#include "global.h" int sport0a_buf[2][NUM_SAMPLES*2]; int sport0b_buf[2][NUM_SAMPLES*2]; int sport1a_buf[2][NUM_SAMPLES*2]; int sport1b_buf[2][NUM_SAMPLES*2]; int sport2a_buf[2][NUM_SAMPLES*2]; int sport2b_buf[2][NUM_SAMPLES*2]; int sport3a_buf[2][NUM_SAMPLES*2]; int sport3b_buf[2][NUM_SAMPLES*2]; #if PHY_NUM_INPUTS>8 int sport4a_buf[2][NUM_SAMPLES*2]; int sport4b_buf[2][NUM_SAMPLES*2]; int sport5a_buf[2][NUM_SAMPLES*2]; int sport5b_buf[2][NUM_SAMPLES*2]; int sport6a_buf[2][NUM_SAMPLES*2]; int sport6b_buf[2][NUM_SAMPLES*2]; int sport7a_buf[2][NUM_SAMPLES*2]; int sport7b_buf[2][NUM_SAMPLES*2]; #endif //2 For ping-pong ,each TCB has four registers. int sport0a_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport0a_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport0a_buf[1]} }; int sport0b_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport0b_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport0b_buf[1]} }; int sport1a_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport1a_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport1a_buf[1]} }; int sport1b_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport1b_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport1b_buf[1]} }; int sport2a_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport2a_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport2a_buf[1]} }; int sport2b_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport2b_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport2b_buf[1]} }; int sport3a_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport3a_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport3a_buf[1]} }; int sport3b_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport3b_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport3b_buf[1]} }; #if PHY_NUM_INPUTS>8 int sport4a_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport4a_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport4a_buf[1]} }; int sport4b_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport4b_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport4b_buf[1]} }; int sport5a_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport5a_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport5a_buf[1]} }; int sport5b_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport5b_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport5b_buf[1]} }; int sport6a_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport6a_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport6a_buf[1]} }; int sport6b_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport6b_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport6b_buf[1]} }; int sport7a_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport7a_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport7a_buf[1]} }; int sport7b_tcb[2][4] = { {0, NUM_SAMPLES*2, 1, (int) sport7b_buf[0]}, {0, NUM_SAMPLES*2, 1, (int) sport7b_buf[1]} }; #endif void InitSPORT(int mask, int fs) { int i; int fs_div = MCLK/fs; int sclk_div = MCLK/(fs*64); #ifndef DEMO_BOARD //PCG *pPCG_CTLA0 = fs_div | ENFSA | ENCLKA ; *pPCG_CTLA1 = sclk_div | CLKASOURCE | FSASOURCE | ((sclk_div/2) << 20) ; #endif /* External clock and frame syncs generated by AD1939 */ *pDIV0 = 0x00000000; // Transmitter (SPORT0) *pDIV1 = 0x00000000; // Receiver (SPORT1) at 12.288 MHz SCLK and 48 kHz sample rate if(mask&0x1){ *pSPCTL0 =0 ; *pSPMCTL0 = 0; *pSPCTLN0 =0; sport0a_tcb[0][0]= ((int)sport0a_tcb[1] + 3)&0x7ffff | (1<<19); sport0a_tcb[1][0]= ((int)sport0a_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP0A = sport0a_tcb[0][0]; sport0b_tcb[0][0]= ((int)sport0b_tcb[1] + 3)&0x7ffff | (1<<19); sport0b_tcb[1][0]= ((int)sport0b_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP0B = sport0b_tcb[0][0]; *pSPCTL0 = (SPTRAN | OPMODE | SLEN32 | SPEN_A | SCHEN_A | SDEN_A | SPEN_B | SCHEN_B | SDEN_B); } if(mask&0x2){ *pSPCTL1 =0 ; *pSPMCTL1 = 0; *pSPCTLN1 =0; sport1a_tcb[0][0]= ((int)sport1a_tcb[1] + 3)&0x7ffff | (1<<19); sport1a_tcb[1][0]= ((int)sport1a_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP1A = sport1a_tcb[0][0]; sport1b_tcb[0][0]= ((int)sport1b_tcb[1] + 3)&0x7ffff | (1<<19); sport1b_tcb[1][0]= ((int)sport1b_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP1B = sport1b_tcb[0][0]; *pSPCTL1 = (OPMODE | SLEN32 | SPEN_A | SCHEN_A | SDEN_A | SPEN_B | SCHEN_B | SDEN_B); } if(mask&0x4){ *pSPCTL2 =0 ; *pSPMCTL2 = 0; *pSPCTLN2 =0; sport2a_tcb[0][0]= ((int)sport2a_tcb[1] + 3)&0x7ffff | (1<<19); sport2a_tcb[1][0]= ((int)sport2a_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP2A = sport2a_tcb[0][0]; sport2b_tcb[0][0]= ((int)sport2b_tcb[1] + 3)&0x7ffff | (1<<19); sport2b_tcb[1][0]= ((int)sport2b_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP2B = sport2b_tcb[0][0]; *pSPCTL2 = (SPTRAN | OPMODE | SLEN32 | SPEN_A | SCHEN_A | SDEN_A | SPEN_B | SCHEN_B | SDEN_B); } if(mask&0x8){ *pSPCTL3 =0 ; *pSPMCTL3 = 0; *pSPCTLN3 =0; sport3a_tcb[0][0]= ((int)sport3a_tcb[1] + 3)&0x7ffff | (1<<19); sport3a_tcb[1][0]= ((int)sport3a_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP3A = sport3a_tcb[0][0]; sport3b_tcb[0][0]= ((int)sport3b_tcb[1] + 3)&0x7ffff | (1<<19); sport3b_tcb[1][0]= ((int)sport3b_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP3B = sport3b_tcb[0][0]; *pSPCTL3 = (OPMODE | SLEN32 | SPEN_A | SCHEN_A | SDEN_A | SPEN_B | SCHEN_B | SDEN_B); } #if PHY_NUM_INPUTS>8 if(mask&0x10){ *pSPCTL4 =0 ; *pSPMCTL4 = 0; *pSPCTLN4 =0; sport4a_tcb[0][0]= ((int)sport4a_tcb[1] + 3)&0x7ffff | (1<<19); sport4a_tcb[1][0]= ((int)sport4a_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP4A = sport4a_tcb[0][0]; sport4b_tcb[0][0]= ((int)sport4b_tcb[1] + 3)&0x7ffff | (1<<19); sport4b_tcb[1][0]= ((int)sport4b_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP4B = sport4b_tcb[0][0]; *pSPCTL4 = (SPTRAN | OPMODE | SLEN32 | SPEN_A | SCHEN_A | SDEN_A | SPEN_B | SCHEN_B | SDEN_B); } if(mask&0x20){ *pSPCTL5 =0 ; *pSPMCTL5 = 0; *pSPCTLN5 =0; sport5a_tcb[0][0]= ((int)sport5a_tcb[1] + 3)&0x7ffff | (1<<19); sport5a_tcb[1][0]= ((int)sport5a_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP5A = sport5a_tcb[0][0]; sport5b_tcb[0][0]= ((int)sport5b_tcb[1] + 3)&0x7ffff | (1<<19); sport5b_tcb[1][0]= ((int)sport5b_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP5B = sport5b_tcb[0][0]; *pSPCTL5 = (OPMODE | SLEN32 | SPEN_A | SCHEN_A | SDEN_A | SPEN_B | SCHEN_B | SDEN_B); } if(mask&0x40){ *pSPCTL6 =0 ; *pSPMCTL6 = 0; *pSPCTLN6 =0; sport6a_tcb[0][0]= ((int)sport6a_tcb[1] + 3)&0x7ffff | (1<<19); sport6a_tcb[1][0]= ((int)sport6a_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP6A = sport6a_tcb[0][0]; sport6b_tcb[0][0]= ((int)sport6b_tcb[1] + 3)&0x7ffff | (1<<19); sport6b_tcb[1][0]= ((int)sport6b_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP6B = sport6b_tcb[0][0]; *pSPCTL6 = (SPTRAN| OPMODE | SLEN32 | SPEN_A | SCHEN_A | SDEN_A | SPEN_B | SCHEN_B | SDEN_B); } if(mask&0x80){ *pSPCTL7 =0 ; *pSPMCTL7 = 0; *pSPCTLN7 =0; sport7a_tcb[0][0]= ((int)sport7a_tcb[1] + 3)&0x7ffff | (1<<19); sport7a_tcb[1][0]= ((int)sport7a_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP7A = sport7a_tcb[0][0]; sport7b_tcb[0][0]= ((int)sport7b_tcb[1] + 3)&0x7ffff | (1<<19); sport7b_tcb[1][0]= ((int)sport7b_tcb[0] + 3)&0x7ffff | (1<<19); *pCPSP7B = sport7b_tcb[0][0]; *pSPCTL7 = (OPMODE | SLEN32 | SPEN_A | SCHEN_A | SDEN_A | SPEN_B | SCHEN_B | SDEN_B); } #endif }