| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

Macros | Functions
I2S Exported Functions
NUC472/NUC442 Device Driver » I2S Driver » I2S Exported Constants
Collaboration diagram for I2S Exported Functions:

## Macros
#define | I2S_ENABLE_TXDMA(i2s)
| Enable I2S Tx DMA function. I2S requests DMA to transfer data to Tx FIFO. More...
#define | I2S_DISABLE_TXDMA(i2s)
| Disable I2S Tx DMA function. I2S requests DMA to transfer data to Tx FIFO. More...
#define | I2S_ENABLE_RXDMA(i2s)
| Enable I2S Rx DMA function. I2S requests DMA to transfer data from Rx FIFO. More...
#define | I2S_DISABLE_RXDMA(i2s)
| Disable I2S Rx DMA function. I2S requests DMA to transfer data from Rx FIFO. More...
#define | I2S_ENABLE_TX(i2s)
| Enable I2S Tx function . More...
#define | I2S_DISABLE_TX(i2s)
| Disable I2S Tx function . More...
#define | I2S_ENABLE_RX(i2s)
| Enable I2S Rx function . More...
#define | I2S_DISABLE_RX(i2s)
| Disable I2S Rx function . More...
#define | I2S_ENABLE_TX_MUTE(i2s)
| Enable Tx Mute function . More...
#define | I2S_DISABLE_TX_MUTE(i2s)
| Disable Tx Mute function . More...
#define | I2S_CLR_TX_FIFO(i2s)
| Clear Tx FIFO. Internal pointer is reset to FIFO start point. More...
#define | I2S_CLR_RX_FIFO(i2s)
| Clear Rx FIFO. Internal pointer is reset to FIFO start point. More...
#define | I2S_WRITE_TX_FIFO(i2s, u32Data)
| Write data to I2S Tx FIFO. More...
#define | I2S_READ_RX_FIFO(i2s)
| Read Rx FIFO. More...
#define | I2S_GET_INT_FLAG(i2s, u32Mask)
| This function gets the interrupt flag according to the mask parameter. More...
#define | I2S_CLR_INT_FLAG(i2s, u32Mask)
| This function clears the interrupt flag according to the mask parameter. More...
#define | I2S_GET_TX_FIFO_LEVEL(i2s)
| Get transmit FIFO level. More...
#define | I2S_GET_RX_FIFO_LEVEL(i2s)
| Get receive FIFO level. More...

## Functions
static __INLINE void | I2S_ENABLE_TX_ZCD (I2S_T *i2s, uint32_t u32ChMask)
| Enable zero cross detect function. More...
static __INLINE void | I2S_DISABLE_TX_ZCD (I2S_T *i2s, uint32_t u32ChMask)
| Disable zero cross detect function. More...
static __INLINE void | I2S_SET_MONO_RX_CHANNEL (I2S_T *i2s, uint32_t u32Ch)
| This function sets the recording source channel when mono mode is used. More...
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. The sample rate may not be used from the parameter, it depends on system's clock settings, but real sample rate used by system will be returned for reference. More...
void | I2S_Close (I2S_T *i2s)
| Disable I2S function and I2S clock. More...
void | I2S_EnableInt (I2S_T *i2s, uint32_t u32Mask)
| This function enables the interrupt according to the mask parameter. More...
void | I2S_DisableInt (I2S_T *i2s, uint32_t u32Mask)
| This function disables the interrupt according to the mask parameter. More...
uint32_t | I2S_EnableMCLK (I2S_T *i2s, uint32_t u32BusClock)
| Enable MCLK . More...
void | I2S_DisableMCLK (I2S_T *i2s)
| Disable MCLK . More...
void | I2S_SetFIFO (I2S_T *i2s, uint32_t u32TxThreshold, uint32_t u32RxThreshold)
| Configure FIFO threshold setting. More...
static uint32_t | I2S_GetSourceClockFreq (I2S_T *i2s)
| This function is used to get I2S source clock frequency. More...

## Detailed Description

## Macro Definition Documentation

## ◆ I2S_CLR_INT_FLAG

#define I2S_CLR_INT_FLAG | ( |  | i2s,
|  |  | u32Mask
| ) |  |

This function clears the interrupt flag according to the mask parameter.

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32Mask | is the mask for the all interrupt flags.

Returns
  none

Definition at line 270 of file i2s.h.

## ◆ I2S_CLR_RX_FIFO

#define I2S_CLR_RX_FIFO | ( |  | i2s | ) |

Clear Rx FIFO. Internal pointer is reset to FIFO start point.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 219 of file i2s.h.

## ◆ I2S_CLR_TX_FIFO

#define I2S_CLR_TX_FIFO | ( |  | i2s | ) |

Clear Tx FIFO. Internal pointer is reset to FIFO start point.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 211 of file i2s.h.

## ◆ I2S_DISABLE_RX

#define I2S_DISABLE_RX | ( |  | i2s | ) |

Disable I2S Rx function .

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 187 of file i2s.h.

## ◆ I2S_DISABLE_RXDMA

#define I2S_DISABLE_RXDMA | ( |  | i2s | ) |

Disable I2S Rx DMA function. I2S requests DMA to transfer data from Rx FIFO.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 155 of file i2s.h.

## ◆ I2S_DISABLE_TX

#define I2S_DISABLE_TX | ( |  | i2s | ) |

Disable I2S Tx function .

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 171 of file i2s.h.

## ◆ I2S_DISABLE_TX_MUTE

#define I2S_DISABLE_TX_MUTE | ( |  | i2s | ) |

Disable Tx Mute function .

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 203 of file i2s.h.

## ◆ I2S_DISABLE_TXDMA

#define I2S_DISABLE_TXDMA | ( |  | i2s | ) |

Disable I2S Tx DMA function. I2S requests DMA to transfer data to Tx FIFO.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 139 of file i2s.h.

## ◆ I2S_ENABLE_RX

#define I2S_ENABLE_RX | ( |  | i2s | ) |

Enable I2S Rx function .

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 179 of file i2s.h.

## ◆ I2S_ENABLE_RXDMA

#define I2S_ENABLE_RXDMA | ( |  | i2s | ) |

Enable I2S Rx DMA function. I2S requests DMA to transfer data from Rx FIFO.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 147 of file i2s.h.

## ◆ I2S_ENABLE_TX

#define I2S_ENABLE_TX | ( |  | i2s | ) |

Enable I2S Tx function .

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 163 of file i2s.h.

## ◆ I2S_ENABLE_TX_MUTE

#define I2S_ENABLE_TX_MUTE | ( |  | i2s | ) |

Enable Tx Mute function .

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 195 of file i2s.h.

## ◆ I2S_ENABLE_TXDMA

#define I2S_ENABLE_TXDMA | ( |  | i2s | ) |

Enable I2S Tx DMA function. I2S requests DMA to transfer data to Tx FIFO.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 131 of file i2s.h.

## ◆ I2S_GET_INT_FLAG

#define I2S_GET_INT_FLAG | ( |  | i2s,
|  |  | u32Mask
| ) |  |

This function gets the interrupt flag according to the mask parameter.

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32Mask | is the mask for the all interrupt flags.

Returns
  The masked bit value of interrupt flag.

Definition at line 261 of file i2s.h.

## ◆ I2S_GET_RX_FIFO_LEVEL

#define I2S_GET_RX_FIFO_LEVEL | ( |  | i2s | ) |

Get receive FIFO level.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  FIFO level

Definition at line 286 of file i2s.h.

## ◆ I2S_GET_TX_FIFO_LEVEL

#define I2S_GET_TX_FIFO_LEVEL | ( |  | i2s | ) |

Get transmit FIFO level.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  FIFO level

Definition at line 278 of file i2s.h.

## ◆ I2S_READ_RX_FIFO

#define I2S_READ_RX_FIFO | ( |  | i2s | ) |

Read Rx FIFO.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  Data in Rx FIFO.

Definition at line 252 of file i2s.h.

## ◆ I2S_WRITE_TX_FIFO

#define I2S_WRITE_TX_FIFO | ( |  | i2s,
|  |  | u32Data
| ) |  |

Write data to I2S Tx FIFO.

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32Data | The data written to FIFO.

Returns
  none

Definition at line 244 of file i2s.h.

## Function Documentation

## ◆ I2S_Close()

void I2S_Close | ( | I2S_T * | i2s | ) |

Disable I2S function and I2S clock.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 137 of file i2s.c.

## ◆ I2S_DISABLE_TX_ZCD()

static __INLINE void I2S_DISABLE_TX_ZCD | ( | I2S_T * | i2s,
|  | uint32_t | u32ChMask
| ) |  |
| static

Disable zero cross detect function.

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32ChMask | is the mask for left or right channel. Valid values are: I2S_RIGHT I2S_LEFT

Returns
  none

Definition at line 117 of file i2s.h.

## ◆ I2S_DisableInt()

void I2S_DisableInt | ( | I2S_T * | i2s,
|  | uint32_t | u32Mask
| ) |  |

This function disables the interrupt according to the mask parameter.

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32Mask | is the combination of all related interrupt enable bits. Each bit corresponds to a interrupt bit.

Returns
  none

Definition at line 161 of file i2s.c.

## ◆ I2S_DisableMCLK()

void I2S_DisableMCLK | ( | I2S_T * | i2s | ) |

Disable MCLK .

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  none

Definition at line 200 of file i2s.c.

## ◆ I2S_ENABLE_TX_ZCD()

static __INLINE void I2S_ENABLE_TX_ZCD | ( | I2S_T * | i2s,
|  | uint32_t | u32ChMask
| ) |  |
| static

Enable zero cross detect function.

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32ChMask | is the mask for left or right channel. Valid values are: I2S_RIGHT I2S_LEFT

Returns
  none

Definition at line 100 of file i2s.h.

## ◆ I2S_EnableInt()

void I2S_EnableInt | ( | I2S_T * | i2s,
|  | uint32_t | u32Mask
| ) |  |

This function enables the interrupt according to the mask parameter.

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32Mask | is the combination of all related interrupt enable bits. Each bit corresponds to a interrupt bit.

Returns
  none

Definition at line 149 of file i2s.c.

## ◆ I2S_EnableMCLK()

uint32_t I2S_EnableMCLK | ( | I2S_T * | i2s,
|  | uint32_t | u32BusClock
| ) |  |

Enable MCLK .

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32BusClock | is the target MCLK clock

Returns
  Actual MCLK clock

Definition at line 172 of file i2s.c.

Here is the call graph for this function:

## ◆ I2S_GetSourceClockFreq()

static uint32_t I2S_GetSourceClockFreq | ( | I2S_T * | i2s | ) |
| static

This function is used to get I2S source clock frequency.

Parameters

  [in] | i2s | is the base address of I2S module.

Returns
  I2S source clock frequency (Hz).

Definition at line 33 of file i2s.c.

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ I2S_Open()

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. The sample rate may not be used from the parameter, it depends on system's clock settings, but real sample rate used by system will be returned for reference.

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32MasterSlave | I2S operation mode. Valid values are: I2S_MODE_MASTER I2S_MODE_SLAVE
  [in] | u32SampleRate | Sample rate
  [in] | u32WordWidth | Data length. Valid values are: I2S_DATABIT_8 I2S_DATABIT_16 I2S_DATABIT_24 I2S_DATABIT_32
  [in] | u32Channels | Audio format. Valid values are: I2S_MONO I2S_STEREO
  [in] | u32DataFormat | Data format. Valid values are: I2S_FORMAT_I2S I2S_FORMAT_MSB I2S_FORMAT_PCMA I2S_FORMAT_PCMB
  [in] | u32AudioInterface | Audio interface. Valid values are: I2S_I2S I2S_PCM

Returns
  Real sample rate.

Definition at line 99 of file i2s.c.

Here is the call graph for this function:

## ◆ I2S_SET_MONO_RX_CHANNEL()

static __INLINE void I2S_SET_MONO_RX_CHANNEL | ( | I2S_T * | i2s,
|  | uint32_t | u32Ch
| ) |  |
| static

This function sets the recording source channel when mono mode is used.

Parameters

  [in] | i2s | is the base address of I2S module.
  [in] | u32Ch | left or right channel. Valid values are: I2S_MONO_LEFT I2S_MONO_RIGHT

Returns
  none

Definition at line 230 of file i2s.h.

## ◆ I2S_SetFIFO()

void I2S_SetFIFO | ( | I2S_T * | i2s,
|  | uint32_t | u32TxThreshold,
|  | uint32_t | u32RxThreshold
| ) |  |

Configure FIFO threshold setting.

Parameters

  [in] | i2s | The pointer of the specified I2S module.
  [in] | u32TxThreshold | Decides the TX FIFO threshold. It could be 0 ~ 7.
  [in] | u32RxThreshold | Decides the RX FIFO threshold. It could be 0 ~ 7.

Returns
  None

Set TX FIFO threshold and RX FIFO threshold configurations.

Definition at line 213 of file i2s.c.