35 uint32_t u32Freq, u32ClkSrcSel;
86 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)
89 uint32_t u32BitRate, u32SrcClk;
98 u32BitRate = u32SampleRate * (((u32WordWidth>>4) & 0x3) + 1) * 16;
99 u8Divider = ((u32SrcClk/u32BitRate) >> 1) - 1;
103 u32BitRate = u32SrcClk / (2*(u8Divider+1));
104 u32SampleRate = u32BitRate / ((((u32WordWidth>>4) & 0x3) + 1) * 16);
108 return u32SampleRate;
130 i2s->
INTEN |= u32Mask;
142 i2s->
INTEN &= ~u32Mask;
154 uint32_t u32SrcClk, u32Reg;
157 if (u32BusClock == u32SrcClk)
160 u8Divider = (u32SrcClk/u32BusClock) >> 1;
171 return ((u32SrcClk >> 1) / u32Reg);
#define CLK
Pointer to CLK register structure.
#define I2S_CTRL_MCLKEN_Msk
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.
#define CLK_CLKSEL2_I2S_S_HIRC
Nano100 series peripheral access layer header file. This file contains all the peripheral register's ...
#define CLK_CLKSEL2_I2S_S_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_CTRL_I2SEN_Msk
#define CLK_CLKSEL2_I2S_S_Msk
void I2S_EnableInt(I2S_T *i2s, uint32_t u32Mask)
This function enables the interrupt according to the mask parameter.
#define CLK_CLKSEL2_I2S_S_HXT
#define I2S_CLKDIV_MCLK_DIV_Msk
void I2S_Close(I2S_T *i2s)
Disable I2S function and I2S clock.
#define I2S_FIFO_RX_LEVEL_WORD_4
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 .
#define SYS_IPRST_CTL2_I2S_RST_Msk
#define I2S_CLKDIV_BCLK_DIV_Msk
uint32_t I2S_EnableMCLK(I2S_T *i2s, uint32_t u32BusClock)
Enable MCLK .
#define SYS
Pointer to SYS register structure.