Texas Instruments TMS320 User Manual page 211

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

Advertisement

6.4.1
Writing Data to a Pipe
There are no special format or data type requirements for the data to be
transferred by a pipe.
The DSP/BIOS online help describes data pipe objects and their parameters.
See PIP Module in the TMS320 DSP/BIOS API Reference Guide for your
platform for information on the PIP module API.
The steps that a program should perform to write data to a pipe are as follows:
1) A function should first check the number of empty frames available to be
filled with data. To do this, the program must check the return value of
PIP_getWriterNumFrames. This function call returns the number of
empty frames in a pipe object.
2) If the number of empty frames is greater than 0, the function then calls
PIP_alloc to get an empty frame from the pipe.
3) Before returning from the PIP_alloc call, DSP/BIOS checks whether
there are additional empty frames available in the pipe. If so, the
notifyWriter function is called at this time.
4) Once PIP_alloc returns, the empty frame can be used by the application
code to store data. To do this the function needs to know the frame's start
address and its size. The API function PIP_getWriterAddr returns the
address of the beginning of the allocated frame. The API function
PIP_getWriterSize returns the number of words that can be written to the
frame. (The default value for an empty frame is the configured frame
size.)
5) When the frame is full of data, it can be returned to the pipe. If the number
of words written to the frame is less than the frame size, the function can
specify this by calling the PIP_setWriterSize function. Afterwards, call
PIP_put to return the data to the pipe.
6) Calling PIP_put causes the notifyReader function to run. This enables the
writer thread to notify the reader thread that there is data available in the
pipe to be read.
The code fragment in Figure 6-1 demonstrates how to write data to a pipe.
Data Pipe Manager (PIP Module)
Input/Output Methods
6-9

Advertisement

Table of Contents
loading

Table of Contents