#include <stdio.h>
|
#include <string.h>
|
#include <sru.h>
|
#include <time.h>
|
#include <math.h>
|
#include <sysreg.h>
|
#include <alg.h>
|
#include "drv/global.h"
|
#include "drv/pll.h"
|
#include "drv/board_sru.h"
|
#include "drv/ad1939.h"
|
#include "drv/sport.h"
|
#include "drv/hmem.h"
|
#include "drv/spi.h"
|
#include "drv/fft.h"
|
#include "f2f.h"
|
#include "execute.h"
|
#include "queue.h"
|
#include "jitter.h"
|
#include "report.h"
|
|
extern double proc_secs;///////////////////////////////////////////////////////
|
extern void* hans,* haec, *hafc;
|
double cpu_get_process_ulitity(void);
|
|
#pragma section("scene_mem")
|
static int mem_test = 0xefbcdda5;
|
|
|
//jitter_mem* pusb_input_jitter =0;
|
//jitter_mem* pusb_output_jitter =0;
|
|
|
static short cpu_cal_ulitily(void)
|
{
|
double aec_secs = alg_aec_get_ulitily(haec);
|
double ans_secs = alg_ans_get_ulitily(hans);
|
|
double total_secs;
|
|
total_secs = proc_secs*7.5+ (aec_secs+ans_secs);
|
proc_secs = 0 ;
|
|
return (total_secs*100000/10);
|
|
}
|
|
|
void main()
|
{
|
|
int i ;
|
int led_on=0;
|
int led_count=0;
|
int loop_cnt=0;
|
|
short value;
|
unsigned short size;////////////////////////////////////////////////
|
extern int clock_ok ;
|
|
extern int sp_flag ;
|
extern int inputcnt;
|
extern int dma_count;
|
extern void* htx_que;
|
extern int msg_process(void);
|
extern int dsp_index ;
|
extern int dsp_status;
|
extern int handshake_successful;
|
|
initPLL_SDRAM(); //Initialize the PLL and SDRAM controller
|
|
InitDAI();
|
|
//float t = NORMALIZE(0x0000b32f)*(1.0f/0x7fff);
|
|
i = sizeof(tag_parameters);
|
|
SRU(DPI_PB06_O, FLAG6_I);
|
sysreg_bit_set(sysreg_FLAGS, FLG6);
|
dsp_index = sysreg_bit_tst(sysreg_FLAGS , FLG6);
|
|
//GPIO
|
SRU(HIGH, DPI_PBEN11_I); //0-busy,1-idle
|
SRU(HIGH, DPI_PBEN12_I); //0-send, 1-recva
|
SRU(LOW,DPI_PB11_I);
|
SRU(LOW,DPI_PB12_I);
|
|
|
// test_dft();
|
|
SRU(HIGH,DPI_PBEN13_I);//led
|
SRU(HIGH,DPI_PBEN14_I);
|
for(i=0;i<3;i++){
|
SRU(LOW,DPI_PB13_I);
|
SRU(LOW,DPI_PB14_I);
|
Delay(1000000);
|
SRU(HIGH,DPI_PB13_I);
|
SRU(HIGH,DPI_PB14_I);
|
Delay(1000000);
|
}
|
|
|
hmem_init();
|
|
spi_init(DEVICE_DMA);
|
|
|
// hrx_que = queue_create(8*16);
|
htx_que = queue_create(SPI_PKT_SIZE*2);
|
//pusb_input_jitter = jitter_create(512);
|
// pusb_output_jitter = jitter_create(512);
|
|
//sdram check help find problem
|
if( mem_test != 0xefbcdda5){
|
dsp_status = dsp_mem_err;
|
//֪ͨMCUÆô¶¯Íê³É
|
SRU(HIGH,DPI_PB11_I);
|
SRU(HIGH,DPI_PB12_I);
|
while(1){
|
loop_cnt++;
|
if(loop_cnt>=1000000){
|
if(led_on){
|
SRU(HIGH,DPI_PB13_I);
|
}
|
else{
|
SRU(LOW,DPI_PB13_I);
|
}
|
led_on = !led_on;
|
loop_cnt =0;
|
}
|
msg_process();
|
}
|
}
|
|
alg_lib_init();
|
|
//fft_init();
|
|
output_empty();
|
|
InitSRC();
|
InitSPORT(0x3,RATE_SAMPLES);
|
//InitSRC();
|
//interrupts(SIG_SP1, sport_isr);
|
interruptcb(SIG_SP1, sport_isr);
|
|
//usb
|
interruptcb(SIG_SP5, sport_usb_isr);
|
|
|
//debug״̬ÇëÇóMCUÖØÐ·¢ËÍÊý¾Ý
|
device_status_report(DSP_EMULATE_DEBUG,0, 0);
|
msg_report_dsp_status(MSG_DSP_STATUS_REPORT);
|
|
|
//֪ͨMCUÆô¶¯Íê³É
|
SRU(HIGH,DPI_PB11_I);
|
SRU(HIGH,DPI_PB12_I);
|
|
#define LED_PERIOD (1000*RATE_SAMPLES/(NUM_SAMPLES*1000))
|
|
//main loop
|
while(1){
|
if(haec != NULL ){
|
alg_aec_process_asy(haec);
|
}
|
|
if(hans != NULL){
|
alg_ans_process_asy(hans);
|
}
|
|
|
msg_process();
|
|
|
if(dma_count-led_count>LED_PERIOD){
|
if(led_on){
|
SRU(LOW,DPI_PB13_I);
|
}
|
else{
|
SRU(HIGH,DPI_PB13_I);
|
}
|
|
size = hmem_perused(SRAM_AUTO);
|
device_status_report(DSP_MEM_UTILITY,(short*)&size, 1);
|
|
value = cpu_cal_ulitily();
|
device_status_report(DSP_CPU_UTILITY,&value , 1);
|
device_status_report(DSP_RUNNING_STATUS,(short*)&dsp_status ,1);
|
|
msg_report_dsp_status(MSG_DSP_STATUS_REPORT);
|
led_on=!led_on;
|
led_count = dma_count;
|
loop_cnt =0;
|
}
|
loop_cnt++;
|
if(loop_cnt>10000000){
|
dsp_status = dsp_no_clock;
|
loop_cnt =0;
|
}
|
|
if(clock_ok == 0 && dsp_status==dsp_running_ok && handshake_successful){
|
//DSP²úÉúʱÖÓÉϱ¨MCUÕý³£ÔË×÷
|
device_status_report(DSP_CLOCK_STATUS,0 ,0 );
|
clock_ok = 1;
|
}
|
}
|
}
|