EasyManuals Logo

Texas Instruments TMS320 User Manual

Texas Instruments TMS320
288 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #271 background imageLoading...
Page #271 background image
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);
post_count++;
}
if (`there is a buffer currently in use by the HWI` ) {
SEM_pend(objptr->sync, SYS_FOREVER);
post_count++;
}
`stop the device`

Table of Contents

Other manuals for Texas Instruments TMS320

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments TMS320 and is the answer not in the manual?

Texas Instruments TMS320 Specifications

General IconGeneral
BrandTexas Instruments
ModelTMS320
CategoryComputer Hardware
LanguageEnglish

Related product manuals