35 uint32_t u32Freq, u32ClkSrcSel;
99uint32_t
I2S_Open(
I2S_T *i2s, uint32_t u32MasterSlave, uint32_t u32SampleRate, uint32_t u32WordWidth, uint32_t u32Channels, uint32_t u32DataFormat, uint32_t u32AudioInterface)
102 uint32_t u32BitRate, u32SrcClk;
107 SYS->IPRST1 &= ~SYS_IPRST1_I2S0RST_Msk;
112 SYS->IPRST1 &= ~SYS_IPRST1_I2S1RST_Msk;
119 u32BitRate = u32SampleRate * (((u32WordWidth>>4) & 0x3) + 1) * 16;
120 u16Divider = ((u32SrcClk/u32BitRate) >> 1) - 1;
121 i2s->
CLKDIV = (i2s->
CLKDIV & ~I2S_CLKDIV_BCLKDIV_Msk) | (u16Divider << 8);
124 u32BitRate = u32SrcClk / (2*(u16Divider+1));
125 u32SampleRate = u32BitRate / ((((u32WordWidth>>4) & 0x3) + 1) * 16);
129 return u32SampleRate;
139 i2s->
CTL &= ~I2S_CTL_I2SEN_Msk;
163 i2s->
IEN &= ~u32Mask;
175 uint32_t u32SrcClk, u32Reg;
178 if (u32BusClock == u32SrcClk)
181 u8Divider = (u32SrcClk/u32BusClock) >> 1;
183 i2s->
CLKDIV = (i2s->
CLKDIV & ~I2S_CLKDIV_MCLKDIV_Msk) | u8Divider;
192 return ((u32SrcClk >> 1) / u32Reg);
202 i2s->
CTL &= ~I2S_CTL_MCLKEN_Msk;
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
#define I2S_CTL_I2SEN_Msk
#define SYS_IPRST1_I2S1RST_Msk
#define CLK_CLKSEL3_I2S0SEL_Msk
#define SYS_IPRST1_I2S0RST_Msk
#define I2S_CLKDIV_MCLKDIV_Msk
#define CLK_CLKSEL3_I2S1SEL_Msk
#define I2S_CTL_MCLKEN_Msk
#define CLK_CLKSEL3_I2S1SEL_HIRC
#define CLK_CLKSEL3_I2S0SEL_HXT
#define CLK_CLKSEL3_I2S0SEL_PCLK
#define CLK_CLKSEL3_I2S0SEL_HIRC
#define CLK_CLKSEL3_I2S1SEL_PCLK
#define CLK_CLKSEL3_I2S1SEL_PLL
#define CLK_CLKSEL3_I2S0SEL_PLL
uint32_t CLK_GetPLLClockFreq(void)
This function get PLL frequency. The frequency unit is Hz.
#define I2S_FIFO_TX_LEVEL_WORD_4
#define I2S_FIFO_RX_LEVEL_WORD_4
void I2S_SetFIFO(I2S_T *i2s, uint32_t u32TxThreshold, uint32_t u32RxThreshold)
Configure FIFO threshold setting.
uint32_t I2S_Open(I2S_T *i2s, uint32_t u32MasterSlave, uint32_t u32SampleRate, uint32_t u32WordWidth, uint32_t u32Channels, uint32_t u32DataFormat, uint32_t u32AudioInterface)
This function configures some parameters of I2S interface for general purpose use....
static uint32_t I2S_GetSourceClockFreq(I2S_T *i2s)
This function is used to get I2S source clock frequency.
void I2S_DisableInt(I2S_T *i2s, uint32_t u32Mask)
This function disables the interrupt according to the mask parameter.
void I2S_DisableMCLK(I2S_T *i2s)
Disable MCLK .
uint32_t I2S_EnableMCLK(I2S_T *i2s, uint32_t u32BusClock)
Enable MCLK .
void I2S_EnableInt(I2S_T *i2s, uint32_t u32Mask)
This function enables the interrupt according to the mask parameter.
void I2S_Close(I2S_T *i2s)
Disable I2S function and I2S clock.