?? main.c
字號:
#include "../CPLD.h"
#include "I2C.h"
#include "Aic23b_regdef.h"
#define SPIDelay 10000
#define Sample8K 0
#define Sample48K 1
//unsigned short sports1error;
void Init_Interrupts(void)
{
// assign core IDs to interrupts
*pSICB_IAR0 = 0xffffffff;
*pSICB_IAR1 = 0xffffffff;
*pSICB_IAR2 = 0x2fffffff;
}
void Init_Sports(void)
{
*pSPORT0_TCR2 = 0x001f;
*pSPORT0_TCR1 = 0x4000|0x0400|0x0001|0x2000;
*pSPORT0_RCR2 = 0x001f;
*pSPORT0_RCR1 = 0x4000|0x0400|0x0001|0x2000;
}
/*******************************************************/
/*This function initialize the tlv320aic23b audio codec */
/*
Select line in input.
Line in left and right volume are set to default 0dB,
and simultaneous update is disabled.
Headphone output volume are set to 0x70(-9dB),
and simultaneous update & zero-cross detect is disabled.
Sidetone is disabled.
Bypass is disabled.
Microphone is normal.
DAC soft mute is disabled.
De-emphasis is disabled.
ADC high-pass filter is enabled.
Master mode,16bits.
DAC left/right swap is disable.
MSB is available on 1st BCLK rising edge after LRCIN rising edge
DSP format,frame sync followed by two data words.
Sample Rate Normal mode.
48K.
Clock input divider is 0.
Clock output divider is 0.
*/
/*******************************************************/
unsigned char Init_AIC23B_I2C(void)
{
if(!I2C_Init(AIC23B_IDENT_W))
{return false;}
if(!I2C_Write_Word(PWDC|0x00ff))
{return false;}
if(!I2C_Write_Word(LLVC|0x1d))
{return false;}
if(!I2C_Write_Word(RLVC|0x1d))
{return false;}
if(!I2C_Write_Word(LHVC|0x70))
{return false;}
if(!I2C_Write_Word(RHVC|0x70))
{return false;}
if(!I2C_Write_Word(AAPC|DAC))
{return false;}
if(!I2C_Write_Word(AAPC|DAC|INSEL))
{return false;}
if(!I2C_Write_Word(DAPC))
{return false;}
if(!I2C_Write_Word(DAIF|MS|FOR|LRP))
{return false;}
if(!I2C_Write_Word(SARC))
{return false;}
if(!I2C_Write_Word(DIAC|ACT|RES))
{return false;}
if(!I2C_Write_Word(PWDC))
{return false;}
return true;
}
EX_INTERRUPT_HANDLER(SPORTS0_RX)
{
*pSPORT0_TX32 = *pSPORT0_RX32;
}
void main()
{
Set_PLL( (short)(CORECLK/CLKIN), (short)(CORECLK/SYSCLK));
Init_Sports();
// Init_Interrupts();
register_handler(ik_ivg9, SPORTS0_RX);
if(!Init_AIC23B_I2C())
{
while(1);
}
*pSICB_IMASK0 = 0x00800000;//0x00000810;
*pSICB_IMASK1 = 0x00000000;
while(1);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -