nRF5 SDK v15.3.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
SPI driver

SPI peripheral driver. More...

Modules

 SPI peripheral driver configuration
 

Data Structures

struct  nrfx_spi_t
 SPI master driver instance data structure. More...
 
struct  nrfx_spi_config_t
 SPI master driver instance configuration structure. More...
 
struct  nrfx_spi_xfer_desc_t
 Single transfer descriptor structure. More...
 
struct  nrfx_spi_evt_t
 

Macros

#define NRFX_SPI_INSTANCE(id)
 Macro for creating an SPI master driver instance. More...
 
#define NRFX_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 NRFX_SPI_DEFAULT_CONFIG
 SPI master instance default configuration. More...
 
#define NRFX_SPI_SINGLE_XFER(p_tx, tx_len, p_rx, rx_len)
 Macro for setting up single transfer descriptor. More...
 
#define NRFX_SPI_XFER_TRX(p_tx_buf, tx_length, p_rx_buf, rx_length)   NRFX_SPI_SINGLE_XFER(p_tx_buf, tx_length, p_rx_buf, rx_length)
 Macro for setting duplex TX RX transfer.
 
#define NRFX_SPI_XFER_TX(p_buf, length)   NRFX_SPI_SINGLE_XFER(p_buf, length, NULL, 0)
 Macro for setting TX transfer.
 
#define NRFX_SPI_XFER_RX(p_buf, length)   NRFX_SPI_SINGLE_XFER(NULL, 0, p_buf, length)
 Macro for setting RX transfer.
 

Typedefs

typedef void(* nrfx_spi_evt_handler_t )(nrfx_spi_evt_t const *p_event, void *p_context)
 SPI master driver event handler type.
 

Enumerations

enum  { NRFX_SPI_ENABLED_COUNT }
 
enum  nrfx_spi_evt_type_t { NRFX_SPI_EVENT_DONE }
 SPI master driver event types, passed to the handler routine provided during initialization. More...
 

Functions

nrfx_err_t nrfx_spi_init (nrfx_spi_t const *const p_instance, nrfx_spi_config_t const *p_config, nrfx_spi_evt_handler_t handler, void *p_context)
 Function for initializing the SPI master driver instance. More...
 
void nrfx_spi_uninit (nrfx_spi_t const *const p_instance)
 Function for uninitializing the SPI master driver instance. More...
 
nrfx_err_t nrfx_spi_xfer (nrfx_spi_t const *const p_instance, nrfx_spi_xfer_desc_t const *p_xfer_desc, uint32_t flags)
 Function for starting the SPI data transfer. More...
 
void nrfx_spi_abort (nrfx_spi_t const *p_instance)
 Function for aborting ongoing transfer. More...
 
void nrfx_spi_0_irq_handler (void)
 
void nrfx_spi_1_irq_handler (void)
 
void nrfx_spi_2_irq_handler (void)
 

Detailed Description

SPI peripheral driver.

Macro Definition Documentation

#define NRFX_SPI_DEFAULT_CONFIG
Value:
{ \
.sck_pin = NRFX_SPI_PIN_NOT_USED, \
.mosi_pin = NRFX_SPI_PIN_NOT_USED, \
.miso_pin = NRFX_SPI_PIN_NOT_USED, \
.ss_pin = NRFX_SPI_PIN_NOT_USED, \
.orc = 0xFF, \
.frequency = NRF_SPI_FREQ_4M, \
.mode = NRF_SPI_MODE_0, \
}

SPI master instance default configuration.

#define NRFX_SPI_INSTANCE (   id)
Value:
{ \
.p_reg = NRFX_CONCAT_2(NRF_SPI, id), \
.drv_inst_idx = NRFX_CONCAT_3(NRFX_SPI, id, _INST_IDX), \
}

Macro for creating an SPI master driver instance.

#define NRFX_SPI_SINGLE_XFER (   p_tx,
  tx_len,
  p_rx,
  rx_len 
)
Value:
{ \
.p_tx_buffer = (uint8_t const *)(p_tx), \
.tx_length = (tx_len), \
.p_rx_buffer = (p_rx), \
.rx_length = (rx_len), \
}

Macro for setting up single transfer descriptor.

This macro is for internal use only.

Enumeration Type Documentation

SPI master driver event types, passed to the handler routine provided during initialization.

Enumerator
NRFX_SPI_EVENT_DONE 

Transfer done.

Function Documentation

void nrfx_spi_abort ( nrfx_spi_t const *  p_instance)

Function for aborting ongoing transfer.

Parameters
[in]p_instancePointer to the driver instance structure.
nrfx_err_t nrfx_spi_init ( nrfx_spi_t const *const  p_instance,
nrfx_spi_config_t const *  p_config,
nrfx_spi_evt_handler_t  handler,
void *  p_context 
)

Function for initializing the SPI master driver instance.

This function configures and enables the specified peripheral.

Parameters
[in]p_instancePointer to the driver instance structure.
[in]p_configPointer to the structure with initial configuration.
handlerEvent handler provided by the user. If NULL, transfers will be performed in blocking mode.
p_contextContext passed to event handler.
Return values
NRFX_SUCCESSIf initialization was successful.
NRFX_ERROR_INVALID_STATEIf the driver was already initialized.
NRFX_ERROR_BUSYIf some other peripheral with the same instance ID is already in use. This is possible only if Peripheral Resource Sharing (PRS) module is enabled.
void nrfx_spi_uninit ( nrfx_spi_t const *const  p_instance)

Function for uninitializing the SPI master driver instance.

Parameters
[in]p_instancePointer to the driver instance structure.
nrfx_err_t nrfx_spi_xfer ( nrfx_spi_t const *const  p_instance,
nrfx_spi_xfer_desc_t const *  p_xfer_desc,
uint32_t  flags 
)

Function for starting the SPI data transfer.

If an event handler was provided in the nrfx_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.

Parameters
p_instancePointer to the driver instance structure.
p_xfer_descPointer to the transfer descriptor.
flagsTransfer options (0 for default settings). Currently, no additional flags are available.
Return values
NRFX_SUCCESSIf the procedure was successful.
NRFX_ERROR_BUSYIf the driver is not ready for a new transfer.
NRFX_ERROR_NOT_SUPPORTEDIf the provided parameters are not supported.

Documentation feedback | Developer Zone | Subscribe | Updated