Device Control
Streaming I/O and Device Drivers 7-43
7.15 Device Control
Dxx_ctrl is called by SIO_ctrl to perform a control operation on a device. A
typical use of Dxx_ctrl is to change the contents of a device control register
or the sampling rate for an A/D or D/A device. Dxx_ctrl is called as follows:
status = Dxx_ctrl(DEV_Handle device, Uns cmd, Arg arg);
❏ cmd is a device-specific command.
❏ arg provides an optional command argument.
Dxx_ctrl returns SYS_OK if the control operation was successful; otherwise,
Dxx_ctrl returns an error code.
7.16 Device Ready
Dxx_ready is called by SIO_select to determine if a device is ready for I/O.
Dxx_ready returns TRUE if the device is ready and FALSE if the device is not.
The device is ready if the next call to retrieve a buffer from the device will not
block. This usually means that there is at least one available frame on the
queue device->fromdevice when Dxx_ready returns as shown in Example 7-
32. Refer to section 7.6, Selecting Among Multiple Streams, page 7-23, for
more information on SIO_select.
Example 7-32. Making a Device Ready
If the mode is DEV_INPUT, the streaming model is DEV_STANDARD. If the
device has not been started already, the device is started. This is necessary,
since in the DEV_STANDARD streaming model, SIO_select can be called by
the application before the first call to SIO_get.
Bool Dxx_ready(DEV_Handle dev, SEM_Handle sem)
{
Dxx_Handle objptr = (Dxx_Handle)device->object;
/* register the ready semaphore */
objptr->ready = sem;
if ((device->mode == DEV_INPUT) &&
((device->model == DEV_STANDARD) &&
`device is not started` )) {
`start the device`
}
/* return TRUE if device is ready */
return ( `TRUE if device->fromdevice has a frame or
device won't block` );
}