DSP编程方面的程序
源代码在线查看: codec.c
/* Set up the CODEC */
int codec()
{
int temp = 0;
/* Set up control register 3 for S/W reset */
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(1);
mcbsp0_read();
mcbsp0_write(0x0386);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
/* Set up control register 3 for mic input */
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(1);
mcbsp0_read();
mcbsp0_write(0x0306);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(1);
mcbsp0_read();
mcbsp0_write(0x2330);
temp = mcbsp0_read();
mcbsp0_write(0x0);
mcbsp0_read();
mcbsp0_write(0x0);
mcbsp0_read();
if((temp & 0xff) != 0x06)
{
printf ("Error in setting up register 3. %x\n", temp);
return(1);
}
/* Set up control register 4 */
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(1);
mcbsp0_read();
mcbsp0_write(0x0400);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(1);
mcbsp0_read();
mcbsp0_write(0x2430);
temp = mcbsp0_read();
mcbsp0_write(0x0);
mcbsp0_read();
mcbsp0_write(0x0);
mcbsp0_read();
if((temp & 0xff) != 0x00)
{
printf ("Error in setting up register 4.\n");
return(1);
}
/* Set up control register 5 */
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(1);
mcbsp0_read();
mcbsp0_write(0x0586);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(0);
mcbsp0_read();
mcbsp0_write(1);
mcbsp0_read();
mcbsp0_write(0x2530);
temp = mcbsp0_read();
mcbsp0_write(0x0);
mcbsp0_read();
mcbsp0_write(0x0);
mcbsp0_read();
if((temp & 0xfe) != 0x86)
{
printf ("Error in setting up register 5.\n");
return(1);
}
return(0);
}