📄 audio.c
字号:
/*
* Copyright 2000 by Texas Instruments Incorporated.
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
* U.S. Patent Nos. 5,283,900 5,392,448
*/
/* "@(#) DSP/BIOS 4.00 03-27-00 (barracuda-e08)" */
/*
* ======== audio.c ========
*/
#include <std.h>
#include <pip.h>
#include <swi.h>
#include <log.h>
#include <trc.h>
/* The following external objects are defined in the config file audio.cdb */
extern far LOG_Obj trace; /* application printf() log */
static Void error(Void); /* called if an error occurs */
extern Void DSS_init(Void); /* Initialize codec and serial port */
extern Void AUDIO_load(Int); /* */
Void load(Int ); /* simulate CPU load */
Int loadVal = 0;
/*
* ======== main ========
*/
Void main()
{
DSS_init();
LOG_printf(&trace, "Audio example started!!\n");
/* fall into BIOS idle loop */
return;
}
/*
* ======== audio ========
*/
Void audio(PIP_Obj *in, PIP_Obj *out)
{
Uns *src, *dst;
Uns size;
if (PIP_getReaderNumFrames(in) == 0 || PIP_getWriterNumFrames(out) == 0) {
error();
}
/* get input data and allocate output buffer */
PIP_get(in);
PIP_alloc(out);
/* copy input data to output buffer */
src = PIP_getReaderAddr(in);
dst = PIP_getWriterAddr(out);
size = PIP_getReaderSize(in);
PIP_setWriterSize(out,size);
for (; size > 0; size--) {
*dst++ = *src++;
}
/* output copied data and free input buffer */
PIP_put(out);
PIP_free(in);
}
/*
* ======== error ========
*/
static Void error(Void)
{
LOG_printf(&trace, "Error: audio signal falsely triggered!");
for (;;) {
; /* loop for ever */
}
}
/*
* ======== load ========
*/
Void load(Int prd_ms)
{
static int oldLoad = 0;
/* display confirmation of load changes */
if (oldLoad != loadVal ) {
oldLoad = loadVal;
LOG_printf(&trace,
"load: new load = %d000 instructions every %d ms", loadVal, prd_ms);
}
if (loadVal) {
AUDIO_load(loadVal);
}
}
/*
* ======== step ========
*/
Void step(void)
{
static Int direction = 1;
if (loadVal > 800) {
direction = -1;
}
if (loadVal <= 0) {
direction = 1;
}
loadVal = loadVal + (100 * direction);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -