#define BUFFER_SIZE 27 /* total number of UART data words */
/* Global Variables */
char xmit_msg[BUFFER_SIZE] = "McBSP does UART on C5000!\n";
char recv_msg[BUFFER_SIZE] = "Transmission didn't work!\n";
/* Get referenc to start of interrupt vector table */
/* This symbol is defined in file, vectors.s54 */
extern void VECSTART(void);
/* Prototypes */
void ConfigMcBSP(void);
void ProcessTransmitData();
void ProcessReceiveData();
int CheckTestCase(void);
short VoteLogic(unsigned short value);
/*******************************************************************/
/* void main(void) */
/*******************************************************************/
void main(void)
{
// int waittime = 0;
// int works = FALSE;
unsigned short * xmitbufptr;
unsigned short * recvbufptr;
unsigned short val;
unsigned short * ptr;
int i;
/* initialize the CSL library */
CSL_init();
/* Set IPTR to start of interrupt vector table */
IRQ_setVecs((Uint16)(&VECSTART));
/* process transmit data */
printf("Processing Transmit string...\n");
ProcessTransmitData();
printf("String transmitted: %s \n", xmit_msg);
/* Open the McBSP channel 1 */
hMcbsp1 = MCBSP_open(MCBSP_PORT1, MCBSP_OPEN_RESET);
/* Setup for McBSP */
ConfigMcBSP();
/* Start the MCBSP and Sample Rate Generator */
MCBSP_start(hMcbsp1,
MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC |
MCBSP_RCV_START | MCBSP_XMIT_START,
0x200
);
// send data for test
/* point to Transmit Buffer */
xmitbufptr = (unsigned short *)xmitbuf;
for( i = 0; i< BUFFER_SIZE * 11; i++ )
{
while (!MCBSP_xrdy(hMcbsp1));
MCBSP_write16(hMcbsp1,xmitbufptr);
//printf("====write 16bit : %d\n",xmitbufptr);
}
// receive test data
recvbufptr = (unsigned short *) recvbuf;
for( i = 0; i< (BUFFER_SIZE * 11); i++ )
{
/* Wait for RRDY signal to read data from DRR */
while (!MCBSP_rrdy(hMcbsp1));
/* Read 16 bit value from DRR */
recvbufptr = MCBSP_read16(hMcbsp1);
}
/* process received data */
printf("Processing Receive string...\n");
ProcessReceiveData();
printf("String received: %s \n", recv_msg);
MCBSP_close(hMcbsp1); /* close McBSP 1 */
printf("============ completed =============\n");
} /* End of main() */