Texas Instruments TMS320 User Manual page 274

Dsp/bios v5.40
Hide thumbs Also See for TMS320:
Table of Contents

Advertisement

Device Ready
Example 7-33. SIO_Select Pseudocode
7-44
The device's ready semaphore handle is set to the semaphore handle
passed in by SIO_select. To better understand Dxx_ready, consider the
following details of SIO_select.
SIO_select can be summarized in pseudocode as shown in Example 7-33.
/*
*
======== SIO_select ========
*/
Uns SIO_select(streamtab, n, timeout)
SIO_Handle streamtab[];
Int
n;
Uns
timeout;
{
Int
i;
Uns
mask = 1;
Uns
ready = 0;
SEM_Handle sem;
SIO_Handle *stream;
/*
* For efficiency, the "real" SIO_select() doesn't call
* SEM_create() but instead initializes a SEM_Obj on the
* current stack.
*/
sem = SEM_create(0, NULL);
stream = streamtab;
for (i = n; i > 0; i--, stream++) {
/*
* call each device ready function with 'sem'
*/
if ( `Dxx_ready(device, sem)` )
ready = 1;
}
}
if (!ready) {
/* wait until at least one device is ready */
SEM_pend(sem, timeout);
}
ready = 0;
stream = streamtab;
for (i = n; i > 0; i--, stream++) {
/*
* Call each device ready function with NULL.
* When this loop is done, ready will have a bit set
* for each ready device.
*/
if ( `Dxx_ready(device, NULL)` )
ready |= mask;
}
mask = mask << 1;
}
return (ready);
}
/* array of streams */
/* number of streams */
/*
passed to SEM_pend() */
/* used to build ready mask */
/* bit mask of ready streams */
/* local semaphore */
/* pointer into streamtab[] */

Advertisement

Table of Contents
loading

Table of Contents