/*****************************************************************************
|
* dsp_core_Core1.c
|
*****************************************************************************/
|
#include <stdlib.h>
|
#include <stdio.h>
|
#include <ctime>
|
#include <sru.h>
|
//#include <def21489.h>
|
#include <def1802.h>
|
//#include <cdef21489.h>
|
#include <cdef1802.h>
|
#include <string.h>
|
#include "../drv/spi.h"
|
#include "config.h"
|
#include "../drv/board.h"
|
#include "../drv/sport.h"
|
#include "../drv/memory.h"
|
#include "../drv/PLL.h"
|
#include "../drv/FIR_acc.h"
|
#include "messageproc.h"
|
#include "queue.h"
|
#include "tob.h"
|
#include "f2f.h"
|
#include "ModuleProAPI.h"
|
//#include "../lz/quicklz.h"
|
|
#define LEVEL_REPORT_TIME (100*SAMPLE_RATE/(1000*SAMPLE_NUM))
|
|
//volatile u32 DMACount =0;
|
u32 DMACount =0;
|
u32 test_count;
|
ufloat proc_secs;
|
ubool DDRPassed = ufalse;
|
ubool HandShakeSuccesful = ufalse;
|
ubool TopoLoading = ufalse;
|
u8 mDspIndex = 0;
|
static eDSPStatus dsp_status = eDSPStatus::dsp_unknow;
|
|
|
uvoid AudioProcCallBack ()
|
{
|
ToB* tob = ToB::GetInstance();
|
ufloat clock_start,clock_stop;
|
|
if(tob) {
|
clock_start = clock();
|
UpdateInput(DMACount&0x1);
|
tob->toProc();
|
UpdateOutput(DMACount&0x1);
|
clock_stop = clock();
|
proc_secs = ((ufloat) (clock_stop - clock_start))/ CLOCKS_PER_SEC;
|
}
|
|
DMACount++;
|
dsp_status = eDSPStatus::dsp_running_ok;
|
}
|
|
|
int main(int argc, char *argv[])
|
{
|
ubool clock_ok = ufalse;
|
u32 ledCount = 0, ledOn = 0;
|
MSG msg;
|
u32 levelCount = 0;
|
u32 test = 0;
|
|
//initPLL_SDRAM();
|
|
//lz_test();
|
|
DAI_config();
|
|
pinmux_config();
|
|
DDRPassed = sram_init();
|
while(!DDRPassed) {
|
SRU(LOW,DPI_PB13_I);
|
SRU(LOW,DPI_PB14_I);
|
for(u32 j=0 ;j < 5000000 ;j++);
|
SRU(HIGH,DPI_PB13_I);
|
SRU(HIGH,DPI_PB14_I);
|
for(u32 j=0 ;j < 5000000 ;j++);
|
}
|
|
// while(1){
|
// SRU(LOW,DPI_PB13_I);
|
// SRU(LOW,DPI_PB14_I);
|
// for(u32 j=0 ;j < 5000000 ;j++);
|
// SRU(HIGH,DPI_PB13_I);
|
// SRU(HIGH,DPI_PB14_I);
|
// for(u32 j=0 ;j < 5000000 ;j++);
|
// }
|
|
fir_acc_init();
|
|
spi_init();
|
|
Message* spiMsg = new Message(4);
|
spiMsg->PushDSPStatus(DSP_EMULATE_DEBUG, 0 );
|
spiMsg->DSPStatusProcess(&msg);
|
|
//֪ͨMCUÆô¶¯Íê³É
|
SRU(HIGH,DPI_PB12_I);
|
SRU(HIGH,DPI_PB11_I);
|
#define LEVEL_REPORT_TIME (100*SAMPLE_RATE/(1000*SAMPLE_NUM))
|
|
while(1) {
|
//pinmux_config();
|
ModulesAsynProcess();
|
|
spiMsg->Proc();
|
|
if(DMACount - ledCount > (SAMPLE_RATE/SAMPLE_NUM)) {
|
u32 unused_memory ;
|
|
if(ledOn){
|
SRU(LOW,DPI_PB13_I);
|
}
|
else{
|
SRU(HIGH,DPI_PB13_I);
|
}
|
ledOn = 1-ledOn;
|
ledCount = DMACount;
|
|
unused_memory = sram_unused_space();
|
spiMsg->PushDSPStatus(DSP_MEM_UTILITY, 10000-unused_memory*0.1436121323529412f );
|
spiMsg->PushDSPStatus(DSP_CPU_UTILITY, proc_secs*SAMPLE_RATE*10000 /SAMPLE_NUM );
|
spiMsg->PushDSPStatus(DSP_RUNNING_STATUS, dsp_status);
|
spiMsg->DSPStatusProcess(&msg);
|
}
|
|
if(clock_ok == 0 && DMACount > 0 && HandShakeSuccesful){
|
//DSP²úÉúʱÖÓÉϱ¨MCUÕý³£ÔË×÷
|
spiMsg->PushDSPStatus(DSP_CLOCK_STATUS, 0 );
|
clock_ok = utrue;
|
}
|
|
if(DMACount - levelCount > LEVEL_REPORT_TIME) {
|
if( TopoLoading ){
|
if(ledOn) SRU(LOW,DPI_PB13_I);
|
else SRU(HIGH,DPI_PB13_I);
|
ledOn = 1-ledOn;
|
}
|
levelCount = DMACount;
|
}
|
}
|
|
}
|