Specifications
Reviewing the Source Code
5-4
■
The dataIO function calls SWI_dec, which decrements a counter
associated with a software interrupt object. When the counter
reaches 0, the software interrupt schedules its function for execution
and resets the counter.
The dataIO function simulates hardware-based data I/O. A typical
program accumulates data in a buffer until it has enough data to
process. In this example, the dataIO function is performed 10 times
for each time the processing function is performed. The counter
decremented by SWI_dec controls this.
#include <std.h>
#include <log.h>
#include <swi.h>
#include "volume.h"
/* Global declarations */
Int inp_buffer[BUFSIZE]; /* processing data buffers */
Int out_buffer[BUFSIZE];
Int gain = MINGAIN; /* volume control variable */
Uns processingLoad = BASELOAD; /* processing load value */
/* Objects created by the Configuration Tool */
extern far LOG_Obj trace;
extern far SWI_Obj processing_SWI;
/* Functions */
extern Void load(Uns loadValue);
Int processing(Int *input, Int *output);
Void dataIO(Void);
/* ======== main ======== */
Void main()
{
LOG_printf(&trace,"volume example started\n");
/* fall into DSP/BIOS idle loop */
return;
}