34 uint32_t u32Freq, u32ClkSrcSel;
91 uint32_t
I2S_Open(
I2S_T *i2s, uint32_t u32MasterSlave, uint32_t u32SampleRate, uint32_t u32WordWidth, uint32_t u32MonoData, uint32_t u32DataFormat)
94 uint32_t u32BitRate, u32SrcClk;
99 i2s->
CTL0 = u32MasterSlave | u32WordWidth | u32MonoData | u32DataFormat;
104 u32BitRate = u32SampleRate * (((u32WordWidth>>4U) & 0x3U) + 1U) * 16U;
106 u16Divider = (uint16_t)((((u32SrcClk * 10UL / u32BitRate) >> 1U) + 5UL) / 10UL) - 1U;
110 u32BitRate = u32SrcClk / (2U*((uint32_t)u16Divider+1U));
111 u32SampleRate = u32BitRate / ((((u32WordWidth>>4U) & 0x3U) + 1U) * 16U);
115 return u32SampleRate;
149 i2s->
IEN &= ~u32Mask;
161 uint32_t u32SrcClk, u32Reg, u32Clock;
164 if (u32BusClock == u32SrcClk)
170 u8Divider = (uint8_t)(u32SrcClk/u32BusClock) >> 1U;
181 u32Clock = u32SrcClk;
185 u32Clock = ((u32SrcClk >> 1U) / u32Reg);
#define I2S_CLKDIV_BCLKDIV_Msk
#define CLK_CLKSEL3_I2S0SEL_PCLK0
#define I2S_FIFO_RX_LEVEL_WORD_8
#define CLK_CLKSEL3_I2S0SEL_HIRC
#define I2S_CTL0_CHWIDTH_Pos
void I2S_EnableInt(I2S_T *i2s, uint32_t u32Mask)
This function enables the interrupt according to the mask parameter.
void I2S_DisableInt(I2S_T *i2s, uint32_t u32Mask)
This function disables the interrupt according to the mask parameter.
uint32_t I2S_EnableMCLK(I2S_T *i2s, uint32_t u32BusClock)
Enable MCLK .
NuMicro peripheral access layer header file.
#define I2S_CTL1_RXTH_Msk
#define CLK_CLKSEL3_I2S0SEL_HXT
#define SYS_IPRST1_I2S0RST_Msk
#define I2S_CTL0_PCMSYNC_Pos
#define I2S_CLKDIV_MCLKDIV_Msk
uint32_t CLK_GetPCLK0Freq(void)
Get PCLK0 frequency.
#define I2S_FIFO_TX_LEVEL_WORD_8
uint32_t CLK_GetPLLClockFreq(void)
Get PLL clock frequency.
#define I2S_CTL0_TDMCHNUM_Pos
#define I2S_CTL0_MCLKEN_Msk
#define I2S_CTL0_I2SEN_Msk
#define I2S_CTL1_TXTH_Msk
#define I2S_CTL1_TXTH_Pos
void I2S_ConfigureTDM(I2S_T *i2s, uint32_t u32ChannelWidth, uint32_t u32ChannelNum, uint32_t u32SyncWidth)
Configure PCM(TDM) function parameters, such as channel width, channel number and sync pulse width.
uint32_t I2S_Open(I2S_T *i2s, uint32_t u32MasterSlave, uint32_t u32SampleRate, uint32_t u32WordWidth, uint32_t u32MonoData, uint32_t u32DataFormat)
This function configures some parameters of I2S interface for general purpose use....
#define CLK_CLKSEL3_I2S0SEL_Msk
#define I2S_CTL1_RXTH_Pos
void I2S_Close(I2S_T *i2s)
Disable I2S function and I2S clock.
void I2S_DisableMCLK(I2S_T *i2s)
Disable MCLK .
#define CLK_CLKSEL3_I2S0SEL_PLL
#define I2S_CTL0_CHWIDTH_Msk
void I2S_SetFIFO(I2S_T *i2s, uint32_t u32TxThreshold, uint32_t u32RxThreshold)
Configure FIFO threshold setting.
static uint32_t I2S_GetSourceClockFreq(I2S_T *i2s)
This function is used to get I2S source clock frequency.
#define I2S_CTL0_PCMSYNC_Msk
#define I2S_CTL0_TDMCHNUM_Msk