SPI operation functions

Data transfer functions. More...

Functions

hal_status_t hal_spi_transmit (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout)
 Transmit an amount of data in blocking mode. More...
 
hal_status_t hal_spi_receive (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length, uint32_t timeout)
 Receive an amount of data in blocking mode. More...
 
hal_status_t hal_spi_transmit_receive (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length, uint32_t timeout)
 Transmit and Receive an amount of data in blocking mode. More...
 
hal_status_t hal_spi_read_eeprom (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data, uint32_t timeout)
 Read an amount of data from EEPROM in blocking mode. More...
 
hal_status_t hal_spi_transmit_it (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
 Transmit an amount of data in non-blocking mode with Interrupt. More...
 
hal_status_t hal_spi_receive_it (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
 Receive an amount of data in non-blocking mode with Interrupt. More...
 
hal_status_t hal_spi_transmit_receive_it (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length)
 Transmit and Receive an amount of data in non-blocking mode with Interrupt. More...
 
hal_status_t hal_spi_read_eeprom_it (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data)
 Read an amount of data from EEPROM in non-blocking mode with Interrupt. More...
 
hal_status_t hal_spi_transmit_dma (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
 Transmit an amount of data in non-blocking mode with DMA. More...
 
hal_status_t hal_spi_receive_dma (spi_handle_t *p_spi, uint8_t *p_data, uint32_t length)
 Receive an amount of data in non-blocking mode with DMA. More...
 
hal_status_t hal_spi_transmit_receive_dma (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t length)
 Transmit and Receive an amount of data in non-blocking mode with DMA. More...
 
hal_status_t hal_spi_read_eeprom_dma (spi_handle_t *p_spi, uint8_t *p_tx_data, uint8_t *p_rx_data, uint32_t tx_number_data, uint32_t rx_number_data)
 Read an amount of data from EEPROM in non-blocking mode with DMA. More...
 
hal_status_t hal_spi_transmit_dma_llp (spi_handle_t *p_spi, dma_llp_config_t *p_llp_config, uint32_t data_length)
 Transmit an amount of data in non-blocking mode with DMA LLP. More...
 
hal_status_t hal_spi_read_eeprom_dma_scatter (spi_handle_t *p_spi, uint8_t *p_tx_data, uint32_t tx_data_length, uint8_t *p_rx_data, uint32_t rx_data_length, uint32_t sct_interval, uint32_t sct_count)
 Receive an amount of data in non-blocking mode with DMA. More...
 
hal_status_t hal_spi_transmit_with_ia (spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length, uint32_t timeout)
 Transmit an amount of data in non-blocking mode with polling. Support Setting C&A. More...
 
hal_status_t hal_spi_transmit_dma_with_ia (spi_handle_t *p_spi, uint8_t inst, uint32_t addr, uint8_t *p_data, uint32_t length)
 Transmit an amount of data in non-blocking mode with DMA. Support Setting C&A. More...
 
hal_status_t hal_spi_abort (spi_handle_t *p_spi)
 Abort ongoing transfer (blocking mode). More...
 
hal_status_t hal_spi_abort_it (spi_handle_t *p_spi)
 Abort ongoing transfer (Interrupt mode). More...
 

Detailed Description

Data transfer functions.

  ==============================================================================
                      ##### SPI operation functions #####
 ===============================================================================
 [..]
    This subsection provides a set of functions allowing to manage the SPI
    data transfer.

    [..] The SPI supports master and slave mode:

    (#) There are two modes of transfer:
       (++) Blocking mode: The communication is performed in polling mode.
            The HAL status of all data processing is returned by the same function
            after finishing transfer.
       (++) No-Blocking mode: The communication is performed using Interrupts
            or DMA, These APIs return the HAL status.
            The end of the data processing will be indicated through the
            dedicated SPI IRQ when using Interrupt mode or the DMA IRQ when
            using DMA mode.
            The hal_spi_tx_cplt_callback(), hal_spi_rx_cplt_callback() and hal_spi_txrx_cplt_callback() user callbacks
            will be executed respectively at the end of the transmit or Receive process
            The hal_spi_error_callback() user callback will be executed when a communication error is detected.

    (#) APIs provided for these 2 transfer modes (Blocking mode or Non blocking mode using either Interrupt or DMA)
        exist for 1-Line (simplex) and 2-Line (full duplex) modes.

Function Documentation

◆ hal_spi_abort()

hal_status_t hal_spi_abort ( spi_handle_t p_spi)

Abort ongoing transfer (blocking mode).

Parameters
[in]p_spiSPI handle.
Note
This procedure could be used for aborting any ongoing transfer (Tx and Rx), started in Interrupt or DMA mode. This procedure performs following operations :
  • Disable SPI Interrupts (depending of transfer direction)
  • Disable the DMA transfer in the peripheral register (if enabled)
  • Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
  • Set handle State to READY
This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_abort_it()

hal_status_t hal_spi_abort_it ( spi_handle_t p_spi)

Abort ongoing transfer (Interrupt mode).

Parameters
[in]p_spiSPI handle.
Note
This procedure could be used for aborting any ongoing transfer (Tx and Rx), started in Interrupt or DMA mode. This procedure performs following operations :
  • Disable SPI Interrupts (depending of transfer direction)
  • Disable the DMA transfer in the peripheral register (if enabled)
  • Abort DMA transfer by calling hal_dma_abort_it (in case of transfer in DMA mode)
  • Set handle State to READY
  • At abort completion, call user abort complete callback
This procedure is executed in Interrupt mode, meaning that abort procedure could be considered as completed only when user abort complete callback is executed (not when exiting function).
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_read_eeprom()

hal_status_t hal_spi_read_eeprom ( spi_handle_t p_spi,
uint8_t *  p_tx_data,
uint8_t *  p_rx_data,
uint32_t  tx_number_data,
uint32_t  rx_number_data,
uint32_t  timeout 
)

Read an amount of data from EEPROM in blocking mode.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_tx_dataPointer to transmission data buffer
[out]p_rx_dataPointer to reception data buffer
[in]tx_number_dataAmount of data to be sent in bytes
[in]rx_number_dataAmount of data to be received in bytes
[in]timeoutTimeout duration
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_read_eeprom_dma()

hal_status_t hal_spi_read_eeprom_dma ( spi_handle_t p_spi,
uint8_t *  p_tx_data,
uint8_t *  p_rx_data,
uint32_t  tx_number_data,
uint32_t  rx_number_data 
)

Read an amount of data from EEPROM in non-blocking mode with DMA.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_tx_dataPointer to transmission data buffer
[out]p_rx_dataPointer to reception data buffer
[in]tx_number_dataAmount of data to be sent in bytes
[in]rx_number_dataAmount of data to be received in bytes, ranging between 0 and 4095.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_read_eeprom_dma_scatter()

hal_status_t hal_spi_read_eeprom_dma_scatter ( spi_handle_t p_spi,
uint8_t *  p_tx_data,
uint32_t  tx_data_length,
uint8_t *  p_rx_data,
uint32_t  rx_data_length,
uint32_t  sct_interval,
uint32_t  sct_count 
)

Receive an amount of data in non-blocking mode with DMA.

Note
In case of MASTER mode and SPI_DIRECTION_2LINES direction, p_dmatx shall be defined.
Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_tx_dataPointer to transmit data buffer
[in]tx_data_lengthAmount of data to be sent in bytes
[in]p_rx_dataPointer to receive data buffer
[in]rx_data_lengthAmount of data to be received in bytes
[in]sct_intervalScatter interval in beat
[in]sct_countScatter count in beat
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_read_eeprom_it()

hal_status_t hal_spi_read_eeprom_it ( spi_handle_t p_spi,
uint8_t *  p_tx_data,
uint8_t *  p_rx_data,
uint32_t  tx_number_data,
uint32_t  rx_number_data 
)

Read an amount of data from EEPROM in non-blocking mode with Interrupt.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_tx_dataPointer to transmission data buffer
[out]p_rx_dataPointer to reception data buffer
[in]tx_number_dataAmount of data to be sent in bytes
[in]rx_number_dataAmount of data to be received in bytes
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_receive()

hal_status_t hal_spi_receive ( spi_handle_t p_spi,
uint8_t *  p_data,
uint32_t  length,
uint32_t  timeout 
)

Receive an amount of data in blocking mode.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[out]p_dataPointer to data buffer
[in]lengthAmount of data to be received in bytes
[in]timeoutTimeout duration
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_receive_dma()

hal_status_t hal_spi_receive_dma ( spi_handle_t p_spi,
uint8_t *  p_data,
uint32_t  length 
)

Receive an amount of data in non-blocking mode with DMA.

Note
In case of MASTER mode and SPI_DIRECTION_2LINES direction, p_dmatx shall be defined.
Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[out]p_dataPointer to data buffer
[in]lengthAmount of data to be sent in bytes, ranging between 0 and 4095.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_receive_it()

hal_status_t hal_spi_receive_it ( spi_handle_t p_spi,
uint8_t *  p_data,
uint32_t  length 
)

Receive an amount of data in non-blocking mode with Interrupt.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[out]p_dataPointer to data buffer
[in]lengthAmount of data to be sent in bytes
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_transmit()

hal_status_t hal_spi_transmit ( spi_handle_t p_spi,
uint8_t *  p_data,
uint32_t  length,
uint32_t  timeout 
)

Transmit an amount of data in blocking mode.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_dataPointer to data buffer
[in]lengthAmount of data to be sent in bytes
[in]timeoutTimeout duration
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_transmit_dma()

hal_status_t hal_spi_transmit_dma ( spi_handle_t p_spi,
uint8_t *  p_data,
uint32_t  length 
)

Transmit an amount of data in non-blocking mode with DMA.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_dataPointer to data buffer
[in]lengthAmount of data to be sent in bytes, ranging between 0 and 4095.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_transmit_dma_llp()

hal_status_t hal_spi_transmit_dma_llp ( spi_handle_t p_spi,
dma_llp_config_t p_llp_config,
uint32_t  data_length 
)

Transmit an amount of data in non-blocking mode with DMA LLP.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_llp_configPointer to Linked List Block
[in]data_lengthTotal data in all Blocks to be transmitted, unit in Byte
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.

◆ hal_spi_transmit_dma_with_ia()

hal_status_t hal_spi_transmit_dma_with_ia ( spi_handle_t p_spi,
uint8_t  inst,
uint32_t  addr,
uint8_t *  p_data,
uint32_t  length 
)

Transmit an amount of data in non-blocking mode with DMA. Support Setting C&A.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]inst1 byte instruction
[in]addr3 bytes address
[in]p_dataPointer to data buffer
[in]lengthAmount of data to be sent in bytes, ranging between 0 and 4095.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_transmit_it()

hal_status_t hal_spi_transmit_it ( spi_handle_t p_spi,
uint8_t *  p_data,
uint32_t  length 
)

Transmit an amount of data in non-blocking mode with Interrupt.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_dataPointer to data buffer
[in]lengthAmount of data to be sent in bytes
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_transmit_receive()

hal_status_t hal_spi_transmit_receive ( spi_handle_t p_spi,
uint8_t *  p_tx_data,
uint8_t *  p_rx_data,
uint32_t  length,
uint32_t  timeout 
)

Transmit and Receive an amount of data in blocking mode.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_tx_dataPointer to transmission data buffer
[out]p_rx_dataPointer to reception data buffer
[in]lengthAmount of data to be sent and received in bytes
[in]timeoutTimeout duration
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_transmit_receive_dma()

hal_status_t hal_spi_transmit_receive_dma ( spi_handle_t p_spi,
uint8_t *  p_tx_data,
uint8_t *  p_rx_data,
uint32_t  length 
)

Transmit and Receive an amount of data in non-blocking mode with DMA.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_tx_dataPointer to transmission data buffer
[out]p_rx_dataPointer to reception data buffer
[in]lengthAmount of data to be sent in bytes, ranging between 0 and 4095.
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_transmit_receive_it()

hal_status_t hal_spi_transmit_receive_it ( spi_handle_t p_spi,
uint8_t *  p_tx_data,
uint8_t *  p_rx_data,
uint32_t  length 
)

Transmit and Receive an amount of data in non-blocking mode with Interrupt.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]p_tx_dataPointer to transmission data buffer
[out]p_rx_dataPointer to reception data buffer
[in]lengthAmount of data to be sent and received in bytes
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.

◆ hal_spi_transmit_with_ia()

hal_status_t hal_spi_transmit_with_ia ( spi_handle_t p_spi,
uint8_t  inst,
uint32_t  addr,
uint8_t *  p_data,
uint32_t  length,
uint32_t  timeout 
)

Transmit an amount of data in non-blocking mode with polling. Support Setting C&A.

Parameters
[in]p_spiPointer to an SPI handle which contains the configuration information for the specified SPI module.
[in]inst1 byte instruction
[in]addr3 bytes address
[in]p_dataPointer to data buffer
[in]lengthAmount of data to be sent in bytes, ranging between 0 and 4095.
[in]timeoutTimeout duration
Return values
HAL_OKOperation is OK.
HAL_ERRORParameter error or operation not supported.
HAL_BUSYDriver is busy.
HAL_TIMEOUTTimeout occurred.