M480 BSP V3.05.006
The Board Support Package for M480 Series
Macros | Functions

Macros

#define SPI_CLR_UNIT_TRANS_INT_FLAG(spi)
 Clear the unit transfer interrupt flag. More...
 
#define SPI_TRIGGER_RX_PDMA(spi)
 Trigger RX PDMA function. More...
 
#define SPI_TRIGGER_TX_PDMA(spi)
 Trigger TX PDMA function. More...
 
#define SPI_TRIGGER_TX_RX_PDMA(spi)
 Trigger TX and RX PDMA function. More...
 
#define SPI_DISABLE_RX_PDMA(spi)
 Disable RX PDMA transfer. More...
 
#define SPI_DISABLE_TX_PDMA(spi)
 Disable TX PDMA transfer. More...
 
#define SPI_DISABLE_TX_RX_PDMA(spi)
 Disable TX and RX PDMA transfer. More...
 
#define SPI_GET_RX_FIFO_COUNT(spi)
 Get the count of available data in RX FIFO. More...
 
#define SPI_GET_RX_FIFO_EMPTY_FLAG(spi)
 Get the RX FIFO empty flag. More...
 
#define SPI_GET_TX_FIFO_EMPTY_FLAG(spi)
 Get the TX FIFO empty flag. More...
 
#define SPI_GET_TX_FIFO_FULL_FLAG(spi)
 Get the TX FIFO full flag. More...
 
#define SPI_READ_RX(spi)
 Get the datum read from RX register. More...
 
#define SPI_WRITE_TX(spi, u32TxData)
 Write datum to TX register. More...
 
#define SPI_SET_SS_HIGH(spi)
 Set SPIx_SS pin to high state. More...
 
#define SPI_SET_SS_LOW(spi)
 Set SPIx_SS pin to low state. More...
 
#define SPI_ENABLE_BYTE_REORDER(spi)
 Enable Byte Reorder function. More...
 
#define SPI_DISABLE_BYTE_REORDER(spi)
 Disable Byte Reorder function. More...
 
#define SPI_SET_SUSPEND_CYCLE(spi, u32SuspCycle)
 Set the length of suspend interval. More...
 
#define SPI_SET_LSB_FIRST(spi)
 Set the SPI transfer sequence with LSB first. More...
 
#define SPI_SET_MSB_FIRST(spi)
 Set the SPI transfer sequence with MSB first. More...
 
#define SPI_SET_DATA_WIDTH(spi, u32Width)
 Set the data width of a SPI transaction. More...
 
#define SPI_IS_BUSY(spi)
 Get the SPI busy state. More...
 
#define SPI_ENABLE(spi)
 Enable SPI controller. More...
 
#define SPI_DISABLE(spi)
 Disable SPI controller. More...
 
#define SPII2S_ENABLE_TXDMA(i2s)
 Enable I2S TX DMA function. More...
 
#define SPII2S_DISABLE_TXDMA(i2s)
 Disable I2S TX DMA function. More...
 
#define SPII2S_ENABLE_RXDMA(i2s)
 Enable I2S RX DMA function. More...
 
#define SPII2S_DISABLE_RXDMA(i2s)
 Disable I2S RX DMA function. More...
 
#define SPII2S_ENABLE_TX(i2s)
 Enable I2S TX function. More...
 
#define SPII2S_DISABLE_TX(i2s)
 Disable I2S TX function. More...
 
#define SPII2S_ENABLE_RX(i2s)
 Enable I2S RX function. More...
 
#define SPII2S_DISABLE_RX(i2s)
 Disable I2S RX function. More...
 
#define SPII2S_ENABLE_TX_MUTE(i2s)
 Enable TX Mute function. More...
 
#define SPII2S_DISABLE_TX_MUTE(i2s)
 Disable TX Mute function. More...
 
#define SPII2S_CLR_TX_FIFO(i2s)
 Clear TX FIFO. More...
 
#define SPII2S_CLR_RX_FIFO(i2s)
 Clear RX FIFO. More...
 
#define SPII2S_WRITE_TX_FIFO(i2s, u32Data)
 Write data to I2S TX FIFO. More...
 
#define SPII2S_READ_RX_FIFO(i2s)
 Read RX FIFO. More...
 
#define SPII2S_GET_INT_FLAG(i2s, u32Mask)
 Get the interrupt flag. More...
 
#define SPII2S_CLR_INT_FLAG(i2s, u32Mask)
 Clear the interrupt flag. More...
 
#define SPII2S_GET_TX_FIFO_LEVEL(i2s)
 Get transmit FIFO level. More...
 
#define SPII2S_GET_RX_FIFO_LEVEL(i2s)
 Get receive FIFO level. More...
 

Functions

__STATIC_INLINE void SPII2S_ENABLE_TX_ZCD (SPI_T *i2s, uint32_t u32ChMask)
 Enable zero cross detection function. More...
 
__STATIC_INLINE void SPII2S_DISABLE_TX_ZCD (SPI_T *i2s, uint32_t u32ChMask)
 Disable zero cross detection function. More...
 
__STATIC_INLINE void SPII2S_SET_MONO_RX_CHANNEL (SPI_T *i2s, uint32_t u32Ch)
 This function sets the recording source channel when mono mode is used. More...
 
uint32_t SPI_Open (SPI_T *spi, uint32_t u32MasterSlave, uint32_t u32SPIMode, uint32_t u32DataWidth, uint32_t u32BusClock)
 This function make SPI module be ready to transfer. More...
 
void SPI_Close (SPI_T *spi)
 Disable SPI controller. More...
 
void SPI_ClearRxFIFO (SPI_T *spi)
 Clear RX FIFO buffer. More...
 
void SPI_ClearTxFIFO (SPI_T *spi)
 Clear TX FIFO buffer. More...
 
void SPI_DisableAutoSS (SPI_T *spi)
 Disable the automatic slave selection function. More...
 
void SPI_EnableAutoSS (SPI_T *spi, uint32_t u32SSPinMask, uint32_t u32ActiveLevel)
 Enable the automatic slave selection function. More...
 
uint32_t SPI_SetBusClock (SPI_T *spi, uint32_t u32BusClock)
 Set the SPI bus clock. More...
 
void SPI_SetFIFO (SPI_T *spi, uint32_t u32TxThreshold, uint32_t u32RxThreshold)
 Configure FIFO threshold setting. More...
 
uint32_t SPI_GetBusClock (SPI_T *spi)
 Get the actual frequency of SPI bus clock. Only available in Master mode. More...
 
void SPI_EnableInt (SPI_T *spi, uint32_t u32Mask)
 Enable interrupt function. More...
 
void SPI_DisableInt (SPI_T *spi, uint32_t u32Mask)
 Disable interrupt function. More...
 
uint32_t SPI_GetIntFlag (SPI_T *spi, uint32_t u32Mask)
 Get interrupt flag. More...
 
void SPI_ClearIntFlag (SPI_T *spi, uint32_t u32Mask)
 Clear interrupt flag. More...
 
uint32_t SPI_GetStatus (SPI_T *spi, uint32_t u32Mask)
 Get SPI status. More...
 
uint32_t SPII2S_Open (SPI_T *i2s, uint32_t u32MasterSlave, uint32_t u32SampleRate, uint32_t u32WordWidth, uint32_t u32Channels, uint32_t u32DataFormat)
 This function configures some parameters of I2S interface for general purpose use. More...
 
void SPII2S_Close (SPI_T *i2s)
 Disable I2S function. More...
 
void SPII2S_EnableInt (SPI_T *i2s, uint32_t u32Mask)
 Enable interrupt function. More...
 
void SPII2S_DisableInt (SPI_T *i2s, uint32_t u32Mask)
 Disable interrupt function. More...
 
uint32_t SPII2S_EnableMCLK (SPI_T *i2s, uint32_t u32BusClock)
 Enable master clock (MCLK). More...
 
void SPII2S_DisableMCLK (SPI_T *i2s)
 Disable master clock (MCLK). More...
 
void SPII2S_SetFIFO (SPI_T *i2s, uint32_t u32TxThreshold, uint32_t u32RxThreshold)
 Configure FIFO threshold setting. More...
 
static uint32_t SPII2S_GetSourceClockFreq (SPI_T *i2s)
 This function is used to get I2S source clock frequency. More...
 

Detailed Description

Macro Definition Documentation

◆ SPI_CLR_UNIT_TRANS_INT_FLAG

#define SPI_CLR_UNIT_TRANS_INT_FLAG (   spi)

Clear the unit transfer interrupt flag.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Write 1 to UNITIF bit of SPI_STATUS register to clear the unit transfer interrupt flag.

Definition at line 116 of file spi.h.

◆ SPI_DISABLE

#define SPI_DISABLE (   spi)

Disable SPI controller.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Clear SPIEN (SPI_CTL[0]) to disable SPI controller.

Definition at line 331 of file spi.h.

◆ SPI_DISABLE_BYTE_REORDER

#define SPI_DISABLE_BYTE_REORDER (   spi)

Disable Byte Reorder function.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Clear REORDER bit field of SPI_CTL register to disable Byte Reorder function.

Definition at line 264 of file spi.h.

◆ SPI_DISABLE_RX_PDMA

#define SPI_DISABLE_RX_PDMA (   spi)

Disable RX PDMA transfer.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Clear RXPDMAEN bit of SPI_PDMACTL register to disable RX PDMA transfer function.

Definition at line 152 of file spi.h.

◆ SPI_DISABLE_TX_PDMA

#define SPI_DISABLE_TX_PDMA (   spi)

Disable TX PDMA transfer.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Clear TXPDMAEN bit of SPI_PDMACTL register to disable TX PDMA transfer function.

Definition at line 161 of file spi.h.

◆ SPI_DISABLE_TX_RX_PDMA

#define SPI_DISABLE_TX_RX_PDMA (   spi)

Disable TX and RX PDMA transfer.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Clear TXPDMAEN bit and RXPDMAEN bit of SPI_PDMACTL register to disable TX and RX PDMA transfer function.

Definition at line 170 of file spi.h.

◆ SPI_ENABLE

#define SPI_ENABLE (   spi)

Enable SPI controller.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Set SPIEN (SPI_CTL[0]) to enable SPI controller.

Definition at line 322 of file spi.h.

◆ SPI_ENABLE_BYTE_REORDER

#define SPI_ENABLE_BYTE_REORDER (   spi)

Enable Byte Reorder function.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Enable Byte Reorder function. The suspend interval depends on the setting of SUSPITV (SPI_CTL[7:4]).

Definition at line 255 of file spi.h.

◆ SPI_GET_RX_FIFO_COUNT

#define SPI_GET_RX_FIFO_COUNT (   spi)

Get the count of available data in RX FIFO.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
The count of available data in RX FIFO.

Read RXCNT (SPI_STATUS[27:24]) to get the count of available data in RX FIFO.

Definition at line 179 of file spi.h.

◆ SPI_GET_RX_FIFO_EMPTY_FLAG

#define SPI_GET_RX_FIFO_EMPTY_FLAG (   spi)

Get the RX FIFO empty flag.

Parameters
[in]spiThe pointer of the specified SPI module.
Return values
0RX FIFO is not empty.
1RX FIFO is empty.

Read RXEMPTY bit of SPI_STATUS register to get the RX FIFO empty flag.

Definition at line 189 of file spi.h.

◆ SPI_GET_TX_FIFO_EMPTY_FLAG

#define SPI_GET_TX_FIFO_EMPTY_FLAG (   spi)

Get the TX FIFO empty flag.

Parameters
[in]spiThe pointer of the specified SPI module.
Return values
0TX FIFO is not empty.
1TX FIFO is empty.

Read TXEMPTY bit of SPI_STATUS register to get the TX FIFO empty flag.

Definition at line 199 of file spi.h.

◆ SPI_GET_TX_FIFO_FULL_FLAG

#define SPI_GET_TX_FIFO_FULL_FLAG (   spi)

Get the TX FIFO full flag.

Parameters
[in]spiThe pointer of the specified SPI module.
Return values
0TX FIFO is not full.
1TX FIFO is full.

Read TXFULL bit of SPI_STATUS register to get the TX FIFO full flag.

Definition at line 209 of file spi.h.

◆ SPI_IS_BUSY

#define SPI_IS_BUSY (   spi)

Get the SPI busy state.

Parameters
[in]spiThe pointer of the specified SPI module.
Return values
0SPI controller is not busy.
1SPI controller is busy.

This macro will return the busy state of SPI controller.

Definition at line 313 of file spi.h.

◆ SPI_READ_RX

#define SPI_READ_RX (   spi)

Get the datum read from RX register.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
Data in RX register.

Read SPI_RX register to get the received datum.

Definition at line 218 of file spi.h.

◆ SPI_SET_DATA_WIDTH

#define SPI_SET_DATA_WIDTH (   spi,
  u32Width 
)

Set the data width of a SPI transaction.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32WidthThe bit width of one transaction.
Returns
None.

The data width can be 8 ~ 32 bits.

Definition at line 303 of file spi.h.

◆ SPI_SET_LSB_FIRST

#define SPI_SET_LSB_FIRST (   spi)

Set the SPI transfer sequence with LSB first.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Set LSB bit of SPI_CTL register to set the SPI transfer sequence with LSB first.

Definition at line 284 of file spi.h.

◆ SPI_SET_MSB_FIRST

#define SPI_SET_MSB_FIRST (   spi)

Set the SPI transfer sequence with MSB first.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Clear LSB bit of SPI_CTL register to set the SPI transfer sequence with MSB first.

Definition at line 293 of file spi.h.

◆ SPI_SET_SS_HIGH

#define SPI_SET_SS_HIGH (   spi)

Set SPIx_SS pin to high state.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Disable automatic slave selection function and set SPIx_SS pin to high state.

Definition at line 237 of file spi.h.

◆ SPI_SET_SS_LOW

#define SPI_SET_SS_LOW (   spi)

Set SPIx_SS pin to low state.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Disable automatic slave selection function and set SPIx_SS pin to low state.

Definition at line 246 of file spi.h.

◆ SPI_SET_SUSPEND_CYCLE

#define SPI_SET_SUSPEND_CYCLE (   spi,
  u32SuspCycle 
)

Set the length of suspend interval.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32SuspCycleDecides the length of suspend interval. It could be 0 ~ 15.
Returns
None.

Set the length of suspend interval according to u32SuspCycle. The length of suspend interval is ((u32SuspCycle + 0.5) * the length of one SPI bus clock cycle).

Definition at line 275 of file spi.h.

◆ SPI_TRIGGER_RX_PDMA

#define SPI_TRIGGER_RX_PDMA (   spi)

Trigger RX PDMA function.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Set RXPDMAEN bit of SPI_PDMACTL register to enable RX PDMA transfer function.

Definition at line 125 of file spi.h.

◆ SPI_TRIGGER_TX_PDMA

#define SPI_TRIGGER_TX_PDMA (   spi)

Trigger TX PDMA function.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Set TXPDMAEN bit of SPI_PDMACTL register to enable TX PDMA transfer function.

Definition at line 134 of file spi.h.

◆ SPI_TRIGGER_TX_RX_PDMA

#define SPI_TRIGGER_TX_RX_PDMA (   spi)

Trigger TX and RX PDMA function.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None.

Set TXPDMAEN bit and RXPDMAEN bit of SPI_PDMACTL register to enable TX and RX PDMA transfer function.

Definition at line 143 of file spi.h.

◆ SPI_WRITE_TX

#define SPI_WRITE_TX (   spi,
  u32TxData 
)

Write datum to TX register.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32TxDataThe datum which user attempt to transfer through SPI bus.
Returns
None.

Write u32TxData to SPI_TX register.

Definition at line 228 of file spi.h.

◆ SPII2S_CLR_INT_FLAG

#define SPII2S_CLR_INT_FLAG (   i2s,
  u32Mask 
)

Clear the interrupt flag.

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32MaskThe mask value for all interrupt flags.
Returns
None

This macro will clear the interrupt flags specified by the u32mask parameter.

Note
Except TX and RX FIFO threshold interrupt flags, the other interrupt flags can be cleared by writing 1 to itself.

Definition at line 543 of file spi.h.

◆ SPII2S_CLR_RX_FIFO

#define SPII2S_CLR_RX_FIFO (   i2s)

Clear RX FIFO.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will clear RX FIFO. The internal RX FIFO pointer will be reset to FIFO start point.

Definition at line 486 of file spi.h.

◆ SPII2S_CLR_TX_FIFO

#define SPII2S_CLR_TX_FIFO (   i2s)

Clear TX FIFO.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will clear TX FIFO. The internal TX FIFO pointer will be reset to FIFO start point.

Definition at line 477 of file spi.h.

◆ SPII2S_DISABLE_RX

#define SPII2S_DISABLE_RX (   i2s)

Disable I2S RX function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will clear RXEN bit of SPI_I2SCTL register to disable I2S RX function.

Definition at line 450 of file spi.h.

◆ SPII2S_DISABLE_RXDMA

#define SPII2S_DISABLE_RXDMA (   i2s)

Disable I2S RX DMA function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will clear RXPDMAEN bit of SPI_PDMACTL register to disable RX DMA function.

Definition at line 414 of file spi.h.

◆ SPII2S_DISABLE_TX

#define SPII2S_DISABLE_TX (   i2s)

Disable I2S TX function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will clear TXEN bit of SPI_I2SCTL register to disable I2S TX function.

Definition at line 432 of file spi.h.

◆ SPII2S_DISABLE_TX_MUTE

#define SPII2S_DISABLE_TX_MUTE (   i2s)

Disable TX Mute function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will clear MUTE bit of SPI_I2SCTL register to disable I2S TX mute function.

Definition at line 468 of file spi.h.

◆ SPII2S_DISABLE_TXDMA

#define SPII2S_DISABLE_TXDMA (   i2s)

Disable I2S TX DMA function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will clear TXPDMAEN bit of SPI_PDMACTL register to disable TX DMA function.

Definition at line 396 of file spi.h.

◆ SPII2S_ENABLE_RX

#define SPII2S_ENABLE_RX (   i2s)

Enable I2S RX function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will set RXEN bit of SPI_I2SCTL register to enable I2S RX function.

Definition at line 441 of file spi.h.

◆ SPII2S_ENABLE_RXDMA

#define SPII2S_ENABLE_RXDMA (   i2s)

Enable I2S RX DMA function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will set RXPDMAEN bit of SPI_PDMACTL register to receive data with PDMA.

Definition at line 405 of file spi.h.

◆ SPII2S_ENABLE_TX

#define SPII2S_ENABLE_TX (   i2s)

Enable I2S TX function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will set TXEN bit of SPI_I2SCTL register to enable I2S TX function.

Definition at line 423 of file spi.h.

◆ SPII2S_ENABLE_TX_MUTE

#define SPII2S_ENABLE_TX_MUTE (   i2s)

Enable TX Mute function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will set MUTE bit of SPI_I2SCTL register to enable I2S TX mute function.

Definition at line 459 of file spi.h.

◆ SPII2S_ENABLE_TXDMA

#define SPII2S_ENABLE_TXDMA (   i2s)

Enable I2S TX DMA function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

This macro will set TXPDMAEN bit of SPI_PDMACTL register to transmit data with PDMA.

Definition at line 387 of file spi.h.

◆ SPII2S_GET_INT_FLAG

#define SPII2S_GET_INT_FLAG (   i2s,
  u32Mask 
)

Get the interrupt flag.

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32MaskThe mask value for all interrupt flags.
Returns
The interrupt flags specified by the u32mask parameter.

This macro will return the combination interrupt flags of SPI_I2SSTS register. The flags are specified by the u32mask parameter.

Definition at line 532 of file spi.h.

◆ SPII2S_GET_RX_FIFO_LEVEL

#define SPII2S_GET_RX_FIFO_LEVEL (   i2s)

Get receive FIFO level.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
RX FIFO level

This macro will return the number of available words in RX FIFO.

Definition at line 561 of file spi.h.

◆ SPII2S_GET_TX_FIFO_LEVEL

#define SPII2S_GET_TX_FIFO_LEVEL (   i2s)

Get transmit FIFO level.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
TX FIFO level

This macro will return the number of available words in TX FIFO.

Definition at line 552 of file spi.h.

◆ SPII2S_READ_RX_FIFO

#define SPII2S_READ_RX_FIFO (   i2s)

Read RX FIFO.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
The value read from RX FIFO.

This function will return a value read from RX FIFO.

Definition at line 522 of file spi.h.

◆ SPII2S_WRITE_TX_FIFO

#define SPII2S_WRITE_TX_FIFO (   i2s,
  u32Data 
)

Write data to I2S TX FIFO.

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32DataThe value written to TX FIFO.
Returns
None

This macro will write a value to TX FIFO.

Definition at line 513 of file spi.h.

Function Documentation

◆ SPI_ClearIntFlag()

void SPI_ClearIntFlag ( SPI_T spi,
uint32_t  u32Mask 
)

Clear interrupt flag.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32MaskThe combination of all related interrupt sources. Each bit corresponds to a interrupt source. This parameter decides which interrupt flags will be cleared. It could be the combination of:
Returns
None

Clear SPI related interrupt flags specified by u32Mask parameter.

Definition at line 888 of file spi.c.

◆ SPI_ClearRxFIFO()

void SPI_ClearRxFIFO ( SPI_T spi)

Clear RX FIFO buffer.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None

This function will clear SPI RX FIFO buffer. The RXEMPTY (SPI_STATUS[8]) will be set to 1.

Definition at line 293 of file spi.c.

◆ SPI_ClearTxFIFO()

void SPI_ClearTxFIFO ( SPI_T spi)

Clear TX FIFO buffer.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None

This function will clear SPI TX FIFO buffer. The TXEMPTY (SPI_STATUS[16]) will be set to 1.

Note
The TX shift register will not be cleared.

Definition at line 305 of file spi.c.

◆ SPI_Close()

void SPI_Close ( SPI_T spi)

Disable SPI controller.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None

This function will reset SPI controller.

Definition at line 259 of file spi.c.

◆ SPI_DisableAutoSS()

void SPI_DisableAutoSS ( SPI_T spi)

Disable the automatic slave selection function.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
None

This function will disable the automatic slave selection function and set slave selection signal to inactive state.

Definition at line 316 of file spi.c.

◆ SPI_DisableInt()

void SPI_DisableInt ( SPI_T spi,
uint32_t  u32Mask 
)

Disable interrupt function.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32MaskThe combination of all related interrupt enable bits. Each bit corresponds to a interrupt bit. This parameter decides which interrupts will be disabled. It is combination of:
Returns
None

Disable SPI related interrupts specified by u32Mask parameter.

Definition at line 710 of file spi.c.

◆ SPI_EnableAutoSS()

void SPI_EnableAutoSS ( SPI_T spi,
uint32_t  u32SSPinMask,
uint32_t  u32ActiveLevel 
)

Enable the automatic slave selection function.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32SSPinMaskSpecifies slave selection pins. (SPI_SS)
[in]u32ActiveLevelSpecifies the active level of slave selection signal. (SPI_SS_ACTIVE_HIGH, SPI_SS_ACTIVE_LOW)
Returns
None

This function will enable the automatic slave selection function. Only available in Master mode. The slave selection pin and the active level will be set in this function.

Definition at line 330 of file spi.c.

◆ SPI_EnableInt()

void SPI_EnableInt ( SPI_T spi,
uint32_t  u32Mask 
)

Enable interrupt function.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32MaskThe combination of all related interrupt enable bits. Each bit corresponds to a interrupt enable bit. This parameter decides which interrupts will be enabled. It is combination of:
Returns
None

Enable SPI related interrupts specified by u32Mask parameter.

Definition at line 627 of file spi.c.

◆ SPI_GetBusClock()

uint32_t SPI_GetBusClock ( SPI_T spi)

Get the actual frequency of SPI bus clock. Only available in Master mode.

Parameters
[in]spiThe pointer of the specified SPI module.
Returns
Actual SPI bus clock frequency in Hz.

This function will calculate the actual SPI bus clock rate according to the SPInSEL and DIVIDER settings. Only available in Master mode.

Definition at line 513 of file spi.c.

◆ SPI_GetIntFlag()

uint32_t SPI_GetIntFlag ( SPI_T spi,
uint32_t  u32Mask 
)

Get interrupt flag.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32MaskThe combination of all related interrupt sources. Each bit corresponds to a interrupt source. This parameter decides which interrupt flags will be read. It is combination of:
Returns
Interrupt flags of selected sources.

Get SPI related interrupt flags specified by u32Mask parameter.

Definition at line 793 of file spi.c.

◆ SPI_GetStatus()

uint32_t SPI_GetStatus ( SPI_T spi,
uint32_t  u32Mask 
)

Get SPI status.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32MaskThe combination of all related sources. Each bit corresponds to a source. This parameter decides which flags will be read. It is combination of:
Returns
Flags of selected sources.

Get SPI related status specified by u32Mask parameter.

Definition at line 949 of file spi.c.

◆ SPI_Open()

uint32_t SPI_Open ( SPI_T spi,
uint32_t  u32MasterSlave,
uint32_t  u32SPIMode,
uint32_t  u32DataWidth,
uint32_t  u32BusClock 
)

This function make SPI module be ready to transfer.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32MasterSlaveDecides the SPI module is operating in master mode or in slave mode. (SPI_SLAVE, SPI_MASTER)
[in]u32SPIModeDecides the transfer timing. (SPI_MODE_0, SPI_MODE_1, SPI_MODE_2, SPI_MODE_3)
[in]u32DataWidthDecides the data width of a SPI transaction.
[in]u32BusClockThe expected frequency of SPI bus clock in Hz.
Returns
Actual frequency of SPI peripheral clock.

By default, the SPI transfer sequence is MSB first, the slave selection signal is active low and the automatic slave selection function is disabled. In Slave mode, the u32BusClock shall be NULL and the SPI clock divider setting will be 0. The actual clock rate may be different from the target SPI clock rate. For example, if the SPI source clock rate is 12 MHz and the target SPI bus clock rate is 7 MHz, the actual SPI clock rate will be 6MHz.

Note
If u32BusClock = 0, DIVIDER setting will be set to the maximum value.
If u32BusClock >= system clock frequency, SPI peripheral clock source will be set to APB clock and DIVIDER will be set to 0.
If u32BusClock >= SPI peripheral clock source, DIVIDER will be set to 0.
In slave mode, the SPI peripheral clock rate will be equal to APB clock rate.

Definition at line 44 of file spi.c.

◆ SPI_SetBusClock()

uint32_t SPI_SetBusClock ( SPI_T spi,
uint32_t  u32BusClock 
)

Set the SPI bus clock.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32BusClockThe expected frequency of SPI bus clock in Hz.
Returns
Actual frequency of SPI bus clock.

This function is only available in Master mode. The actual clock rate may be different from the target SPI bus clock rate. For example, if the SPI source clock rate is 12 MHz and the target SPI bus clock rate is 7 MHz, the actual SPI bus clock rate will be 6 MHz.

Note
If u32BusClock = 0, DIVIDER setting will be set to the maximum value.
If u32BusClock >= system clock frequency, SPI peripheral clock source will be set to APB clock and DIVIDER will be set to 0.
If u32BusClock >= SPI peripheral clock source, DIVIDER will be set to 0.

Definition at line 347 of file spi.c.

◆ SPI_SetFIFO()

void SPI_SetFIFO ( SPI_T spi,
uint32_t  u32TxThreshold,
uint32_t  u32RxThreshold 
)

Configure FIFO threshold setting.

Parameters
[in]spiThe pointer of the specified SPI module.
[in]u32TxThresholdDecides the TX FIFO threshold. It could be 0 ~ 3. If data width is 8~16 bits, it could be 0 ~ 7.
[in]u32RxThresholdDecides the RX FIFO threshold. It could be 0 ~ 3. If data width is 8~16 bits, it could be 0 ~ 7.
Returns
None

Set TX FIFO threshold and RX FIFO threshold configurations.

Definition at line 500 of file spi.c.

◆ SPII2S_Close()

void SPII2S_Close ( SPI_T i2s)

Disable I2S function.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

Disable I2S function.

Definition at line 1240 of file spi.c.

◆ SPII2S_DISABLE_TX_ZCD()

__STATIC_INLINE void SPII2S_DISABLE_TX_ZCD ( SPI_T i2s,
uint32_t  u32ChMask 
)

Disable zero cross detection function.

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32ChMaskThe mask for left or right channel. Valid values are:
Returns
None

This function will clear RZCEN or LZCEN bit of SPI_I2SCTL register to disable zero cross detection function.

Definition at line 368 of file spi.h.

◆ SPII2S_DisableInt()

void SPII2S_DisableInt ( SPI_T i2s,
uint32_t  u32Mask 
)

Disable interrupt function.

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32MaskThe combination of all related interrupt enable bits. Each bit corresponds to a interrupt source. Valid values are listed below.
Returns
None

This function disables the interrupt according to the u32Mask parameter.

Definition at line 1320 of file spi.c.

◆ SPII2S_DisableMCLK()

void SPII2S_DisableMCLK ( SPI_T i2s)

Disable master clock (MCLK).

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
None

Clear MCLKEN bit of SPI_I2SCTL register to disable master clock output.

Definition at line 1417 of file spi.c.

◆ SPII2S_ENABLE_TX_ZCD()

__STATIC_INLINE void SPII2S_ENABLE_TX_ZCD ( SPI_T i2s,
uint32_t  u32ChMask 
)

Enable zero cross detection function.

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32ChMaskThe mask for left or right channel. Valid values are:
Returns
None

This function will set RZCEN or LZCEN bit of SPI_I2SCTL register to enable zero cross detection function.

Definition at line 347 of file spi.h.

◆ SPII2S_EnableInt()

void SPII2S_EnableInt ( SPI_T i2s,
uint32_t  u32Mask 
)

Enable interrupt function.

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32MaskThe combination of all related interrupt enable bits. Each bit corresponds to a interrupt source. Valid values are listed below.
Returns
None

This function enables the interrupt according to the u32Mask parameter.

Definition at line 1260 of file spi.c.

◆ SPII2S_EnableMCLK()

uint32_t SPII2S_EnableMCLK ( SPI_T i2s,
uint32_t  u32BusClock 
)

Enable master clock (MCLK).

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32BusClockThe target MCLK clock rate.
Returns
Actual MCLK clock rate

Set the master clock rate according to u32BusClock parameter and enable master clock output. The actual master clock rate may be different from the target master clock rate. The real master clock rate will be returned for reference.

Definition at line 1373 of file spi.c.

◆ SPII2S_GetSourceClockFreq()

static uint32_t SPII2S_GetSourceClockFreq ( SPI_T i2s)
static

This function is used to get I2S source clock frequency.

Parameters
[in]i2sThe pointer of the specified I2S module.
Returns
I2S source clock frequency (Hz).

Return the source clock frequency according to the setting of SPI0SEL (CLKSEL2[27:26]).

Definition at line 1019 of file spi.c.

◆ SPII2S_Open()

uint32_t SPII2S_Open ( SPI_T i2s,
uint32_t  u32MasterSlave,
uint32_t  u32SampleRate,
uint32_t  u32WordWidth,
uint32_t  u32Channels,
uint32_t  u32DataFormat 
)

This function configures some parameters of I2S interface for general purpose use.

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32MasterSlaveI2S operation mode. Valid values are listed below.
[in]u32SampleRateSample rate
[in]u32WordWidthData length. Valid values are listed below.
[in]u32ChannelsAudio format. Valid values are listed below.
[in]u32DataFormatData format. Valid values are listed below.
Returns
Real sample rate of master mode or peripheral clock rate of slave mode.

This function will reset SPI/I2S controller and configure I2S controller according to the input parameters. Set TX FIFO threshold to 2 and RX FIFO threshold to 1. Both the TX and RX functions will be enabled. The actual sample rate may be different from the target sample rate. The real sample rate will be returned for reference.

Note
In slave mode, the SPI peripheral clock rate will be equal to APB clock rate.

Definition at line 1133 of file spi.c.

◆ SPII2S_SET_MONO_RX_CHANNEL()

__STATIC_INLINE void SPII2S_SET_MONO_RX_CHANNEL ( SPI_T i2s,
uint32_t  u32Ch 
)

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

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32Chleft or right channel. Valid values are:
Returns
None

This function selects the recording source channel of monaural mode.

Definition at line 498 of file spi.h.

◆ SPII2S_SetFIFO()

void SPII2S_SetFIFO ( SPI_T i2s,
uint32_t  u32TxThreshold,
uint32_t  u32RxThreshold 
)

Configure FIFO threshold setting.

Parameters
[in]i2sThe pointer of the specified I2S module.
[in]u32TxThresholdDecides the TX FIFO threshold. It could be 0 ~ 3.
[in]u32RxThresholdDecides the RX FIFO threshold. It could be 0 ~ 3.
Returns
None

Set TX FIFO threshold and RX FIFO threshold configurations.

Definition at line 1430 of file spi.c.