Multi-instance SPI slave driver. More...
Modules | |
SPI Slave driver configuration | |
Data Structures | |
struct | nrf_drv_spis_event_t |
Structure containing the event context from the SPI slave driver. More... | |
struct | nrf_drv_spis_t |
SPI slave driver instance data structure. More... | |
struct | nrf_drv_spis_config_t |
SPI peripheral device configuration data. More... | |
Macros | |
#define | NRF_DRV_SPIS_DEFAULT_CSN_PULLUP NRF_GPIO_PIN_NOPULL |
#define | NRF_DRV_SPIS_DEFAULT_MISO_DRIVE NRF_GPIO_PIN_S0S1 |
#define | NRF_DRV_SPIS_PIN_NOT_USED 0xFF |
This value can be provided instead of a pin number for the signals MOSI and MISO to specify that the given signal is not used and therefore does not need to be connected to a pin. | |
#define | SPIS0_INSTANCE_INDEX 0 |
#define | SPIS1_INSTANCE_INDEX SPIS0_INSTANCE_INDEX+SPIS0_ENABLED |
#define | SPIS2_INSTANCE_INDEX SPIS1_INSTANCE_INDEX+SPIS1_ENABLED |
#define | NRF_DRV_SPIS_INSTANCE(id) |
Macro for creating an SPI slave driver instance. More... | |
#define | NRF_DRV_SPIS_DEFAULT_CONFIG |
SPI slave instance default configuration. More... | |
Typedefs | |
typedef void(* | nrf_drv_spis_event_handler_t )(nrf_drv_spis_event_t event) |
SPI slave event callback function type. More... | |
Enumerations | |
enum | nrf_drv_spis_endian_t { NRF_DRV_SPIS_BIT_ORDER_LSB_FIRST = NRF_SPIS_BIT_ORDER_LSB_FIRST, NRF_DRV_SPIS_BIT_ORDER_MSB_FIRST = NRF_SPIS_BIT_ORDER_MSB_FIRST } |
SPIS transaction bit order definitions. More... | |
enum | nrf_drv_spis_mode_t { NRF_DRV_SPIS_MODE_0 = NRF_SPIS_MODE_0, NRF_DRV_SPIS_MODE_1 = NRF_SPIS_MODE_1, NRF_DRV_SPIS_MODE_2 = NRF_SPIS_MODE_2, NRF_DRV_SPIS_MODE_3 = NRF_SPIS_MODE_3 } |
SPIS mode definitions for clock polarity and phase. More... | |
enum | nrf_drv_spis_event_type_t { NRF_DRV_SPIS_BUFFERS_SET_DONE, NRF_DRV_SPIS_XFER_DONE, NRF_DRV_SPIS_EVT_TYPE_MAX } |
Event callback function event definitions. More... | |
Functions | |
ret_code_t | nrf_drv_spis_init (nrf_drv_spis_t const *const p_instance, nrf_drv_spis_config_t const *p_config, nrf_drv_spis_event_handler_t event_handler) |
Function for initializing the SPI slave driver instance. More... | |
void | nrf_drv_spis_uninit (nrf_drv_spis_t const *const p_instance) |
Function for uninitializing the SPI slave driver instance. More... | |
ret_code_t | nrf_drv_spis_buffers_set (nrf_drv_spis_t const *const p_instance, const uint8_t *p_tx_buffer, uint8_t tx_buffer_length, uint8_t *p_rx_buffer, uint8_t rx_buffer_length) |
Function for preparing the SPI slave instance for a single SPI transaction. More... | |
Multi-instance SPI slave driver.
#define NRF_DRV_SPIS_DEFAULT_CONFIG |
SPI slave instance default configuration.
#define NRF_DRV_SPIS_DEFAULT_CSN_PULLUP NRF_GPIO_PIN_NOPULL |
Default pull-up configuration of the SPI CS.
#define NRF_DRV_SPIS_DEFAULT_MISO_DRIVE NRF_GPIO_PIN_S0S1 |
Default drive configuration of the SPI MISO.
#define NRF_DRV_SPIS_INSTANCE | ( | id | ) |
Macro for creating an SPI slave driver instance.
typedef void(* nrf_drv_spis_event_handler_t)(nrf_drv_spis_event_t event) |
SPI slave event callback function type.
[in] | event | SPI slave driver event. |
Event callback function event definitions.
enum nrf_drv_spis_mode_t |
ret_code_t nrf_drv_spis_buffers_set | ( | nrf_drv_spis_t const *const | p_instance, |
const uint8_t * | p_tx_buffer, | ||
uint8_t | tx_buffer_length, | ||
uint8_t * | p_rx_buffer, | ||
uint8_t | rx_buffer_length | ||
) |
Function for preparing the SPI slave instance for a single SPI transaction.
This function prepares the SPI slave device to be ready for a single SPI transaction. It configures the SPI slave device to use the memory supplied with the function call in SPI transactions.
When either the memory buffer configuration or the SPI transaction has been completed, the event callback function will be called with the appropriate event nrf_drv_spis_event_type_t. Note that the callback function can be called before returning from this function, because it is called from the SPI slave interrupt context.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | p_tx_buffer | Pointer to the TX buffer. |
[in] | p_rx_buffer | Pointer to the RX buffer. |
[in] | tx_buffer_length | Length of the TX buffer in bytes. |
[in] | rx_buffer_length | Length of the RX buffer in bytes. |
NRF_SUCCESS | If the operation was successful. |
NRF_ERROR_NULL | If the operation failed because a NULL pointer was supplied. |
NRF_ERROR_INVALID_STATE | If the operation failed because the SPI slave device is in an incorrect state. |
NRF_ERROR_INVALID_ADDR | If the provided buffers are not placed in the Data RAM region. |
NRF_ERROR_INTERNAL | If the operation failed because of an internal error. |
ret_code_t nrf_drv_spis_init | ( | nrf_drv_spis_t const *const | p_instance, |
nrf_drv_spis_config_t const * | p_config, | ||
nrf_drv_spis_event_handler_t | event_handler | ||
) |
Function for initializing the SPI slave driver instance.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | p_config | Pointer to the structure with the initial configuration. If NULL, the default configuration will be used. |
[in] | event_handler | Function to be called by the SPI slave driver upon event. |
NRF_SUCCESS | If the initialization was successful. |
NRF_ERROR_INVALID_PARAM | If an invalid parameter is supplied. |
NRF_ERROR_BUSY | If some other peripheral with the same instance ID is already in use. This is possible only if PERIPHERAL_RESOURCE_SHARING_ENABLED is set to a value other than zero. |
NRF_ERROR_INTERNAL | GPIOTE channel for detecting falling edges on CSN pin cannot be initialized. Possible only when using nRF52 Anomaly 109 workaround. |
void nrf_drv_spis_uninit | ( | nrf_drv_spis_t const *const | p_instance | ) |
Function for uninitializing the SPI slave driver instance.
[in] | p_instance | Pointer to the driver instance structure. |