General functions for SPI driver. These functions provide basic functionality on top of SPI hardware registers.
More...
General functions for SPI driver. These functions provide basic functionality on top of SPI hardware registers.
group_spi_data_structures
◆ spi_init()
Initializes the SPI block
- Parameters
-
- Returns
- spi_status_en Status code indicating success or the reason for failure.
- Note
- This function must be called before any other SPI API is used.
◆ spi_deinit()
Deinitializes the SPI block
- Parameters
-
- Returns
- spi_status_en Status code indicating success or the reason for failure.
◆ spi_set_configuration()
Configures the SPI block. This function should only be called when the SPI block is disabled. This function checks each parameter to ensure they are valid, it sets the clock divider to achieve desired SPI clock rate.
- Parameters
-
| id | SPI Instance ID. |
| config | Configuration structure - See spi_config_t for details |
| achieved_clk_rate_khz | Pointer to location to return achieved clock rate in kHz. |
- Returns
- spi_status_en Status code indicating success or the reason for failure.
◆ spi_get_configuration()
Gets current SPI block configuration.
- Parameters
-
| id | SPI Instance ID. |
| config | Configuration structure - See spi_config_t for details |
| achieved_clk_rate_khz | Pointer to location to return achieved clock rate in kHz. |
- Returns
- spi_status_en Status code indicating success or the reason for failure.
◆ spi_enable()
Enables the SPI block. Note that if the SPI block is enabled the configuration can't be changed. First set the configuration and then enable the SPI.
- Parameters
-
- Returns
- spi_status_en Status code indicating success or the reason for failure.
◆ spi_disable()
Disables the SPI block. Note that if the SPI block is enabled the configuration can't be changed. Call this function before changing any configuration settings.
- Parameters
-
- Returns
- spi_status_en Status code indicating success or the reason for failure.
◆ spi_controller_select_peripheral()
Selects which peripheral select to enable during communication. Note that this function is only valid in controller mode, it will be ignored if block is peripheral
- Parameters
-
| id | SPI Instance ID. |
| peripheral_select | Bit mask of peripheral select lines to enable |
- Returns
- spi_status_en Status code indicating success or the reason for failure.