Multi-instance SPI master driver. More...
Data Structures |
|
| struct | nrf_drv_spi_t |
|
SPI master driver instance data structure.
More...
|
|
| struct | nrf_drv_spi_config_t |
|
SPI master driver instance configuration structure.
More...
|
|
Macros |
|
| #define | NRF_DRV_SPI_INSTANCE (id) |
|
Macro for creating an SPI master driver instance.
More...
|
|
| #define | NRF_DRV_SPI_PIN_NOT_USED 0xFF |
|
This value can be provided instead of a pin number for signals MOSI, MISO, and Slave Select to specify that the given signal is not used and therefore does not need to be connected to a pin.
|
|
| #define | NRF_DRV_SPI_DEFAULT_CONFIG (id) |
|
SPI master instance default configuration.
More...
|
|
Typedefs |
|
| typedef void(* | nrf_drv_spi_handler_t )( nrf_drv_spi_event_t event) |
|
SPI master driver event handler type.
|
|
Enumerations |
|
| enum |
nrf_drv_spi_frequency_t
{
NRF_DRV_SPI_FREQ_125K = NRF_SPI_FREQ_125K, NRF_DRV_SPI_FREQ_250K = NRF_SPI_FREQ_250K, NRF_DRV_SPI_FREQ_500K = NRF_SPI_FREQ_500K, NRF_DRV_SPI_FREQ_1M = NRF_SPI_FREQ_1M, NRF_DRV_SPI_FREQ_2M = NRF_SPI_FREQ_2M, NRF_DRV_SPI_FREQ_4M = NRF_SPI_FREQ_4M, NRF_DRV_SPI_FREQ_8M = NRF_SPI_FREQ_8M } |
|
SPI data rates.
More...
|
|
| enum |
nrf_drv_spi_mode_t
{
NRF_DRV_SPI_MODE_0 = NRF_SPI_MODE_0, NRF_DRV_SPI_MODE_1 = NRF_SPI_MODE_1, NRF_DRV_SPI_MODE_2 = NRF_SPI_MODE_2, NRF_DRV_SPI_MODE_3 = NRF_SPI_MODE_3 } |
|
SPI modes.
More...
|
|
| enum |
nrf_drv_spi_bit_order_t
{
NRF_DRV_SPI_BIT_ORDER_MSB_FIRST = NRF_SPI_BIT_ORDER_MSB_FIRST, NRF_DRV_SPI_BIT_ORDER_LSB_FIRST = NRF_SPI_BIT_ORDER_LSB_FIRST } |
|
SPI bit orders.
More...
|
|
| enum | nrf_drv_spi_event_t { NRF_DRV_SPI_EVENT_DONE } |
|
SPI master driver events, passed to the handler routine provided during initialization.
More...
|
|
Functions |
|
| ret_code_t | nrf_drv_spi_init ( nrf_drv_spi_t const *const p_instance, nrf_drv_spi_config_t const *p_config, nrf_drv_spi_handler_t handler) |
|
Function for initializing the SPI master driver instance.
More...
|
|
| void | nrf_drv_spi_uninit ( nrf_drv_spi_t const *const p_instance) |
|
Function for uninitializing the SPI master driver instance.
More...
|
|
| ret_code_t | nrf_drv_spi_transfer ( nrf_drv_spi_t const *const p_instance, uint8_t const *p_tx_buffer, uint8_t tx_buffer_length, uint8_t *p_rx_buffer, uint8_t rx_buffer_length) |
|
Function for starting the SPI data transfer.
More...
|
|
Detailed Description
Multi-instance SPI master driver.
Macro Definition Documentation
| #define NRF_DRV_SPI_DEFAULT_CONFIG | ( | id | ) |
SPI master instance default configuration.
| #define NRF_DRV_SPI_INSTANCE | ( | id | ) |
Macro for creating an SPI master driver instance.
Enumeration Type Documentation
| enum nrf_drv_spi_event_t |
| enum nrf_drv_spi_mode_t |
Function Documentation
| ret_code_t nrf_drv_spi_init | ( | nrf_drv_spi_t const *const | p_instance , |
| nrf_drv_spi_config_t const * | p_config , | ||
| nrf_drv_spi_handler_t | handler | ||
| ) |
Function for initializing the SPI master driver instance.
This function configures and enables the specified peripheral.
- Parameters
-
[in] p_instance Pointer to the instance structure. [in] p_config Pointer to the structure with the initial configuration. If NULL, the default configuration is used. handler Event handler provided by the user. If NULL, transfers will be performed in blocking mode.
- Return values
-
NRF_SUCCESS If initialization was successful. NRF_ERROR_INVALID_STATE If the driver was already initialized.
| ret_code_t nrf_drv_spi_transfer | ( | nrf_drv_spi_t const *const | p_instance , |
| uint8_t const * | p_tx_buffer , | ||
| uint8_t | tx_buffer_length , | ||
| uint8_t * | p_rx_buffer , | ||
| uint8_t | rx_buffer_length | ||
| ) |
Function for starting the SPI data transfer.
If an event handler was provided in the nrf_drv_spi_init call, this function returns immediately and the handler is called when the transfer is done. Otherwise, the transfer is performed in blocking mode, which means that this function returns when the transfer is finished.
- Note
- Peripherals using EasyDMA (for example, SPIM) require the transfer buffers to be placed in the data RAM region. If they are not and an SPIM instance is used, this function will fail with the error code NRF_ERROR_INVALID_ADDR.
- Parameters
-
[in] p_instance Pointer to the instance structure. [in] p_tx_buffer Pointer to the transmit buffer. Can be NULL if there is nothing to send. tx_buffer_length Length of the transmit buffer. [in] p_rx_buffer Pointer to the receive buffer. Can be NULL if there is nothing to receive. rx_buffer_length Length of the receive buffer.
- Return values
-
NRF_SUCCESS If the operation was successful. NRF_ERROR_BUSY If a previously started transfer has not finished yet. NRF_ERROR_INVALID_ADDR If the provided buffers are not placed in the data RAM region.
| void nrf_drv_spi_uninit | ( | nrf_drv_spi_t const *const | p_instance | ) |
Function for uninitializing the SPI master driver instance.
- Parameters
-
[in] p_instance Pointer to the instance structure.