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 #252 background imageLoading...
Page #252 background image
Controlling Streams
7-22
7.5 Controlling Streams
A physical device typically requires one or more specialized control signals in
order to operate as desired. SIO_ctrl makes it possible to communicate with
the device, passing it commands and arguments. Since each device admits
only specialized commands, you need to consult the documentation for each
particular device. The general calling format is shown in Example 7-10.
Example 7-10. Using SIO_ctrl to Communicate with a Device
The device associated with stream is passed the command represented by
the device-specific cmd. A generic pointer to the command’s arguments is
also passed to the device. The actual control function that is part of the device
driver then interprets the command and arguments and acts accordingly.
Assume that an analog-to-digital converter device /a2d has a control
operation to change the sample rate. The sample rate might be changed to
12 kHz as shown in Example 7-11.
Example 7-11. Changing Sample Rate
In some situations, you can synchronize with an I/O device that is doing
buffered I/O. There are two methods to synchronize with the devices:
SIO_idle and SIO_flush. Either function leaves the device in the idled state.
Idling a device means that all buffers are returned to the queues that they
were in when the device was initially created. That is, the device is returned
to its initial state, and streaming is stopped.
For an input stream, the two functions have the same results: all unread input
is lost. For an output stream, SIO_idle blocks until all buffered data has been
written to the device. However, SIO_flush discards any data that has not
already been written. SIO_flush does not block as shown in Example 7-12.
Example 7-12. Synchronizing with a Device
An idle stream does not perform I/O with its underlying device. Thus, you can
turn a stream off until further I/O is needed by calling SIO_idle or SIO_flush.
Int SIO_ctrl(stream, cmd, arg)
SIO_Handle stream;
Uns cmd;
Ptr arg;
SIO_Handle stream;
stream = SIO_create("/a2d", ...);
SIO_ctrl(stream, DAC_RATE, 12000);
Void SIO_idle(stream);
SIO_Handle stream;
Void SIO_flush(stream);
SIO_Handle stream;

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