Texas Instruments TMS320 User Manual page 245

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

Advertisement

Example 7-7. Using the Issue/Reclaim Model
/*
======== doIRstreaming ======== */
Void doIRstreaming(Uns nloops)
{
Ptr
Arg
Int
/* 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) {
}
/* Reclaim full buffer from the input stream */
if ((nbytes = SIO_reclaim(input, &buf, &arg)) < 0) {
}
/* Issue full buffer to the output stream */
if (SIO_issue(output, buf, nbytes, NULL) < 0) {
}
/* Reclaim empty buffer from the output stream to be reused */
if (SIO_reclaim(output, &buf, &arg) < 0) {
}
}
/* 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));
}
buf;
arg;
i, nbytes;
SYS_abort("Error issuing buffer %d", i);
SYS_abort("Error reclaiming buffer %d", i);
SYS_abort("Error issuing buffer %d", i);
SYS_abort("Error reclaiming buffer %d", i);
The output for Example 7-7 is the same as found in Example 7-5.
Stream I/O—Reading and Writing Streams
Streaming I/O and Device Drivers
7-15

Advertisement

Table of Contents
loading

Table of Contents