![]() |
M480 BSP V3.05.005
The Board Support Package for M480 Series
|
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... | |
#define SPI_CLR_UNIT_TRANS_INT_FLAG | ( | spi | ) |
#define SPI_DISABLE | ( | spi | ) |
#define SPI_DISABLE_BYTE_REORDER | ( | spi | ) |
#define SPI_DISABLE_RX_PDMA | ( | spi | ) |
#define SPI_DISABLE_TX_PDMA | ( | spi | ) |
#define SPI_DISABLE_TX_RX_PDMA | ( | spi | ) |
#define SPI_ENABLE | ( | spi | ) |
#define SPI_ENABLE_BYTE_REORDER | ( | spi | ) |
#define SPI_GET_RX_FIFO_COUNT | ( | spi | ) |
#define SPI_GET_RX_FIFO_EMPTY_FLAG | ( | spi | ) |
#define SPI_GET_TX_FIFO_EMPTY_FLAG | ( | spi | ) |
#define SPI_GET_TX_FIFO_FULL_FLAG | ( | spi | ) |
#define SPI_IS_BUSY | ( | spi | ) |
#define SPI_READ_RX | ( | spi | ) |
#define SPI_SET_DATA_WIDTH | ( | spi, | |
u32Width | |||
) |
#define SPI_SET_LSB_FIRST | ( | spi | ) |
#define SPI_SET_MSB_FIRST | ( | spi | ) |
#define SPI_SET_SS_HIGH | ( | spi | ) |
#define SPI_SET_SS_LOW | ( | spi | ) |
#define SPI_SET_SUSPEND_CYCLE | ( | spi, | |
u32SuspCycle | |||
) |
Set the length of suspend interval.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32SuspCycle | Decides the length of suspend interval. It could be 0 ~ 15. |
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).
#define SPI_TRIGGER_RX_PDMA | ( | spi | ) |
#define SPI_TRIGGER_TX_PDMA | ( | spi | ) |
#define SPI_TRIGGER_TX_RX_PDMA | ( | spi | ) |
#define SPI_WRITE_TX | ( | spi, | |
u32TxData | |||
) |
#define SPII2S_CLR_INT_FLAG | ( | i2s, | |
u32Mask | |||
) |
Clear the interrupt flag.
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32Mask | The mask value for all interrupt flags. |
This macro will clear the interrupt flags specified by the u32mask parameter.
#define SPII2S_CLR_RX_FIFO | ( | i2s | ) |
#define SPII2S_CLR_TX_FIFO | ( | i2s | ) |
#define SPII2S_DISABLE_RX | ( | i2s | ) |
#define SPII2S_DISABLE_RXDMA | ( | i2s | ) |
#define SPII2S_DISABLE_TX | ( | i2s | ) |
#define SPII2S_DISABLE_TX_MUTE | ( | i2s | ) |
#define SPII2S_DISABLE_TXDMA | ( | i2s | ) |
#define SPII2S_ENABLE_RX | ( | i2s | ) |
#define SPII2S_ENABLE_RXDMA | ( | i2s | ) |
#define SPII2S_ENABLE_TX | ( | i2s | ) |
#define SPII2S_ENABLE_TX_MUTE | ( | i2s | ) |
#define SPII2S_ENABLE_TXDMA | ( | i2s | ) |
#define SPII2S_GET_INT_FLAG | ( | i2s, | |
u32Mask | |||
) |
Get the interrupt flag.
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32Mask | The mask value for all interrupt flags. |
This macro will return the combination interrupt flags of SPI_I2SSTS register. The flags are specified by the u32mask parameter.
#define SPII2S_GET_RX_FIFO_LEVEL | ( | i2s | ) |
#define SPII2S_GET_TX_FIFO_LEVEL | ( | i2s | ) |
#define SPII2S_READ_RX_FIFO | ( | i2s | ) |
#define SPII2S_WRITE_TX_FIFO | ( | i2s, | |
u32Data | |||
) |
void SPI_ClearIntFlag | ( | SPI_T * | spi, |
uint32_t | u32Mask | ||
) |
Clear interrupt flag.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32Mask | The 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: |
Clear SPI related interrupt flags specified by u32Mask parameter.
void SPI_ClearRxFIFO | ( | SPI_T * | spi | ) |
void SPI_ClearTxFIFO | ( | SPI_T * | spi | ) |
void SPI_Close | ( | SPI_T * | spi | ) |
void SPI_DisableAutoSS | ( | SPI_T * | spi | ) |
void SPI_DisableInt | ( | SPI_T * | spi, |
uint32_t | u32Mask | ||
) |
Disable interrupt function.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32Mask | The 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: |
Disable SPI related interrupts specified by u32Mask parameter.
void SPI_EnableAutoSS | ( | SPI_T * | spi, |
uint32_t | u32SSPinMask, | ||
uint32_t | u32ActiveLevel | ||
) |
Enable the automatic slave selection function.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32SSPinMask | Specifies slave selection pins. (SPI_SS) |
[in] | u32ActiveLevel | Specifies the active level of slave selection signal. (SPI_SS_ACTIVE_HIGH, SPI_SS_ACTIVE_LOW) |
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.
void SPI_EnableInt | ( | SPI_T * | spi, |
uint32_t | u32Mask | ||
) |
Enable interrupt function.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32Mask | The 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: |
Enable SPI related interrupts specified by u32Mask parameter.
uint32_t SPI_GetBusClock | ( | SPI_T * | spi | ) |
Get the actual frequency of SPI bus clock. Only available in Master mode.
[in] | spi | The pointer of the specified SPI module. |
This function will calculate the actual SPI bus clock rate according to the SPInSEL and DIVIDER settings. Only available in Master mode.
uint32_t SPI_GetIntFlag | ( | SPI_T * | spi, |
uint32_t | u32Mask | ||
) |
Get interrupt flag.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32Mask | The 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: |
Get SPI related interrupt flags specified by u32Mask parameter.
uint32_t SPI_GetStatus | ( | SPI_T * | spi, |
uint32_t | u32Mask | ||
) |
Get SPI status.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32Mask | The combination of all related sources. Each bit corresponds to a source. This parameter decides which flags will be read. It is combination of: |
Get SPI related status specified by u32Mask parameter.
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.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32MasterSlave | Decides the SPI module is operating in master mode or in slave mode. (SPI_SLAVE, SPI_MASTER) |
[in] | u32SPIMode | Decides the transfer timing. (SPI_MODE_0, SPI_MODE_1, SPI_MODE_2, SPI_MODE_3) |
[in] | u32DataWidth | Decides the data width of a SPI transaction. |
[in] | u32BusClock | The expected frequency of SPI bus clock in Hz. |
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.
uint32_t SPI_SetBusClock | ( | SPI_T * | spi, |
uint32_t | u32BusClock | ||
) |
Set the SPI bus clock.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32BusClock | The expected frequency of SPI bus clock in Hz. |
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.
void SPI_SetFIFO | ( | SPI_T * | spi, |
uint32_t | u32TxThreshold, | ||
uint32_t | u32RxThreshold | ||
) |
Configure FIFO threshold setting.
[in] | spi | The pointer of the specified SPI module. |
[in] | u32TxThreshold | Decides the TX FIFO threshold. It could be 0 ~ 3. If data width is 8~16 bits, it could be 0 ~ 7. |
[in] | u32RxThreshold | Decides the RX FIFO threshold. It could be 0 ~ 3. If data width is 8~16 bits, it could be 0 ~ 7. |
Set TX FIFO threshold and RX FIFO threshold configurations.
void SPII2S_Close | ( | SPI_T * | i2s | ) |
__STATIC_INLINE void SPII2S_DISABLE_TX_ZCD | ( | SPI_T * | i2s, |
uint32_t | u32ChMask | ||
) |
Disable zero cross detection function.
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32ChMask | The mask for left or right channel. Valid values are: |
This function will clear RZCEN or LZCEN bit of SPI_I2SCTL register to disable zero cross detection function.
void SPII2S_DisableInt | ( | SPI_T * | i2s, |
uint32_t | u32Mask | ||
) |
Disable interrupt function.
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32Mask | The combination of all related interrupt enable bits. Each bit corresponds to a interrupt source. Valid values are listed below. |
This function disables the interrupt according to the u32Mask parameter.
void SPII2S_DisableMCLK | ( | SPI_T * | i2s | ) |
__STATIC_INLINE void SPII2S_ENABLE_TX_ZCD | ( | SPI_T * | i2s, |
uint32_t | u32ChMask | ||
) |
Enable zero cross detection function.
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32ChMask | The mask for left or right channel. Valid values are: |
This function will set RZCEN or LZCEN bit of SPI_I2SCTL register to enable zero cross detection function.
void SPII2S_EnableInt | ( | SPI_T * | i2s, |
uint32_t | u32Mask | ||
) |
Enable interrupt function.
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32Mask | The combination of all related interrupt enable bits. Each bit corresponds to a interrupt source. Valid values are listed below. |
This function enables the interrupt according to the u32Mask parameter.
uint32_t SPII2S_EnableMCLK | ( | SPI_T * | i2s, |
uint32_t | u32BusClock | ||
) |
Enable master clock (MCLK).
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32BusClock | The target 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.
|
static |
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.
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32MasterSlave | I2S operation mode. Valid values are listed below. |
[in] | u32SampleRate | Sample rate |
[in] | u32WordWidth | Data length. Valid values are listed below. |
[in] | u32Channels | Audio format. Valid values are listed below. |
[in] | u32DataFormat | Data format. Valid values are listed below. |
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.
__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.
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32Ch | left or right channel. Valid values are: |
This function selects the recording source channel of monaural mode.
void SPII2S_SetFIFO | ( | SPI_T * | i2s, |
uint32_t | u32TxThreshold, | ||
uint32_t | u32RxThreshold | ||
) |
Configure FIFO threshold setting.
[in] | i2s | The pointer of the specified I2S module. |
[in] | u32TxThreshold | Decides the TX FIFO threshold. It could be 0 ~ 3. |
[in] | u32RxThreshold | Decides the RX FIFO threshold. It could be 0 ~ 3. |
Set TX FIFO threshold and RX FIFO threshold configurations.