Peripheral State and Errors functions

SPI control functions. More...

Functions

hal_spi_state_t hal_spi_get_state (spi_handle_t *p_spi)
 Return the SPI handle state. More...
 
uint32_t hal_spi_get_error (spi_handle_t *p_spi)
 Return the SPI error code. More...
 
void hal_spi_set_timeout (spi_handle_t *p_spi, uint32_t timeout)
 Set the SPI internal process timeout value. More...
 
hal_status_t hal_spi_set_tx_fifo_threshold (spi_handle_t *p_spi, uint32_t threshold)
 Set the TX FIFO threshold. More...
 
hal_status_t hal_spi_set_rx_fifo_threshold (spi_handle_t *p_spi, uint32_t threshold)
 Set the RX FIFO threshold. More...
 
uint32_t hal_spi_get_tx_fifo_threshold (spi_handle_t *p_spi)
 Get the TX FIFO threshold. More...
 
uint32_t hal_spi_get_rx_fifo_threshold (spi_handle_t *p_spi)
 Get the RX FIFO threshold. More...
 
hal_status_t hal_spi_suspend_reg (spi_handle_t *p_spi)
 Suspend some registers related to SPI configuration before sleep. More...
 
hal_status_t hal_spi_resume_reg (spi_handle_t *p_spi)
 Restore some registers related to SPI configuration after sleep. This function must be used in conjunction with the hal_spi_suspend_reg(). More...
 
hal_spi_state_t hal_spi_v2_get_state (spi_handle_t *p_spi)
 Return the SPI handle state. More...
 
uint32_t hal_spi_v2_get_error (spi_handle_t *p_spi)
 Return the SPI error code. More...
 
void hal_spi_v2_set_timeout (spi_handle_t *p_spi, uint32_t timeout)
 Set the SPI internal process timeout value. More...
 
uint32_t hal_spi_v2_get_tx_fifo_threshold (spi_handle_t *p_spi)
 Get the TX FIFO threshold. More...
 
uint32_t hal_spi_v2_get_rx_fifo_threshold (spi_handle_t *p_spi)
 Get the RX FIFO threshold. More...
 
hal_status_t hal_spi_v2_suspend_reg (spi_handle_t *p_spi)
 Suspend some registers related to SPI configuration before sleep. More...
 
hal_status_t hal_spi_v2_resume_reg (spi_handle_t *p_spi)
 Restore some registers related to SPI configuration after sleep. This function must be used in conjunction with the hal_spi_suspend_reg(). More...
 
hal_status_t hal_spi_v2_transmit_dma_with_toggle (spi_handle_t *p_spi, uint32_t data_size, uint8_t *p_data, uint32_t length)
 Using DMA to Transmit data by toggling CS in every data beat. More...
 

Detailed Description

SPI control functions.

 ===============================================================================
                      ##### Peripheral State and Errors functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to control the SPI.
     (+) hal_spi_get_state() API can be helpful to check in run-time the state of the SPI peripheral
     (+) hal_spi_get_error() check in run-time Errors occurring during communication
     (+) hal_spi_set_timeout() set the timeout during internal process
     (+) hal_spi_set_tx_fifo_threshold() set the TX FIFO Threshold
     (+) hal_spi_set_rx_fifo_threshold() set the RX FIFO Threshold
     (+) hal_spi_get_tx_fifo_threshold() get the TX FIFO Threshold
     (+) hal_spi_get_rx_fifo_threshold() get the RX FIFO Threshold
 ===============================================================================
                      ##### Peripheral State and Errors functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to control the SPI.
     (+) hal_spi_get_state() API can be helpful to check in run-time the state of the SPI peripheral
     (+) hal_spi_get_error() check in run-time Errors occurring during communication
     (+) hal_spi_set_timeout() set the timeout during internal process
     (+) hal_spi_get_tx_fifo_threshold() get the TX FIFO Threshold
     (+) hal_spi_get_rx_fifo_threshold() get the RX FIFO Threshold

Function Documentation

◆ hal_spi_get_error()

uint32_t hal_spi_get_error ( spi_handle_t p_spi)

Return the SPI error code.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
Returns
SPI error code in bitmap format

◆ hal_spi_get_rx_fifo_threshold()

uint32_t hal_spi_get_rx_fifo_threshold ( spi_handle_t p_spi)

Get the RX FIFO threshold.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
Returns
RX FIFO threshold

◆ hal_spi_get_state()

hal_spi_state_t hal_spi_get_state ( spi_handle_t p_spi)

Return the SPI handle state.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
Return values
HAL_SPI_STATE_RESETPeripheral not initialized.
HAL_SPI_STATE_READYPeripheral initialized and ready for use.
HAL_SPI_STATE_BUSYAn internal process is ongoing.
HAL_SPI_STATE_BUSY_TXData Transmission process is ongoing.
HAL_SPI_STATE_BUSY_RXData Reception process is ongoing.
HAL_SPI_STATE_BUSY_TX_RXData Transmission and Reception process is ongoing.
HAL_SPI_STATE_ABORTPeripheral with abort request ongoing.
HAL_SPI_STATE_ERRORPeripheral in error.

◆ hal_spi_get_tx_fifo_threshold()

uint32_t hal_spi_get_tx_fifo_threshold ( spi_handle_t p_spi)

Get the TX FIFO threshold.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
Returns
TX FIFO threshold

◆ hal_spi_resume_reg()

hal_status_t hal_spi_resume_reg ( spi_handle_t p_spi)

Restore some registers related to SPI configuration after sleep. This function must be used in conjunction with the hal_spi_suspend_reg().

Parameters
[in]p_spiPointer to a SPI handle which contains the configuration information for the specified SPI module.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_set_rx_fifo_threshold()

hal_status_t hal_spi_set_rx_fifo_threshold ( spi_handle_t p_spi,
uint32_t  threshold 
)

Set the RX FIFO threshold.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]thresholdRX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_set_timeout()

void hal_spi_set_timeout ( spi_handle_t p_spi,
uint32_t  timeout 
)

Set the SPI internal process timeout value.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]timeoutInternal process timeout value.

◆ hal_spi_set_tx_fifo_threshold()

hal_status_t hal_spi_set_tx_fifo_threshold ( spi_handle_t p_spi,
uint32_t  threshold 
)

Set the TX FIFO threshold.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]thresholdTX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_suspend_reg()

hal_status_t hal_spi_suspend_reg ( spi_handle_t p_spi)

Suspend some registers related to SPI configuration before sleep.

Parameters
[in]p_spiPointer to a SPI handle which contains the configuration information for the specified SPI module.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_v2_get_error()

uint32_t hal_spi_v2_get_error ( spi_handle_t p_spi)

Return the SPI error code.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
Returns
SPI error code in bitmap format

◆ hal_spi_v2_get_rx_fifo_threshold()

uint32_t hal_spi_v2_get_rx_fifo_threshold ( spi_handle_t p_spi)

Get the RX FIFO threshold.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
Returns
RX FIFO threshold

◆ hal_spi_v2_get_state()

hal_spi_state_t hal_spi_v2_get_state ( spi_handle_t p_spi)

Return the SPI handle state.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
Return values
HAL_SPI_STATE_RESETPeripheral not initialized.
HAL_SPI_STATE_READYPeripheral initialized and ready for use.
HAL_SPI_STATE_BUSYAn internal process is ongoing.
HAL_SPI_STATE_BUSY_TXData Transmission process is ongoing.
HAL_SPI_STATE_BUSY_RXData Reception process is ongoing.
HAL_SPI_STATE_BUSY_TX_RXData Transmission and Reception process is ongoing.
HAL_SPI_STATE_ABORTPeripheral with abort request ongoing.
HAL_SPI_STATE_ERRORPeripheral in error.

◆ hal_spi_v2_get_tx_fifo_threshold()

uint32_t hal_spi_v2_get_tx_fifo_threshold ( spi_handle_t p_spi)

Get the TX FIFO threshold.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
Returns
TX FIFO threshold

◆ hal_spi_v2_resume_reg()

hal_status_t hal_spi_v2_resume_reg ( spi_handle_t p_spi)

Restore some registers related to SPI configuration after sleep. This function must be used in conjunction with the hal_spi_suspend_reg().

Parameters
[in]p_spiPointer to a SPI handle which contains the configuration information for the specified SPI module.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_v2_set_timeout()

void hal_spi_v2_set_timeout ( spi_handle_t p_spi,
uint32_t  timeout 
)

Set the SPI internal process timeout value.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]timeoutInternal process timeout value.

◆ hal_spi_v2_suspend_reg()

hal_status_t hal_spi_v2_suspend_reg ( spi_handle_t p_spi)

Suspend some registers related to SPI configuration before sleep.

Parameters
[in]p_spiPointer to a SPI handle which contains the configuration information for the specified SPI module.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_v2_transmit_dma_with_toggle()

hal_status_t hal_spi_v2_transmit_dma_with_toggle ( spi_handle_t p_spi,
uint32_t  data_size,
uint8_t *  p_data,
uint32_t  length 
)

Using DMA to Transmit data by toggling CS in every data beat.

Parameters
[in]p_spiPointer to a SPI handle which contains the configuration information for the specified SPI module.
[in]data_sizeOptional value - SPI_DATASIZE_8BIT SPI_DATASIZE_16BIT SPI_DATASIZE_32BIT
[in]p_dataPointer to data buffer
[in]lengthLength of data to be sent
Returns
Result of operation.