Stream I/O—Reading and Writing Streams
Streaming I/O and Device Drivers
7-15
Example 7-7.
Using the Issue/Reclaim Model
The output for Example 7-7 is the same as found in Example 7-5.
/* ======== doIRstreaming ======== */
Void doIRstreaming(Uns nloops)
{
Ptr buf;
Arg arg;
Int i, nbytes;
/* Prime the stream with a couple of buffers */
buf = MEM_alloc(IDRAM1, SIO_bufsize(input), 0);
if (buf == MEM_ILLEGAL) {
SYS_abort("Memory allocation error");
}
/* Issue an empty buffer to the input stream */
if (SIO_issue(input, buf, SIO_bufsize(input), NULL) < 0) {
SYS_abort("Error issuing buffer %d", i);
}
buf = MEM_alloc(IDRAM1, SIO_bufsize(input), 0);
if (buf == MEM_ILLEGAL) {
SYS_abort("Memory allocation error");
}
for (i = 0; i < nloops; i++) {
/* Issue an empty buffer to the input stream */
if (SIO_issue(input, buf, SIO_bufsize(input), NULL) < 0) {
SYS_abort("Error issuing buffer %d", i);
}
/* Reclaim full buffer from the input stream */
if ((nbytes = SIO_reclaim(input, &buf, &arg)) < 0) {
SYS_abort("Error reclaiming buffer %d", i);
}
/* Issue full buffer to the output stream */
if (SIO_issue(output, buf, nbytes, NULL) < 0) {
SYS_abort("Error issuing buffer %d", i);
}
/* Reclaim empty buffer from the output stream to be reused */
if (SIO_reclaim(output, &buf, &arg) < 0) {
SYS_abort("Error reclaiming buffer %d", i);
}
}
/* Reclaim and delete the buffers used */
MEM_free(IDRAM1, buf, SIO_bufsize(input));
if ((nbytes = SIO_reclaim(input, &buf, &arg)) < 0) {
SYS_abort("Error reclaiming buffer %d", i);
}
if (SIO_issue(output, buf, nbytes, NULL) < 0) {
SYS_abort("Error issuing buffer %d", i);
}
if (SIO_reclaim(output, &buf, &arg) < 0) {
SYS_abort("Error reclaiming buffer %d", i);
}
MEM_free(IDRAM1, buf, SIO_bufsize(input));
}
Содержание TMS320 Series
Страница 1: ...TMS320 DSP BIOS v5 40 User s Guide Literature Number SPRU423G April 2009 ...
Страница 16: ...xvi ...
Страница 152: ...Tasks 4 48 Figure 4 12 Trace from Example 4 7 ...
Страница 168: ...Semaphores 4 64 Figure 4 14 Trace Results from Example 4 11 ...
Страница 202: ...5 20 ...
Страница 287: ...Index 9 Index Void 1 11 W words data memory 3 15 of code 1 5 wrapper function 2 29 ...
Страница 288: ...Index 10 Index ...