Data Pipe Manager (PIP Module)
6-10
Example 6-1 Writing Data to a Pipe
6.4.2
Reading Data from a Pipe
To read a full frame from a pipe, a program should perform the following
steps:
1) The function should first check the number of full frames available to be
read from the pipe. To do this, the program must check the return value
of PIP_getReaderNumFrames. This function call returns the number of
full frames in a pipe object.
2) If the number of full frames is greater than 0, the function then calls
PIP_get to get a full frame from the pipe.
3) Before returning from the PIP_get call, DSP/BIOS checks whether there
are additional full frames available in the pipe. If so, the notifyReader
function is called at this time.
4) Once PIP_get returns, the data in the full frame can be read by the
application. To do this the function needs to know the frame's start
address and its size. The API function PIP_getReaderAddr returns the
address of the beginning of the full frame. The API function
PIP_getReaderSize returns the number of valid data words in the frame.
extern far PIP_Obj writerPipe; /* created statically */
writer()
{
Uns size;
Uns newsize;
Ptr addr;
if (PIP_getWriterNumFrames(&writerPipe) > 0) {
PIP_alloc(&writerPipe); /* allocate an empty frame */
}
else {
return; /* There are no available empty frames */
}
addr = PIP_getWriterAddr(&writerPipe);
size = PIP_getWriterSize(&writerPipe);
' fill up the frame '
/* optional */
newsize = 'number of words written to the frame';
PIP_setWriterSize(&writerPipe, newsize);
/* release the full frame back to the pipe */
PIP_put(&writerPipe);
}
Summary of Contents for TMS320 Series
Page 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Page 16: ...xvi ...
Page 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Page 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Page 202: ...5 20 ...
Page 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Page 288: ...Index 10 Index ...