Download How the Pros Develop Embedded Software
Transcript
}
buffers[prev].nextBuf=calcBuf;
buffers[calcBuf].nextBuf=NIL;
calcBuf=NIL;
}
EnableInterrupts();
}
/*
* FreeBuf
*
*
If outBuf is NIL, call the error handler.
*
Otherwise put the buffer indicated by outBuf
*
onto the free chain. Set outBuf to NIL.
*
*
This method is only called from within the
*
DMAOut() interrupt routine, and so there is
*
no need to disable interrupts.
*/
void FreeBuf(void)
{
if(outBuf==NIL) {
HandleError(NO_BUF_TO_FREE);
} else {
buffers[outBuf].nextBuf=firstFree;
firstFree=outBuf;
outBuf=NIL;
}
}
/*
* GetBuf
*
*
If outBuf is not NIL, call the error handler.
*
If there are no output list buffers, call the error handler.
*
Otherwise, remove the first buffer from the output list
*
and place it in the outBuf station. Return a pointer
*
to the first word of the free buffer.
*
*
This method is only called from within the
*
DMAOut() interrupt routine, and so there is
*
no need to disable interrupts.
*/
BUF *GetBuf(void)
{
BUF *dabuf=NULL;
if(outBuf!=NIL) {
HandleError(STILL_USING_OUTPUT_BUF);
} else if(firstOut==NIL) {
HandleError(NO_OUTPUT_BUFFERS);
} else {
outBuf=firstOut;
dabuf=&buffers[outBuf];
firstOut=dabuf->nextBuf;
}
return dabuf;
}
/*
* calc.h
*
*
Header file for the Calc object
*
*/
#ifndef CALC_H
#define CALC_H
/*
* public methods
*/
void InitCalc (void);
s16 Calc(BUF *bptr);
#endif
/*
* calc.c
*
*
A voice substitution device module.
*
Copyright 2003, David Clifton
*
All Rights Reserved
*
* This module manages the signal processing
* calculations for the voice substitution device.
*
*/
#include "types.h"
#include "error.h"
#include "bufman.h"
#include "voice.h"
#include "tone.h"
#include "calc.h"
/*
* calc states