?? sport core driven.c
字號:
// **********************************************************************************
// * ADSP-2126x SPORT Internal Loopback Example - DMA Driven Example *
// * *
// * This example loops back data from tx_buf to rx_buf via SPORT4 to SPORT5 *
// * *
// * *
// * Author: Brian M. *
// * Analog Devices, Inc. *
// * Rev 1.0 *
// * 7/03 *
// **********************************************************************************
#define bufsize 10
#include <signal.h>
#include <stdio.h>
// Interrupt Control Bits
#define CBUFEN 0x01000000
#define IRPTEN 0x00001000
#define SP3I 0x00008000
#define SP2IMSK 0x00000800
#define SP2I 0x00000000
// SPORT Control Registers
#define TXSP2A 0x460
#define RXSP3A 0x465
#define TXSP3A 0x464
#define RXSP2A 0x461
#define DIV2 0x402
#define DIV3 0x403
#define SPCTL2 0x400
#define SPCTL3 0x401
#define SPMCTL23 0x404
// SPORT Control Bits
#define SPL 0x00001000
#define SPEN_A 0x00000001
#define SDEN_A 0x00040000
#define SLEN32 0x000001F0
#define SPTRAN 0x02000000
#define IFS 0x00004000
#define FSR 0x00002000
#define ICLK 0x00000400
int tx_buf2a[bufsize]= {0x11111111,
0x22222222,
0x33333333,
0x44444444,
0x55555555,
0x66666666,
0x77777777,
0x88888888,
0x99999999,
0xAAAAAAAA};
int rx_buf3a[bufsize];
/* ISR counters, for debug purposes to see how many times SPORT DMA interrupts are serviced */
int SP2I_counter = 0;
int SP3I_counter = 0;
void Count_SPORT3_IRQs(int);
void main()
{
interrupt(SIG_SP3,Count_SPORT3_IRQs);
/////////////////////////////////////////////////////////////////////////////////////////
// //
// SPORT Loopback init/test: Use SPORT2 as RX & SPORT3 as TX //
// //
/////////////////////////////////////////////////////////////////////////////////////////
// initially clear SPORT control register
* (volatile int *) SPCTL2 = 0;
* (volatile int *) SPCTL3 = 0;
* (volatile int *) SPMCTL23 = 0;
SPORT_DMA_setup:
/* set internal loopback bit for SPORT2 & SPORT3 */
* (volatile int *) SPMCTL23 |= SPL;
/* Configure SPORT2 as a transmitter */
/* CLKDIV2=[fCCLK(200MHz)/2xFSCLK(20MHz)]-1 = 0x0004 */
/* FSDIV2=[FSCLK(20 MHz)/TFS(.625 MHz)]-1 = 31 = 0x001F */
* (volatile int *) DIV2 = 0x001F0004; //internally generating clock and frame sync
* (volatile int *) SPCTL2 = (SPEN_A | SLEN32 | FSR | SPTRAN | IFS | ICLK);
/* Configure SPORT3 as a receiver */
* (volatile int *) DIV3 = 0; /* externally generating clock and frame sync */
* (volatile int *) SPCTL3 = (SPEN_A | SLEN32 | FSR);
for(SP2I_counter=0;SP2I_counter<10;SP2I_counter++)
* (volatile int *) TXSP2A = tx_buf2a[SP2I_counter%sizeof(tx_buf2a)];
do
{}while (SP3I_counter < 10);
* (volatile int *) SPCTL2 = 0;
* (volatile int *) SPCTL3 = 0;
* (volatile int *) SPMCTL23 = 0;
}
/////////////////////////////////////////////////////////////
// //
// SPORT3 Interrupt Service Routines //
// //
/////////////////////////////////////////////////////////////
void Count_SPORT3_IRQs(int sig_int)
{
rx_buf3a[SP3I_counter%sizeof(rx_buf3a)] = * (volatile int *) RXSP3A;
SP3I_counter++; /* increment count */
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -