nRF5 SDK v17.1.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
SPIS driver

Serial Peripheral Interface Slave with EasyDMA (SPIS) driver. More...

Modules

 SPIS peripheral driver configuration
 

Data Structures

struct  nrfx_spis_t
 Data structure for the Serial Peripheral Interface Slave with EasyDMA (SPIS) driver instance. More...
 
struct  nrfx_spis_evt_t
 SPI slave driver event structure. More...
 
struct  nrfx_spis_config_t
 SPI peripheral device configuration data. More...
 

Macros

#define NRFX_SPIS_INSTANCE(id)
 Macro for creating an instance of the SPI slave driver. More...
 
#define NRFX_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 NRFX_SPIS_DEFAULT_CSN_PULLUP   NRF_GPIO_PIN_NOPULL
 Default pull-up configuration of the SPI CS.
 
#define NRFX_SPIS_DEFAULT_MISO_DRIVE   NRF_GPIO_PIN_S0S1
 Default drive configuration of the SPI MISO.
 
#define NRFX_SPIS_DEFAULT_CONFIG
 The default configuration of the SPI slave instance. More...
 

Typedefs

typedef void(* nrfx_spis_event_handler_t )(nrfx_spis_evt_t const *p_event, void *p_context)
 SPI slave driver event handler type. More...
 

Enumerations

enum  nrfx_spis_evt_type_t {
  NRFX_SPIS_BUFFERS_SET_DONE,
  NRFX_SPIS_XFER_DONE,
  NRFX_SPIS_EVT_TYPE_MAX
}
 SPI slave driver event types. More...
 

Functions

nrfx_err_t nrfx_spis_init (nrfx_spis_t const *const p_instance, nrfx_spis_config_t const *p_config, nrfx_spis_event_handler_t event_handler, void *p_context)
 Function for initializing the SPI slave driver instance. More...
 
void nrfx_spis_uninit (nrfx_spis_t const *const p_instance)
 Function for uninitializing the SPI slave driver instance. More...
 
nrfx_err_t nrfx_spis_buffers_set (nrfx_spis_t const *const p_instance, uint8_t const *p_tx_buffer, size_t tx_buffer_length, uint8_t *p_rx_buffer, size_t rx_buffer_length)
 Function for preparing the SPI slave instance for a single SPI transaction. More...
 

Detailed Description

Serial Peripheral Interface Slave with EasyDMA (SPIS) driver.

Macro Definition Documentation

#define NRFX_SPIS_DEFAULT_CONFIG
Value:

The default configuration of the SPI slave instance.

#define NRFX_SPIS_INSTANCE (   id)
Value:
{ \
.p_reg = NRFX_CONCAT_2(NRF_SPIS, id), \
.drv_inst_idx = NRFX_CONCAT_3(NRFX_SPIS, id, _INST_IDX), \
}

Macro for creating an instance of the SPI slave driver.

Typedef Documentation

typedef void(* nrfx_spis_event_handler_t)(nrfx_spis_evt_t const *p_event, void *p_context)

SPI slave driver event handler type.

Parameters
[in]p_eventPointer to the event structure. The structure is allocated on the stack so it is valid only until the event handler returns.
[in]p_contextContext set on initialization.

Enumeration Type Documentation

SPI slave driver event types.

Enumerator
NRFX_SPIS_BUFFERS_SET_DONE 

Memory buffer set event. Memory buffers have been set successfully to the SPI slave device, and SPI transaction can be done.

NRFX_SPIS_XFER_DONE 

SPI transaction event. SPI transaction has been completed.

NRFX_SPIS_EVT_TYPE_MAX 

Enumeration upper bound.

Function Documentation

nrfx_err_t nrfx_spis_buffers_set ( nrfx_spis_t const *const  p_instance,
uint8_t const *  p_tx_buffer,
size_t  tx_buffer_length,
uint8_t *  p_rx_buffer,
size_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 nrfx_spis_evt_type_t. The callback function can be called before returning from this function, because it is called from the SPI slave interrupt context.

Note
This function can be called from the callback function context.
Client applications must call this function after every NRFX_SPIS_XFER_DONE event if the SPI slave driver must be prepared for a possible new SPI transaction.
Peripherals using EasyDMA (including SPIS) require the transfer buffers to be placed in the Data RAM region. If this condition is not met, this function will fail with the error code NRFX_ERROR_INVALID_ADDR.
Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_tx_bufferPointer to the TX buffer. Can be NULL when the buffer length is zero.
[in]p_rx_bufferPointer to the RX buffer. Can be NULL when the buffer length is zero.
[in]tx_buffer_lengthLength of the TX buffer in bytes.
[in]rx_buffer_lengthLength of the RX buffer in bytes.
Return values
NRFX_SUCCESSThe operation was successful.
NRFX_ERROR_INVALID_STATEThe operation failed because the SPI slave device is in an incorrect state.
NRFX_ERROR_INVALID_ADDRThe provided buffers are not placed in the Data RAM region.
NRFX_ERROR_INVALID_LENGTHProvided lengths exceed the EasyDMA limits for the peripheral.
NRFX_ERROR_INTERNALThe operation failed because of an internal error.
nrfx_err_t nrfx_spis_init ( nrfx_spis_t const *const  p_instance,
nrfx_spis_config_t const *  p_config,
nrfx_spis_event_handler_t  event_handler,
void *  p_context 
)

Function for initializing the SPI slave driver instance.

Note
When the nRF52 Anomaly 109 workaround for SPIS is enabled, this function initializes the GPIOTE driver as well, and uses one of GPIOTE channels to detect falling edges on CSN pin.
Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_configPointer to the structure with the initial configuration.
[in]event_handlerFunction to be called by the SPI slave driver upon event. Must not be NULL.
[in]p_contextContext passed to the event handler.
Return values
NRFX_SUCCESSThe initialization was successful.
NRFX_ERROR_INVALID_STATEThe instance is already initialized.
NRFX_ERROR_INVALID_PARAMInvalid parameter is supplied.
NRFX_ERROR_BUSYSome other peripheral with the same instance ID is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled.
NRFX_ERROR_INTERNALGPIOTE channel for detecting falling edges on CSN pin cannot be initialized. Possible only when using nRF52 Anomaly 109 workaround.
void nrfx_spis_uninit ( nrfx_spis_t const *const  p_instance)

Function for uninitializing the SPI slave driver instance.

Parameters
[in]p_instancePointer to the driver instance structure.

Documentation feedback | Developer Zone | Subscribe | Updated