nrfx 4.5.0
Loading...
Searching...
No Matches
SPIS driver

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

Topics

 SPIS peripheral driver configuration
 

Data Structures

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

Macros

#define NRFX_SPIS_INSTANCE(reg)
 Macro for creating an instance of the SPI slave driver.
 
#define NRFX_SPIS_DEFAULT_CONFIG(_pin_sck, _pin_mosi, _pin_miso, _pin_csn)
 SPIS driver default configuration.
 

Typedefs

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

Enumerations

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

Functions

int nrfx_spis_init (nrfx_spis_t *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.
 
int nrfx_spis_reconfigure (nrfx_spis_t *p_instance, nrfx_spis_config_t const *p_config)
 Function for reconfiguring the SPI slave driver instance.
 
void nrfx_spis_uninit (nrfx_spis_t *p_instance)
 Function for uninitializing the SPI slave driver instance.
 
bool nrfx_spis_init_check (nrfx_spis_t const *p_instance)
 Function for checking if the SPIS driver instance is initialized.
 
int nrfx_spis_buffers_set (nrfx_spis_t *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.
 
void nrfx_spis_irq_handler (nrfx_spis_t *p_instance)
 Driver interrupt handler.
 
void nrfx_spis_nrf52_anomaly_109_init (nrfx_spis_t *p_instance, nrfx_gpiote_t *p_gpiote_inst)
 Function for providing GPIOTE driver instance for the nRF52 Anomaly 109 workaround.
 

Detailed Description

Serial Peripheral Interface Slave with EasyDMA (SPIS) driver.

Macro Definition Documentation

◆ NRFX_SPIS_DEFAULT_CONFIG

#define NRFX_SPIS_DEFAULT_CONFIG ( _pin_sck,
_pin_mosi,
_pin_miso,
_pin_csn )
Value:
{ \
.miso_pin = _pin_miso, \
.mosi_pin = _pin_mosi, \
.sck_pin = _pin_sck, \
.csn_pin = _pin_csn, \
.mode = NRF_SPIS_MODE_0, \
.csn_pullup = NRF_GPIO_PIN_NOPULL, \
.miso_drive = NRF_GPIO_PIN_S0S1, \
.def = 0xFF, \
.orc = 0xFE, \
.skip_gpio_cfg = false, \
.skip_psel_cfg = false, \
}
@ NRF_GPIO_PIN_NOPULL
Pin pull-up resistor disabled.
Definition nrf_gpio.h:235
@ NRF_GPIO_PIN_S0S1
Standard '0', standard '1'.
Definition nrf_gpio.h:244
@ NRF_SPIS_BIT_ORDER_MSB_FIRST
Most significant bit shifted out first.
Definition nrf_spis.h:216
@ NRF_SPIS_MODE_0
SCK active high, sample on leading edge of clock.
Definition nrf_spis.h:207
#define NRFX_SPIS_DEFAULT_CONFIG_IRQ_PRIORITY
Interrupt priority.
Definition nrfx_spis_dox_config.h:30

SPIS driver default configuration.

This configuration sets up SPIS with the following options:

  • mode: 0 (SCK active high, sample on leading edge of the clock signal)
  • MSB shifted out first
  • CSN pull-up disabled
  • MISO pin drive set to standard '0' and standard '1'
  • default character set to 0xFF
  • over-read character set to 0xFE
Parameters
[in]_pin_sckSCK pin.
[in]_pin_mosiMOSI pin.
[in]_pin_misoMISO pin.
[in]_pin_csnCSN pin.

◆ NRFX_SPIS_INSTANCE

#define NRFX_SPIS_INSTANCE ( reg)
Value:
{ \
.p_reg = (NRF_SPIS_Type *)reg, \
.cb = {0}, \
}

Macro for creating an instance of the SPI slave driver.

Typedef Documentation

◆ nrfx_spis_event_handler_t

typedef void(* nrfx_spis_event_handler_t) (nrfx_spis_event_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

◆ nrfx_spis_event_type_t

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_spis_buffers_set()

int nrfx_spis_buffers_set ( nrfx_spis_t * 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_event_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 -EACCES.
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
0The operation was successful.
-EINPROGRESSThe operation failed because the SPI slave device is in an incorrect state.
-EACCESThe provided buffers are not placed in the Data RAM region.
-E2BIGProvided lengths exceed the EasyDMA limits for the peripheral.
-ECANCELEDThe operation failed because of an internal error.

◆ nrfx_spis_init()

int nrfx_spis_init ( nrfx_spis_t * 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 instance provided via nrfx_spis_nrf52_anomaly_109_init 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
0The initialization was successful.
-EALREADYThe driver is already initialized.
-EINVALInvalid parameter is supplied.
-EBUSYSome other peripheral with the same instance ID is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled.
-ECANCELEDGPIOTE channel for detecting falling edges on CSN pin cannot be initialized. Possible only when using nRF52 Anomaly 109 workaround.

◆ nrfx_spis_init_check()

bool nrfx_spis_init_check ( nrfx_spis_t const * p_instance)

Function for checking if the SPIS driver instance is initialized.

Parameters
[in]p_instancePointer to the driver instance structure.
Return values
trueInstance is already initialized.
falseInstance is not initialized.

◆ nrfx_spis_irq_handler()

void nrfx_spis_irq_handler ( nrfx_spis_t * p_instance)

Driver interrupt handler.

Parameters
[in]p_instancePointer to the driver instance structure.

◆ nrfx_spis_nrf52_anomaly_109_init()

void nrfx_spis_nrf52_anomaly_109_init ( nrfx_spis_t * p_instance,
nrfx_gpiote_t * p_gpiote_inst )

Function for providing GPIOTE driver instance for the nRF52 Anomaly 109 workaround.

Warning
Must be called before nrfx_spis_init.
Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_gpiote_instPointer to the GPIOTE driver instance structure.

◆ nrfx_spis_reconfigure()

int nrfx_spis_reconfigure ( nrfx_spis_t * p_instance,
nrfx_spis_config_t const * p_config )

Function for reconfiguring the SPI slave driver instance.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_configPointer to the structure with the configuration.
Return values
0Reconfiguration was successful.
-EBUSYThe driver is during transfer.
-EINPROGRESSThe driver is uninitialized.

◆ nrfx_spis_uninit()

void nrfx_spis_uninit ( nrfx_spis_t * p_instance)

Function for uninitializing the SPI slave driver instance.

Parameters
[in]p_instancePointer to the driver instance structure.