Functions
Peripheral State and Errors functions
Peripheral Driver » HAL Driver » SPI » Functions

SPI control functions. More...

Collaboration diagram for Peripheral State and Errors functions:

## 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. More...
void | hal_spi_soft_cs_assert (spi_handle_t *p_spi, uint32_t state)
| Assert the CS Singal line by software (When activate the soft-cs mode) More...
void | hal_spi_soft_cs_deassert (spi_handle_t *p_spi, uint32_t state)
| De-Assert the CS Singal line by software (When activate the soft-cs mode) 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

## 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_spi | Pointer 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_spi | Pointer 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_spi | Pointer to an SPI handle which contains the configuration information for the specified SPI module.

Return values

  HAL_SPI_STATE_RESET | Peripheral not initialized.
  HAL_SPI_STATE_READY | Peripheral initialized and ready for use.
  HAL_SPI_STATE_BUSY | An internal process is ongoing.
  HAL_SPI_STATE_BUSY_TX | Data Transmission process is ongoing.
  HAL_SPI_STATE_BUSY_RX | Data Reception process is ongoing.
  HAL_SPI_STATE_BUSY_TX_RX | Data Transmission and Reception process is ongoing.
  HAL_SPI_STATE_ABORT | Peripheral with abort request ongoing.
  HAL_SPI_STATE_ERROR | Peripheral 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_spi | Pointer 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_spi | Pointer to a SPI handle which contains the configuration information for the specified SPI module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout 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_spi | Pointer to an SPI handle which contains the configuration information for the specified SPI module.
  [in] | threshold | RX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout 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_spi | Pointer to an SPI handle which contains the configuration information for the specified SPI module.
  [in] | timeout | Internal 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_spi | Pointer to an SPI handle which contains the configuration information for the specified SPI module.
  [in] | threshold | TX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.

## ◆ hal_spi_soft_cs_assert()

void hal_spi_soft_cs_assert | ( | spi_handle_t * | p_spi,
|  | uint32_t | state
| ) |  |

Assert the CS Singal line by software (When activate the soft-cs mode)

Parameters

  [in] | p_spi | Pointer to a SPI handle which contains the configuration information for the specified SPI module.
  [in] | state | assert state, please State from Software CS Assert.

Return values

  : | none

## ◆ hal_spi_soft_cs_deassert()

void hal_spi_soft_cs_deassert | ( | spi_handle_t * | p_spi,
|  | uint32_t | state
| ) |  |

De-Assert the CS Singal line by software (When activate the soft-cs mode)

Parameters

  [in] | p_spi | Pointer to a SPI handle which contains the configuration information for the specified SPI module.
  [in] | state | assert state, please State from Software CS Assert.

Return values

  : | none

## ◆ 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_spi | Pointer to a SPI handle which contains the configuration information for the specified SPI module.

Return values

  HAL_OK | Operation is OK.
  HAL_ERROR | Parameter error or operation not supported.
  HAL_BUSY | Driver is busy.
  HAL_TIMEOUT | Timeout occurred.