Closing Devices
Streaming I/O and Device Drivers
7-41
7.14 Closing Devices
A device is closed by calling SIO_delete, which in turn calls Dxx_idle and
Dxx_close. Dxx_close closes the device after Dxx_idle returns the device to
its initial state, which is the state of the device immediately after it was
opened. This is shown in Example 7-31.
Example 7-31.
Closing a Device
/*
* ======== Dxx_idle ========
*/
Int Dxx_idle(DEV_Handle device, Bool flush)
{
Dxx_Handle objptr = (Dxx_Handle) device->object;
Uns post_count;
/*
* The only time we will wait for all pending data
* is when the device is in output mode, and flush
* was not requested.
*/
if ((device->mode == DEV_OUTPUT) && !flush)
{
/* first, make sure device is started */
if ( `device is not started` &&
`device has received data` ) {
`start the device`
}
/*
* wait for all output buffers to be consumed by the
* output HWI. We need to maintain a count of how many
* buffers are returned so we can set the semaphore later.
*/
post_count = 0;
while (!QUE_empty(device->todevice)) {
SEM_pend(objptr->sync, SYS_FOREVER);
pos+;
}
if (`there is a buffer currently in use by the HWI` ) {
SEM_pend(objptr->sync, SYS_FOREVER);
pos+;
}
`stop the device`
Summary of Contents for TMS320 Series
Page 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Page 16: ...xvi ...
Page 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Page 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Page 202: ...5 20 ...
Page 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Page 288: ...Index 10 Index ...