Texas Instruments TMS320 User Manual page 213

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

Advertisement

Example 6-2 Reading Data from a Pipe
extern far PIP_Obj readerPipe;
reader()
{
}
6.4.3
Using a Pipe's Notify Functions
5) When the application has finished reading all the data, the frame can be
returned to the pipe by calling PIP_free.
6) Calling PIP_free causes the notifyWriter function to run. This enables the
reader thread to notify the writer thread that there is a new empty frame
available in the pipe.
The code fragment in Example 6-2 demonstrates how to read data from a
pipe.
Uns size;
Ptr addr;
if (PIP_getReaderNumFrames(&readerPipe) > 0) {
PIP_get(&readerPipe);
}
else {
return;
}
addr = PIP_getReaderAddr(&readerPipe);
size = PIP_getReaderSize(&readerPipe);
' read the data from the frame '
/* release the empty frame back to the pipe */
PIP_free(&readerPipe);
The reader or writer threads of a pipe can operate in a polled mode and
directly test the number of full or empty frames available before retrieving the
next full or empty frame. The examples in section 6.4.1, Writing Data to a
Pipe, page 6-9, and section 6.4.2, Reading Data from a Pipe, page 6-10,
demonstrate this type of polled read and write operation.
When used to buffer real-time I/O streams written (read) by a hardware
peripheral, pipe objects often serve as a data channel between the HWI
routine triggered by the peripheral itself and the program function that
ultimately reads (writes) the data. In such situations, the application can
effectively synchronize itself with the underlying I/O stream by configuring the
pipe's notifyReader (notifyWriter) function to automatically post a software
interrupt that runs the reader (writer) function.
/* created statically */
/* get a full frame */
/* There are no available full frames */
Input/Output Methods
Data Pipe Manager (PIP Module)
6-11

Advertisement

Table of Contents
loading

Table of Contents