Texas Instruments TMS320 User Manual page 243

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

Advertisement

Example 7-6. Adding an Output Stream to Example 7-5
======== Portion of siotest2.c ========
/* SIO objects created with conf tool
extern far LOG_Obj trace;
extern far SIO_Obj inputStream;
extern far SIO_Obj outputStream;
extern far TSK_Obj streamTask;
SIO_Handle input = &inputStream;
SIO_Handle output = &outputStream;
...
Void doStreaming(Uns nloops)
{
Void doStreaming(Arg nloops_arg)
{
Int i, nbytes;
Int *buf;
Long nloops = (Long) nloops_arg;
if ( SIO_staticbuf(input, (Ptr *)&buf) == 0) {
SYS_abort("Error reading buffer ");
}
for (i = 0; i < nloops; i++) {
if ((nbytes = SIO_get(input, (Ptr *)&buf)) < 0) {
}
if (SIO_put(output, (Ptr *)&buf, nbytes) < 0) {
}
}
LOG_printf(&trace, "End SIO example #2");
}
/*
======== DGN_print2log ========
* User function for the DGN user device printData. It takes as an argument
* the address of the LOG object where the data stream should be printed. */
Void DGN_print2log(Arg arg, Ptr addr, Uns nbytes)
{
Int
Int
buf = (Int *)addr;
for (i = 0; i < nbytes/sizeof(Int); i++) {
LOG_printf((LOG_Obj *)arg, "%d", buf[i]);
}
SYS_abort("Error reading buffer %d", (Arg)i);
SYS_abort("Error writing buffer %d", (Arg)i);
i;
*buf;
Note:
Non-pointer type function arguments to log_printf need explicit type casting
to (Arg) as shown in the following code example:
LOG_printf(&trace, "Task %d Done", (Arg)id);
Stream I/O—Reading and Writing Streams
*/
Streaming I/O and Device Drivers
7-13

Advertisement

Table of Contents
loading

Table of Contents