SPIM HALY

group nrfy_spim

Hardware access layer with cache and barrier support for managing the SPIM peripheral.

Defines

NRFY_SPIM_HAS_HW_CSN

@refhal{NRF_SPIM_HAS_HW_CSN}

NRFY_SPIM_HAS_DCX

@refhal{NRF_SPIM_HAS_DCX}

NRFY_SPIM_HAS_RXDELAY

@refhal{NRF_SPIM_HAS_RXDELAY}

NRFY_SPIM_HAS_STALLSTAT

@refhal{NRF_SPIM_HAS_STALLSTAT}

NRFY_SPIM_HAS_EXTENDED

@refhal{NRF_SPIM_HAS_EXTENDED}

NRFY_SPIM_HAS_ARRAY_LIST

@refhal{NRF_SPIM_HAS_ARRAY_LIST}

NRFY_SPIM_HAS_FREQUENCY

@refhal{NRF_SPIM_HAS_FREQUENCY}

NRFY_SPIM_HAS_PRESCALER

@refhal{NRF_SPIM_HAS_PRESCALER}

Functions

NRFY_STATIC_INLINE void nrfy_spim_periph_configure(NRF_SPIM_Type *p_reg, nrfy_spim_config_t const *p_config)

Function for configuring the SPIM.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_config[in] Pointer to the peripheral configuration structure.

NRFY_STATIC_INLINE void nrfy_spim_int_init(NRF_SPIM_Type *p_reg, uint32_t mask, uint8_t irq_priority, bool enable)

Function for initializing the specified SPIM interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of interrupts to be initialized.

  • irq_priority[in] Interrupt priority.

  • enable[in] True if interrupts associated with the event mask are to be enabled, false otherwise.

NRFY_STATIC_INLINE void nrfy_spim_int_uninit(NRF_SPIM_Type *p_reg)

Function for uninitializing the SPIM interrupts.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

NRFY_STATIC_INLINE uint32_t nrfy_spim_events_process(NRF_SPIM_Type *p_reg, uint32_t mask, nrfy_spim_xfer_desc_t const *p_xfer)

Function for processing the specified SPIM events.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • mask[in] Mask of events to be processed, created by NRFY_EVENT_TO_INT_BITMASK();

  • p_xfer[in] Pointer to the structure containing buffers associated with the last transaction. Can be NULL.

Returns:

Mask of events that were generated and processed. To be checked against the result of NRFY_EVENT_TO_INT_BITMASK().

NRFY_STATIC_INLINE void nrfy_spim_buffers_set(NRF_SPIM_Type *p_reg, nrfy_spim_xfer_desc_t const *p_xfer)

Function for setting the SPIM transaction buffers.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_xfer[in] Pointer to the structure containing transaction buffers.

NRFY_STATIC_INLINE void nrfy_spim_xfer_start(NRF_SPIM_Type *p_reg, nrfy_spim_xfer_desc_t const *p_xfer)

Function for starting the SPIM transaction.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_xfer[in] Pointer to the structure containing transaction buffers if the transaction is to be blocking. NULL for non-blocking transactions.

NRFY_STATIC_INLINE void nrfy_spim_abort(NRF_SPIM_Type *p_reg, nrfy_spim_xfer_desc_t const *p_xfer)

Function for aborting the ongoing SPIM transaction.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_xfer[in] Pointer to the structure containing transaction buffers if the abort is to be blocking. NULL for non-blocking operation.

NRFY_STATIC_INLINE void nrfy_spim_pins_get(NRF_SPIM_Type const *p_reg, nrfy_spim_pins_t *p_pins)

Function for getting the SPIM pins configuration.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_pins[out] Pointer to the structure to be filled with SPIM pins configuration.

NRFY_STATIC_INLINE void nrfy_spim_ext_pins_get(NRF_SPIM_Type const *p_reg, nrfy_spim_ext_pins_t *p_pins)

Function for getting the configuration of the SPIM pins used for extended features.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • p_pins[out] Pointer to the structure to be filled with SPIM pins configuration.

NRFY_STATIC_INLINE void nrfy_spim_tx_list_set(NRF_SPIM_Type *p_reg, bool enable)

Function for enabling or disabling the TX list feature.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • enable[in] True if TX list feature is to be enabled, false otherwise.

NRFY_STATIC_INLINE void nrfy_spim_rx_list_set(NRF_SPIM_Type *p_reg, bool enable)

Function for enabling or disabling the RX list feature.

Parameters:
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • enable[in] True if RX list feature is to be enabled, false otherwise.

NRFY_STATIC_INLINE void nrfy_spim_task_trigger(NRF_SPIM_Type *p_reg, nrf_spim_task_t task)

@refhal{nrf_spim_task_trigger}

NRFY_STATIC_INLINE uint32_t nrfy_spim_task_address_get(NRF_SPIM_Type const *p_reg, nrf_spim_task_t task)

@refhal{nrf_spim_task_address_get}

NRFY_STATIC_INLINE void nrfy_spim_event_clear(NRF_SPIM_Type *p_reg, nrf_spim_event_t event)

@refhal{nrf_spim_event_clear}

NRFY_STATIC_INLINE bool nrfy_spim_event_check(NRF_SPIM_Type const *p_reg, nrf_spim_event_t event)

@refhal{nrf_spim_event_check}

NRFY_STATIC_INLINE uint32_t nrfy_spim_event_address_get(NRF_SPIM_Type const *p_reg, nrf_spim_event_t event)

@refhal{nrf_spim_event_address_get}

NRFY_STATIC_INLINE void nrfy_spim_shorts_enable(NRF_SPIM_Type *p_reg, uint32_t mask)

@refhal{nrf_spim_shorts_enable}

NRFY_STATIC_INLINE void nrfy_spim_shorts_disable(NRF_SPIM_Type *p_reg, uint32_t mask)

@refhal{nrf_spim_shorts_disable}

NRFY_STATIC_INLINE uint32_t nrfy_spim_shorts_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_shorts_get}

NRFY_STATIC_INLINE void nrfy_spim_int_enable(NRF_SPIM_Type *p_reg, uint32_t mask)

@refhal{nrf_spim_int_enable}

NRFY_STATIC_INLINE void nrfy_spim_int_disable(NRF_SPIM_Type *p_reg, uint32_t mask)

@refhal{nrf_spim_int_disable}

NRFY_STATIC_INLINE uint32_t nrfy_spim_int_enable_check(NRF_SPIM_Type const *p_reg, uint32_t mask)

@refhal{nrf_spim_int_enable_check}

NRFY_STATIC_INLINE void nrfy_spim_subscribe_set(NRF_SPIM_Type *p_reg, nrf_spim_task_t task, uint8_t channel)

@refhal{nrf_spim_subscribe_set}

NRFY_STATIC_INLINE void nrfy_spim_subscribe_clear(NRF_SPIM_Type *p_reg, nrf_spim_task_t task)

@refhal{nrf_spim_subscribe_clear}

NRFY_STATIC_INLINE void nrfy_spim_publish_set(NRF_SPIM_Type *p_reg, nrf_spim_event_t event, uint8_t channel)

@refhal{nrf_spim_publish_set}

NRFY_STATIC_INLINE void nrfy_spim_publish_clear(NRF_SPIM_Type *p_reg, nrf_spim_event_t event)

@refhal{nrf_spim_publish_clear}

NRFY_STATIC_INLINE void nrfy_spim_enable(NRF_SPIM_Type *p_reg)

@refhal{nrf_spim_enable}

NRFY_STATIC_INLINE void nrfy_spim_disable(NRF_SPIM_Type *p_reg)

@refhal{nrf_spim_disable}

NRFY_STATIC_INLINE void nrfy_spim_pins_set(NRF_SPIM_Type *p_reg, uint32_t sck_pin, uint32_t mosi_pin, uint32_t miso_pin)

@refhal{nrf_spim_pins_set}

NRFY_STATIC_INLINE uint32_t nrfy_spim_sck_pin_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_sck_pin_get}

NRFY_STATIC_INLINE uint32_t nrfy_spim_mosi_pin_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_mosi_pin_get}

NRFY_STATIC_INLINE uint32_t nrfy_spim_miso_pin_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_miso_pin_get}

NRFY_STATIC_INLINE void nrfy_spim_csn_configure(NRF_SPIM_Type *p_reg, uint32_t pin, nrf_spim_csn_pol_t polarity, uint32_t duration)

@refhal{nrf_spim_csn_configure}

NRFY_STATIC_INLINE uint32_t nrfy_spim_csn_pin_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_csn_pin_get}

NRFY_STATIC_INLINE void nrfy_spim_dcx_pin_set(NRF_SPIM_Type *p_reg, uint32_t dcx_pin)

@refhal{nrf_spim_dcx_pin_set}

NRFY_STATIC_INLINE uint32_t nrfy_spim_dcx_pin_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_dcx_pin_get}

NRFY_STATIC_INLINE void nrfy_spim_dcx_cnt_set(NRF_SPIM_Type *p_reg, uint32_t count)

@refhal{nrf_spim_dcx_cnt_set}

NRFY_STATIC_INLINE void nrfy_spim_iftiming_set(NRF_SPIM_Type *p_reg, uint32_t rxdelay)

@refhal{nrf_spim_iftiming_set}

NRFY_STATIC_INLINE void nrfy_spim_stallstat_rx_clear(NRF_SPIM_Type *p_reg)

@refhal{nrf_spim_stallstat_rx_clear}

NRFY_STATIC_INLINE bool nrfy_spim_stallstat_rx_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_stallstat_rx_get}

NRFY_STATIC_INLINE void nrfy_spim_stallstat_tx_clear(NRF_SPIM_Type *p_reg)

@refhal{nrf_spim_stallstat_tx_clear}

NRFY_STATIC_INLINE bool nrfy_spim_stallstat_tx_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_stallstat_tx_get}

NRFY_STATIC_INLINE void nrfy_spim_frequency_set(NRF_SPIM_Type *p_reg, nrf_spim_frequency_t frequency)

@refhal{nrf_spim_frequency_set}

NRF_STATIC_INLINE void nrfy_spim_prescaler_set(NRF_SPIM_Type *p_reg, uint32_t prescaler)

@refhal{nrf_spim_prescaler_set}

NRF_STATIC_INLINE uint32_t nrfy_spim_prescaler_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_prescaler_get}

NRFY_STATIC_INLINE void nrfy_spim_tx_buffer_set(NRF_SPIM_Type *p_reg, uint8_t const *p_buffer, size_t length)

@refhal{nrf_spim_tx_buffer_set}

NRFY_STATIC_INLINE uint32_t nrfy_spim_tx_amount_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_tx_amount_get}

NRFY_STATIC_INLINE uint32_t nrfy_spim_tx_maxcnt_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_tx_maxcnt_get}

NRFY_STATIC_INLINE void nrfy_spim_rx_buffer_set(NRF_SPIM_Type *p_reg, uint8_t *p_buffer, size_t length)

@refhal{nrf_spim_rx_buffer_set}

NRFY_STATIC_INLINE uint32_t nrfy_spim_rx_amount_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_tx_amount_get}

NRFY_STATIC_INLINE uint32_t nrfy_spim_rx_maxcnt_get(NRF_SPIM_Type const *p_reg)

@refhal{nrf_spim_rx_maxcnt_get}

NRFY_STATIC_INLINE void nrfy_spim_configure(NRF_SPIM_Type *p_reg, nrf_spim_mode_t spi_mode, nrf_spim_bit_order_t spi_bit_order)

@refhal{nrf_spim_configure}

NRFY_STATIC_INLINE void nrfy_spim_orc_set(NRF_SPIM_Type *p_reg, uint8_t orc)

@refhal{nrf_spim_orc_set}

struct nrfy_spim_xfer_desc_t
#include <nrfy_spim.h>

Structure describing single SPIM transfer.

Public Members

uint8_t const *p_tx_buffer

Pointer to the TX data buffer.

size_t tx_length

TX data buffer length.

uint8_t *p_rx_buffer

Pointer to the RX data buffer.

size_t rx_length

RX data buffer length.

struct nrfy_spim_ext_pins_t
#include <nrfy_spim.h>

Configuration structure for SPIM pins used for extended features.

Public Members

uint32_t dcx_pin

D/CX pin number.

Set to NRF_SPIM_PIN_NOT_CONNECTED if this signal is not needed.

uint32_t csn_pin

CSN pin number.

Set to NRF_SPIM_PIN_NOT_CONNECTED if this signal is not needed.

struct nrfy_spim_ext_config_t
#include <nrfy_spim.h>

Configuration structure for SPIM extended features.

Public Members

nrfy_spim_ext_pins_t pins

Pin configuration structure.

nrf_spim_csn_pol_t csn_pol

Polarity of the CSN pin.

uint8_t csn_duration

Minimum duration between the edge of CSN and the edge of SCK.

Also, minimum duration of CSN inactivity between transactions. The value is specified in number of 64 MHz clock cycles (15.625 ns).

uint8_t rx_delay

Sample delay for input serial data on MISO.

This value specifies the delay between the occurrence of the SCK sampling edge and actual sampling operation, expressed in number of 64 MHz clock cycles (15.625 ns).

struct nrfy_spim_pins_t
#include <nrfy_spim.h>

SPIM pins configuration structure.

Public Members

uint32_t sck_pin

SCK pin number.

uint32_t mosi_pin

MOSI pin number.

Set to NRF_SPIM_PIN_NOT_CONNECTED if this signal is not needed.

uint32_t miso_pin

MISO pin number.

Set to NRF_SPIM_PIN_NOT_CONNECTED if this signal is not needed.

struct nrfy_spim_config_t
#include <nrfy_spim.h>

SPIM configuration structure.

Public Members

nrfy_spim_pins_t pins

Pin configuration structure.

uint8_t orc

Overrun character.

This character is transmitted when the TX buffer gets exhausted, but the transaction continues due to RX.

nrf_spim_frequency_t frequency

SPIM frequency.

nrf_spim_mode_t mode

SPIM mode.

nrf_spim_bit_order_t bit_order

SPIM bit order.

nrfy_spim_ext_config_t ext_config

Extended features configuration structure.

Used only if ext_enable is true.

bool ext_enable

True if extended features are to be configured, false otherwise.

bool skip_psel_cfg

Skip pin selection configuration.

When set to true, the driver does not modify pin select registers in the peripheral. Those registers are supposed to be set up externally before the driver is initialized.

Note

When both GPIO configuration and pin selection are to be skipped, the structure fields that specify pins can be omitted, as they are ignored anyway.