NUC472_NUC442_BSP V3.03.005
The Board Support Package for NUC472/NUC442
Macros | Functions
Collaboration diagram for SPI Exported Functions:

Macros

#define SPI_SET_SLAVE_TIMEOUT_PERIOD(spi, u32TimeoutPeriod)
 Set time out period for slave. More...
 
#define SPI_ENABLE_TIMEOUT_FIFO_CLEAR(spi)
 Enable time out clear function for FIFO mode. More...
 
#define SPI_DISABLE_TIMEOUT_FIFO_CLEAR(spi)
 Disable time out clear function for FIFO mode. More...
 
#define SPI_SET_TX_UNDERRUN_DATA_LOW(spi)
 Set data out signal to low (0) if transmit under-run occurs. More...
 
#define SPI_SET_TX_UNDERRUN_DATA_HIGH(spi)
 Set data out signal to high (1) if transmit under-run occurs. More...
 
#define SPI_GET_STATUS(spi)
 Get the status flags. More...
 
#define SPI_CLR_UNIT_TRANS_INT_FLAG(spi)
 Clear the unit transfer interrupt flag. More...
 
#define SPI_DISABLE_3WIRE_MODE(spi)
 Disable slave 3-wire mode. More...
 
#define SPI_ENABLE_3WIRE_MODE(spi)
 Enable slave 3-wire mode. 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 R0 FIFO. More...
 
#define SPI_WRITE_TX(spi, u32TxData)
 Write datum to TX register. More...
 
#define SPI_SET_SS0_HIGH(spi)
 Set SPIn_SS0 pin to high state. More...
 
#define SPI_SET_SS0_LOW(spi)
 Set SPIn_SS0 pin to low state. More...
 
#define SPI_SET_SS1_HIGH(spi)
 Set SPIn_SS1 pin to high state. More...
 
#define SPI_SET_SS1_LOW(spi)
 Set SPIn_SS1 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_IS_BUSY(spi)
 Get the SPI busy state. More...
 
#define SPI_TRIGGER(spi)
 Set the SPIEN bit to trigger SPI transfer. More...
 
#define SPI_ENABLE(spi)
 Set the SPIEN bit to trigger SPI transfer. More...
 
#define SPI_DISABLE(spi)
 Disable SPI function. More...
 
#define SPI_DISABLE_DUAL_MODE(spi)
 Disable SPI Dual IO function. More...
 
#define SPI_ENABLE_DUAL_INPUT_MODE(spi)
 Enable Dual IO function and set SPI Dual IO direction to input. More...
 
#define SPI_ENABLE_DUAL_OUTPUT_MODE(spi)
 Enable Dual IO function and set SPI Dual IO direction to output. More...
 
#define SPI_DISABLE_QUAD_MODE(spi)
 Disable SPI Dual IO function. More...
 
#define SPI_ENABLE_QUAD_INPUT_MODE(spi)
 Set SPI Quad IO direction to input. More...
 
#define SPI_ENABLE_QUAD_OUTPUT_MODE(spi)
 Set SPI Quad IO direction to output. More...
 
#define SPI_TRIGGER_RX_PDMA(spi)
 Trigger RX PDMA transfer. More...
 
#define SPI_TRIGGER_TX_PDMA(spi)
 Trigger TX PDMA transfer. More...
 
#define SPI_TRIGGER_TXRX_PDMA(spi)
 Trigger TX/RX PDMA transfer at the same time. More...
 
#define SPI_DISABLE_RX_PDMA(spi)
 Disable RX PDMA transfer. More...
 
#define SPI_DISABLE_TX_PDMA(spi)
 Trigger TX PDMA transfer. More...
 
#define SPI_ENABLE_2BIT_MODE(spi)
 Enable 2-bit transfer mode. More...
 
#define SPI_DISABLE_2BIT_MODE(spi)
 Disable 2-bit transfer mode. More...
 

Functions

static __INLINE void SPI_SET_DATA_WIDTH (SPI_T *spi, uint32_t u32Width)
 Set the data width of a SPI transaction. 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. By default, the SPI transfer sequence is MSB first and the automatic slave select function is disabled. In Slave mode, the u32BusClock must be NULL and the SPI clock divider setting will be 0. More...
 
void SPI_Close (SPI_T *spi)
 Reset SPI module and disable SPI peripheral clock. 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 select function. More...
 
void SPI_EnableAutoSS (SPI_T *spi, uint32_t u32SSPinMask, uint32_t u32ActiveLevel)
 Enable the automatic slave select function. Only available in Master mode. More...
 
uint32_t SPI_SetBusClock (SPI_T *spi, uint32_t u32BusClock)
 Set the SPI bus clock. Only available in Master mode. More...
 
void SPI_SetFIFOThreshold (SPI_T *spi, uint32_t u32TxThreshold, uint32_t u32RxThreshold)
 Set Tx FIFO threshold and Rx FIFO threshold configurations. 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 FIFO related interrupts specified by u32Mask parameter. More...
 
void SPI_DisableInt (SPI_T *spi, uint32_t u32Mask)
 Disable FIFO related interrupts specified by u32Mask parameter. 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]spiis the base address of SPI module.
Returns
none

Definition at line 122 of file spi.h.

◆ SPI_DISABLE

#define SPI_DISABLE (   spi)

Disable SPI function.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 328 of file spi.h.

◆ SPI_DISABLE_2BIT_MODE

#define SPI_DISABLE_2BIT_MODE (   spi)

Disable 2-bit transfer mode.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 434 of file spi.h.

◆ SPI_DISABLE_3WIRE_MODE

#define SPI_DISABLE_3WIRE_MODE (   spi)

Disable slave 3-wire mode.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 131 of file spi.h.

◆ SPI_DISABLE_BYTE_REORDER

#define SPI_DISABLE_BYTE_REORDER (   spi)

Disable byte reorder function.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 250 of file spi.h.

◆ SPI_DISABLE_DUAL_MODE

#define SPI_DISABLE_DUAL_MODE (   spi)

Disable SPI Dual IO function.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 336 of file spi.h.

◆ SPI_DISABLE_QUAD_MODE

#define SPI_DISABLE_QUAD_MODE (   spi)

Disable SPI Dual IO function.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 360 of file spi.h.

◆ SPI_DISABLE_RX_PDMA

#define SPI_DISABLE_RX_PDMA (   spi)

Disable RX PDMA transfer.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 408 of file spi.h.

◆ SPI_DISABLE_TIMEOUT_FIFO_CLEAR

#define SPI_DISABLE_TIMEOUT_FIFO_CLEAR (   spi)

Disable time out clear function for FIFO mode.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 90 of file spi.h.

◆ SPI_DISABLE_TX_PDMA

#define SPI_DISABLE_TX_PDMA (   spi)

Trigger TX PDMA transfer.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 416 of file spi.h.

◆ SPI_ENABLE

#define SPI_ENABLE (   spi)

Set the SPIEN bit to trigger SPI transfer.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 320 of file spi.h.

◆ SPI_ENABLE_2BIT_MODE

#define SPI_ENABLE_2BIT_MODE (   spi)

Enable 2-bit transfer mode.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 425 of file spi.h.

◆ SPI_ENABLE_3WIRE_MODE

#define SPI_ENABLE_3WIRE_MODE (   spi)

Enable slave 3-wire mode.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 140 of file spi.h.

◆ SPI_ENABLE_BYTE_REORDER

#define SPI_ENABLE_BYTE_REORDER (   spi)

Enable byte reorder function.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 241 of file spi.h.

◆ SPI_ENABLE_DUAL_INPUT_MODE

#define SPI_ENABLE_DUAL_INPUT_MODE (   spi)

Enable Dual IO function and set SPI Dual IO direction to input.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 344 of file spi.h.

◆ SPI_ENABLE_DUAL_OUTPUT_MODE

#define SPI_ENABLE_DUAL_OUTPUT_MODE (   spi)

Enable Dual IO function and set SPI Dual IO direction to output.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 352 of file spi.h.

◆ SPI_ENABLE_QUAD_INPUT_MODE

#define SPI_ENABLE_QUAD_INPUT_MODE (   spi)

Set SPI Quad IO direction to input.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 368 of file spi.h.

◆ SPI_ENABLE_QUAD_OUTPUT_MODE

#define SPI_ENABLE_QUAD_OUTPUT_MODE (   spi)

Set SPI Quad IO direction to output.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 376 of file spi.h.

◆ SPI_ENABLE_TIMEOUT_FIFO_CLEAR

#define SPI_ENABLE_TIMEOUT_FIFO_CLEAR (   spi)

Enable time out clear function for FIFO mode.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 82 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]spiis the base address of SPI module.
Returns
The count of available data in RX FIFO.

Definition at line 148 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]spiis the base address of SPI module.
Returns
Rx FIFO flag
Return values
0Rx FIFO is not empty
1Rx FIFO is empty

Definition at line 158 of file spi.h.

◆ SPI_GET_STATUS

#define SPI_GET_STATUS (   spi)

Get the status flags.

Parameters
spiis the base address of SPI module.
Returns
status flags

Definition at line 114 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]spiis the base address of SPI module.
Returns
Tx FIFO flag
Return values
0Tx FIFO is not empty
1Tx FIFO is empty

Definition at line 168 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]spiis the base address of SPI module.
Returns
Tx FIFO flag
Return values
0Tx FIFO is not full
1Tx FIFO is full

Definition at line 178 of file spi.h.

◆ SPI_IS_BUSY

#define SPI_IS_BUSY (   spi)

Get the SPI busy state.

Parameters
[in]spiis the base address of SPI module.
Returns
SPI busy status
Return values
0SPI module is not busy
1SPI module is busy

Definition at line 304 of file spi.h.

◆ SPI_READ_RX

#define SPI_READ_RX (   spi)

Get the datum read from R0 FIFO.

Parameters
[in]spiis the base address of SPI module.
Returns
data in Rx register

Definition at line 186 of file spi.h.

◆ SPI_SET_LSB_FIRST

#define SPI_SET_LSB_FIRST (   spi)

Set the SPI transfer sequence with LSB first.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 269 of file spi.h.

◆ SPI_SET_MSB_FIRST

#define SPI_SET_MSB_FIRST (   spi)

Set the SPI transfer sequence with MSB first.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 278 of file spi.h.

◆ SPI_SET_SLAVE_TIMEOUT_PERIOD

#define SPI_SET_SLAVE_TIMEOUT_PERIOD (   spi,
  u32TimeoutPeriod 
)

Set time out period for slave.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
[in]u32TimeoutPeriodis the period of time out.
Returns
none

Definition at line 74 of file spi.h.

◆ SPI_SET_SS0_HIGH

#define SPI_SET_SS0_HIGH (   spi)

Set SPIn_SS0 pin to high state.

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

Disable automatic slave selection function and set SPIn_SS0 pin to high state. Only available in Master mode.

Definition at line 204 of file spi.h.

◆ SPI_SET_SS0_LOW

#define SPI_SET_SS0_LOW (   spi)

Set SPIn_SS0 pin to low state.

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

Disable automatic slave selection function and set SPIn_SS0 pin to low state. Only available in Master mode.

Definition at line 213 of file spi.h.

◆ SPI_SET_SS1_HIGH

#define SPI_SET_SS1_HIGH (   spi)

Set SPIn_SS1 pin to high state.

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

Disable automatic slave selection function and set SPIn_SS1 pin to high state. Only available in Master mode.

Definition at line 222 of file spi.h.

◆ SPI_SET_SS1_LOW

#define SPI_SET_SS1_LOW (   spi)

Set SPIn_SS1 pin to low state.

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

Disable automatic slave selection function and set SPIn_SS1 pin to low state. Only available in Master mode.

Definition at line 231 of file spi.h.

◆ SPI_SET_SUSPEND_CYCLE

#define SPI_SET_SUSPEND_CYCLE (   spi,
  u32SuspCycle 
)

Set the length of suspend interval.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
[in]u32SuspCycledecides the length of suspend interval.
Returns
none

Definition at line 260 of file spi.h.

◆ SPI_SET_TX_UNDERRUN_DATA_HIGH

#define SPI_SET_TX_UNDERRUN_DATA_HIGH (   spi)

Set data out signal to high (1) if transmit under-run occurs.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 106 of file spi.h.

◆ SPI_SET_TX_UNDERRUN_DATA_LOW

#define SPI_SET_TX_UNDERRUN_DATA_LOW (   spi)

Set data out signal to low (0) if transmit under-run occurs.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 98 of file spi.h.

◆ SPI_TRIGGER

#define SPI_TRIGGER (   spi)

Set the SPIEN bit to trigger SPI transfer.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 312 of file spi.h.

◆ SPI_TRIGGER_RX_PDMA

#define SPI_TRIGGER_RX_PDMA (   spi)

Trigger RX PDMA transfer.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 384 of file spi.h.

◆ SPI_TRIGGER_TX_PDMA

#define SPI_TRIGGER_TX_PDMA (   spi)

Trigger TX PDMA transfer.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 392 of file spi.h.

◆ SPI_TRIGGER_TXRX_PDMA

#define SPI_TRIGGER_TXRX_PDMA (   spi)

Trigger TX/RX PDMA transfer at the same time.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 400 of file spi.h.

◆ SPI_WRITE_TX

#define SPI_WRITE_TX (   spi,
  u32TxData 
)

Write datum to TX register.

Parameters
[in]spiis the base address of SPI module.
[in]u32TxDatais the datum which user attempt to transfer through SPI bus.
Returns
none

Definition at line 195 of file spi.h.

Function Documentation

◆ SPI_ClearRxFIFO()

void SPI_ClearRxFIFO ( SPI_T spi)

Clear Rx FIFO buffer.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 91 of file spi.c.

◆ SPI_ClearTxFIFO()

void SPI_ClearTxFIFO ( SPI_T spi)

Clear Tx FIFO buffer.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 101 of file spi.c.

◆ SPI_Close()

void SPI_Close ( SPI_T spi)

Reset SPI module and disable SPI peripheral clock.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 61 of file spi.c.

◆ SPI_DisableAutoSS()

void SPI_DisableAutoSS ( SPI_T spi)

Disable the automatic slave select function.

Parameters
[in]spiis the base address of SPI module.
Returns
none

Definition at line 111 of file spi.c.

◆ SPI_DisableInt()

void SPI_DisableInt ( SPI_T spi,
uint32_t  u32Mask 
)

Disable FIFO related interrupts specified by u32Mask parameter.

Parameters
[in]spiis the base address of SPI module.
[in]u32Maskis the combination of all related interrupt enable bits. Each bit corresponds to a interrupt bit. This parameter decides which interrupts will be enabled. Valid values are:
Returns
none

Definition at line 319 of file spi.c.

◆ SPI_EnableAutoSS()

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

Enable the automatic slave select function. Only available in Master mode.

Parameters
[in]spiis the base address of SPI module.
[in]u32SSPinMaskspecifies slave select pins. Valid values are:
[in]u32ActiveLevelspecifies the active level of slave select signal. Valid values are:
Returns
none

Definition at line 127 of file spi.c.

◆ SPI_EnableInt()

void SPI_EnableInt ( SPI_T spi,
uint32_t  u32Mask 
)

Enable FIFO related interrupts specified by u32Mask parameter.

Parameters
[in]spiis the base address of SPI module.
[in]u32Maskis the combination of all related interrupt enable bits. Each bit corresponds to a interrupt bit. This parameter decides which interrupts will be enabled. Valid values are:
Returns
none

Definition at line 264 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]spiis the base address of SPI module.
Returns
Actual SPI bus clock frequency.

Definition at line 207 of file spi.c.

Here is the call graph for this function:

◆ 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. By default, the SPI transfer sequence is MSB first and the automatic slave select function is disabled. In Slave mode, the u32BusClock must be NULL and the SPI clock divider setting will be 0.

Parameters
[in]spiis the base address of SPI module.
[in]u32MasterSlavedecides the SPI module is operating in master mode or in slave mode. Valid values are:
[in]u32SPIModedecides the transfer timing. Valid values are:
[in]u32DataWidthdecides the data width of a SPI transaction.
[in]u32BusClockis the expected frequency of SPI bus clock in Hz.
Returns
Actual frequency of SPI peripheral clock.

Definition at line 46 of file spi.c.

Here is the call graph for this function:

◆ SPI_SET_DATA_WIDTH()

static __INLINE void SPI_SET_DATA_WIDTH ( SPI_T spi,
uint32_t  u32Width 
)
static

Set the data width of a SPI transaction.

Note
Before calling this function, SPI must be stopped first. SPI_DISABLE must be called.
Parameters
[in]spiis the base address of SPI module.
[in]u32Widthdata width
Returns
none

Definition at line 288 of file spi.h.

◆ SPI_SetBusClock()

uint32_t SPI_SetBusClock ( SPI_T spi,
uint32_t  u32BusClock 
)

Set the SPI bus clock. Only available in Master mode.

Parameters
[in]spiis the base address of SPI module.
[in]u32BusClockis the expected frequency of SPI bus clock.
Returns
Actual frequency of SPI peripheral clock.

Definition at line 138 of file spi.c.

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

◆ SPI_SetFIFOThreshold()

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

Set Tx FIFO threshold and Rx FIFO threshold configurations.

Parameters
[in]spiis the base address of SPI module.
[in]u32TxThresholddecides the Tx FIFO threshold.
[in]u32RxThresholddecides the Rx FIFO threshold.
Returns
none

Definition at line 195 of file spi.c.