EasyManua.ls Logo

Texas Instruments TMS320

Texas Instruments TMS320
288 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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));
}

Table of Contents

Other manuals for Texas Instruments TMS320

Related product manuals