?? audio.c
字號:
#include "audio.h"
/* MCBSP1 configuration settings */MCBSP_Config audioCntlCfg = { 0x1000, /* Serial Port Control Register 1 */ 0x0200, /* Serial Port Control Register 2 */ 0x0000, /* Receive Control Register 1 */ 0x0000, /* Receive Control Register 2 */ 0x0040, /* Transmit Control Register 1 */ 0x0001, /* Transmit Control Register 2 */ 0x0063, /* Sample Rate Generator Register 1 */ 0x2000, /* Sample Rate Generator Register 2 */ 0x0000, /* Multichannel Control Register 1 */ 0x0000, /* Multichannel Control Register 2 */ 0x0a0a, /* Pin Control Register */ 0x0000, /* Receive Channel Enable Register Partition A */ 0x0000, /* Receive Channel Enable Register Partition B */ 0x0000, /* Receive Channel Enable Register Partition C */ 0x0000, /* Receive Channel Enable Register Partition D */ 0x0000, /* Receive Channel Enable Register Partition E */ 0x0000, /* Receive Channel Enable Register Partition F */ 0x0000, /* Receive Channel Enable Register Partition G */ 0x0000, /* Receive Channel Enable Register Partition H */ 0x0000, /* Transmit Channel Enable Register Partition A */ 0x0000, /* Transmit Channel Enable Register Partition B */ 0x0000, /* Transmit Channel Enable Register Partition C */ 0x0000, /* Transmit Channel Enable Register Partition D */ 0x0000, /* Transmit Channel Enable Register Partition E */ 0x0000, /* Transmit Channel Enable Register Partition F */ 0x0000, /* Transmit Channel Enable Register Partition G */ 0x0000 /* Transmit Channel Enable Register Partition H */};
/* MCBSP2 configuration settings - 16 bits */MCBSP_Config audioDataCfg = { 0x0000, /* Serial Port Control Register 1 */ 0x0200, /* Serial Port Control Register 2 */ 0x0140, /* Receive Control Register 1 */ 0x0000, /* Receive Control Register 2 */ 0x0140, /* Transmit Control Register 1 */ 0x0000, /* Transmit Control Register 2 */ 0x0000, /* Sample Rate Generator Register 1 */ 0x0000, /* Sample Rate Generator Register 2 */ 0x0000, /* Multichannel Control Register 1 */ 0x0000, /* Multichannel Control Register 2 */ 0x0003, /* Pin Control Register */ 0x0000, /* Receive Channel Enable Register Partition A */ 0x0000, /* Receive Channel Enable Register Partition B */ 0x0000, /* Receive Channel Enable Register Partition C */ 0x0000, /* Receive Channel Enable Register Partition D */ 0x0000, /* Receive Channel Enable Register Partition E */ 0x0000, /* Receive Channel Enable Register Partition F */ 0x0000, /* Receive Channel Enable Register Partition G */ 0x0000, /* Receive Channel Enable Register Partition H */ 0x0000, /* Transmit Channel Enable Register Partition A */ 0x0000, /* Transmit Channel Enable Register Partition B */ 0x0000, /* Transmit Channel Enable Register Partition C */ 0x0000, /* Transmit Channel Enable Register Partition D */ 0x0000, /* Transmit Channel Enable Register Partition E */ 0x0000, /* Transmit Channel Enable Register Partition F */ 0x0000, /* Transmit Channel Enable Register Partition G */ 0x0000 /* Transmit Channel Enable Register Partition H */};
CODEC_Config codecCfg = {
0x0017,
0x0017,
0x00f9,
0x00f9,
0x0010,
0x0000,
0x0000,
0x0043,
0x0001,
0x0001
};
/*Joshuatok*/
/*-----------------------------------------------------------------*/
/* handles to the McBSP ports */
MCBSP_Handle hAudio_cntl;
MCBSP_Handle hAudio_data;
/* configure the audio control and data interface */
void audio_setup(void)
{
/* open the McBSP ports */
hAudio_cntl = MCBSP_open(MCBSP_PORT1, MCBSP_OPEN_RESET);
hAudio_data = MCBSP_open(MCBSP_PORT2, MCBSP_OPEN_RESET);
MCBSP_config(hAudio_cntl, &audioCntlCfg);
MCBSP_config(hAudio_data, &audioDataCfg);
MCBSP_start(hAudio_cntl, MCBSP_XMIT_START
| MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC, 100);
audio_reset();
return;
}
/* reset the audio codec */
void audio_reset(void)
{
Uint16 regnum, regval;
/* reset the codec */
regnum = 15;
regval = 0;
while(!MCBSP_xrdy(hAudio_cntl));
MCBSP_write16(hAudio_cntl, (regnum<<9) | regval);
/* cofigure the codec */
for (regnum=0; regnum<10; regnum++){
while(!MCBSP_xrdy(hAudio_cntl));
regval = codecCfg.regs[regnum] & 0x1ff;
MCBSP_write16(hAudio_cntl, (regnum<<9) | regval);
}
/* clear any data in DRR */
if (MCBSP_rrdy(hAudio_data)){
MCBSP_read16(hAudio_data);
}
}
/* start the audio codec to receive and transmit samples */
void audio_start(void)
{
/* start codec */
MCBSP_start(hAudio_data, MCBSP_XMIT_START | MCBSP_RCV_START
| MCBSP_SRGR_START | MCBSP_SRGR_FRAMESYNC, 220);
}
/*Joshuatok*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -