nRF Connect SDK Bare Metal API 2.0.99
Loading...
Searching...
No Matches
SPI transaction manager

SPI controller transaction queue on top of nrfx_spim. More...

Data Structures

struct  bm_spi_mngr_transfer
 SPI transfer descriptor, one segment of a transaction. More...
 
struct  bm_spi_mngr_transaction
 SPI transaction descriptor. More...
 
struct  bm_spi_mngr
 SPI transaction manager instance. More...
 

Macros

#define BM_SPI_MNGR_TRANSFER(_tx_data, _tx_length, _rx_data, _rx_length)
 Macro for creating a simple SPI transfer initializer.
 
#define BM_SPI_MNGR_DEF(_name, _queue_size, _spim_inst)
 Macro for defining an SPI transaction manager instance.
 

Typedefs

typedef void(* bm_spi_mngr_callback_end_t) (int result, void *user_data)
 Transaction end callback.
 
typedef void(* bm_spi_mngr_callback_begin_t) (void *user_data)
 Transaction begin callback, runs from the SPIM event handler context.
 

Functions

int bm_spi_mngr_init (struct bm_spi_mngr *mgr, const nrfx_spim_config_t *default_spim_cfg)
 Initialize the SPI manager and the underlying SPIM driver.
 
int bm_spi_mngr_uninit (struct bm_spi_mngr *mgr)
 Uninitialize the SPI manager and SPIM.
 
int bm_spi_mngr_schedule (struct bm_spi_mngr *mgr, const struct bm_spi_mngr_transaction *transaction)
 Schedule an SPI transaction.
 
bool bm_spi_mngr_is_idle (const struct bm_spi_mngr *mgr)
 Get the current state of an SPI transaction manager instance.
 

Detailed Description

SPI controller transaction queue on top of nrfx_spim.

Transactions wait in a FIFO queue and run one after another on the bus. Each transaction is one or more TX and RX steps in order. You can hook begin_callback and end_callback, and optionally pass a different nrfx_spim_config_t per transaction. That lets you change pins between jobs, for example a different software chip select line. Pins must still be valid for this SPIM instance and on the same GPIO port when your SoC or board wiring requires it.

bm_spi_mngr_schedule adds a transaction. When it finishes, end_callback runs from the SPIM interrupt.

Connect and enable the SPIM interrupt, for example BM_IRQ_DIRECT_CONNECT, before bm_spi_mngr_init.