/*****************************************************************************
|
* dsp_core_Core1.c
|
*****************************************************************************/
|
#include <stdlib.h>
|
#include <stdio.h>
|
#include <sys/platform.h>
|
#include <sys/adi_core.h>
|
#include <ctime>
|
#include <heapnew>
|
#include <matrix.h>
|
#include "adi_initialize.h"
|
#include "../drv/gpio.h"
|
#include "../drv/spi.h"
|
#include "config.h"
|
#include "../drv/board.h"
|
#include "../drv/sport.h"
|
#include "../drv/memory.h"
|
#include "messageproc.h"
|
#include "ModuleProAPI.h"
|
#include "queue.h"
|
#include "tob.h"
|
#include "f2f.h"
|
|
|
u32 g_level_report_interval = LEVEL_REPORT_TIME(200);
|
|
u8 mDspIndex = 0;
|
ubool TopoLoading = ufalse;
|
ubool HandShakeSuccesful = ufalse;
|
ubool TopoRequest = ufalse;
|
u32 DMACount =0;
|
ufloat proc_secs;
|
static ufloat asyn_proc_secs;
|
|
ufloat cpu_utility()
|
{
|
ufloat total_secs ;
|
|
total_secs = asyn_proc_secs + proc_secs*(SAMPLE_RATE*0.01f)/SAMPLE_NUM ;//
|
|
return total_secs*1000*100/10;
|
}
|
|
extern "C" uvoid AudioProcCallBack (uvoid)
|
{
|
ToB* tob = ToB::GetInstance();
|
ufloat clock_start,clock_stop;
|
|
if(tob == NULL) return ;
|
|
if(TopoLoading ){
|
MuteOutput();
|
} else {
|
clock_start = clock();
|
UpdateInput(DMACount&0x1);
|
tob->toProc();
|
UpdateOutput(DMACount&0x1);
|
|
clock_stop = clock();
|
proc_secs = ((ufloat) (clock_stop - clock_start))/ CLOCKS_PER_SEC;
|
ModulesAsynSetInterval(proc_secs);
|
}
|
DMACount++;
|
}
|
|
|
int main(int argc, char *argv[])
|
{
|
int result ;
|
|
s32 ledOn = 0;
|
uint32_t ledCount = 0;
|
uint32_t levelCount = 0;
|
|
extern u32 DMACount;
|
extern ufloat proc_secs;
|
MSG msg;
|
|
adi_initComponents();
|
|
spu_config();
|
|
pinmux_config();
|
//result = DDR_config();
|
sram_init();
|
|
DAI_config();
|
|
Message* spiMsg = new Message(12);
|
spiMsg->Send(MsgType::MSG_REHANDSHAKE_REQ , 0 , 0);
|
|
SPI2_Init();
|
|
while(1) {
|
asyn_proc_secs = ModulesAsynProcess();
|
|
spiMsg->Proc();
|
|
if(DMACount - ledCount > (SAMPLE_RATE/SAMPLE_NUM)) {
|
ToB* tob = ToB::GetInstance();
|
GPIO_SetOutPut(GPIOC, GPIO_Pin0, (GPIO_Level)ledOn);
|
GPIO_SetOutPut(GPIOB, GPIO_Pin10, (GPIO_Level)ledOn);
|
ledOn = 1-ledOn;
|
ledCount = DMACount;
|
spiMsg->DSPStatusProcess(&msg);
|
if(tob) tob->GetModuleCPU(spiMsg, &msg);
|
}
|
|
|
if(DMACount - levelCount > g_level_report_interval) {
|
ToB* tob = ToB::GetInstance();
|
if(tob ) {
|
tob->GetLevels(spiMsg, &msg);
|
}
|
|
if(TopoLoading ){
|
GPIO_SetOutPut(GPIOC, GPIO_Pin0, (GPIO_Level)ledOn);
|
GPIO_SetOutPut(GPIOB, GPIO_Pin10, (GPIO_Level)ledOn);
|
ledOn = 1-ledOn;
|
}
|
levelCount = DMACount;
|
}
|
}
|
|
}
|