SPIM HALY

group nrfy_spim

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

Defines

NRFY_SPIM_HAS_HW_CSN

See also

NRF_SPIM_HAS_HW_CSN Macro for checking if the hardware chip select function is available.

NRFY_SPIM_HAS_DCX

See also

NRF_SPIM_HAS_DCX Macro for checking if the DCX pin control is available.

NRFY_SPIM_HAS_RXDELAY

See also

NRF_SPIM_HAS_RXDELAY Macro for checking if the RXDELAY function is available.

NRFY_SPIM_HAS_STALLSTAT

See also

NRF_SPIM_HAS_STALLSTAT Macro for checking if the STALLSTAT feature is available.

NRFY_SPIM_HAS_EXTENDED

See also

NRF_SPIM_HAS_EXTENDED Symbol indicating whether any of the SPIM extended features is available.

NRFY_SPIM_HAS_ARRAY_LIST

See also

NRF_SPIM_HAS_ARRAY_LIST Symbol indicating whether EasyDMA array list feature is present.

NRFY_SPIM_HAS_FREQUENCY

See also

NRF_SPIM_HAS_FREQUENCY Symbol indicating whether frequency is used.

NRFY_SPIM_HAS_PRESCALER

See also

NRF_SPIM_HAS_PRESCALER Symbol indicating whether prescaler is used.

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)

See also

nrf_spim_task_trigger Function for activating the specified SPIM task.

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

  • task[in] Task to be activated.

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

See also

nrf_spim_task_address_get Function for getting the address of the specified SPIM task register.

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

  • task[in] The specified task.

Returns:

Address of the specified task register.

NRFY_STATIC_INLINE void nrfy_spim_event_clear(NRF_SPIM_Type *p_reg, nrf_spim_event_t event)

See also

nrf_spim_event_clear Function for clearing the specified SPIM event.

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

  • event[in] Event to be cleared.

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

See also

nrf_spim_event_check Function for retrieving the state of the SPIM event.

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

  • event[in] Event to be checked.

Return values:
  • true – The event has been generated.

  • false – The event has not been generated.

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

See also

nrf_spim_event_address_get Function for getting the address of the specified SPIM event register.

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

  • event[in] The specified event.

Returns:

Address of the specified event register.

NRFY_STATIC_INLINE void nrfy_spim_shorts_enable(NRF_SPIM_Type *p_reg, uint32_t mask)

See also

nrf_spim_shorts_enable Function for enabling the specified shortcuts.

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

  • mask[in] Shortcuts to be enabled.

NRFY_STATIC_INLINE void nrfy_spim_shorts_disable(NRF_SPIM_Type *p_reg, uint32_t mask)

See also

nrf_spim_shorts_disable Function for disabling the specified shortcuts.

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

  • mask[in] Shortcuts to be disabled.

NRFY_STATIC_INLINE uint32_t nrfy_spim_shorts_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_shorts_get Function for getting the shortcut setting.

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

Returns:

Current shortcut configuration.

NRFY_STATIC_INLINE void nrfy_spim_int_enable(NRF_SPIM_Type *p_reg, uint32_t mask)

See also

nrf_spim_int_enable Function for enabling the specified interrupts.

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

  • mask[in] Mask of interrupts to be enabled. Use nrf_spim_int_mask_t values for bit masking.

NRFY_STATIC_INLINE void nrfy_spim_int_disable(NRF_SPIM_Type *p_reg, uint32_t mask)

See also

nrf_spim_int_disable Function for disabling the specified interrupts.

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

  • mask[in] Mask of interrupts to be disabled. Use nrf_spim_int_mask_t values for bit masking.

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

See also

nrf_spim_int_enable_check Function for checking if the specified interrupts are enabled.

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

  • mask[in] Mask of interrupts to be checked. Use nrf_spim_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

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

See also

nrf_spim_subscribe_set Function for setting the subscribe configuration for a given SPIM task.

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

  • task[in] Task for which to set the configuration.

  • channel[in] Channel through which to subscribe events.

NRFY_STATIC_INLINE void nrfy_spim_subscribe_clear(NRF_SPIM_Type *p_reg, nrf_spim_task_t task)

See also

nrf_spim_subscribe_clear Function for clearing the subscribe configuration for a given SPIM task.

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

  • task[in] Task for which to clear the configuration.

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

See also

nrf_spim_publish_set Function for setting the publish configuration for a given SPIM event.

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

  • event[in] Event for which to set the configuration.

  • channel[in] Channel through which to publish the event.

NRFY_STATIC_INLINE void nrfy_spim_publish_clear(NRF_SPIM_Type *p_reg, nrf_spim_event_t event)

See also

nrf_spim_publish_clear Function for clearing the publish configuration for a given SPIM event.

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

  • event[in] Event for which to clear the configuration.

NRFY_STATIC_INLINE void nrfy_spim_enable(NRF_SPIM_Type *p_reg)

See also

nrf_spim_enable Function for enabling the SPIM peripheral.

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

NRFY_STATIC_INLINE void nrfy_spim_disable(NRF_SPIM_Type *p_reg)

See also

nrf_spim_disable Function for disabling the SPIM peripheral.

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

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)

See also

nrf_spim_pins_set Function for configuring SPIM pins.

If a given signal is not needed, pass the NRF_SPIM_PIN_NOT_CONNECTED value instead of its pin number.

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

  • sck_pin[in] SCK pin number.

  • mosi_pin[in] MOSI pin number.

  • miso_pin[in] MISO pin number.

NRFY_STATIC_INLINE uint32_t nrfy_spim_sck_pin_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_sck_pin_get Function for getting the SCK pin selection.

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

Returns:

SCK pin selection.

NRFY_STATIC_INLINE uint32_t nrfy_spim_mosi_pin_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_mosi_pin_get Function for getting the MOSI pin selection.

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

Returns:

MOSI pin selection.

NRFY_STATIC_INLINE uint32_t nrfy_spim_miso_pin_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_miso_pin_get Function for getting the MISO pin selection.

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

Returns:

MISO pin selection.

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)

See also

nrf_spim_csn_configure Function for configuring the SPIM hardware CSN pin.

If this signal is not needed, pass the NRF_SPIM_PIN_NOT_CONNECTED value instead of its pin number.

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

  • pin[in] CSN pin number.

  • polarity[in] CSN pin polarity.

  • duration[in] Minimum duration between the edge of CSN and the edge of SCK and minimum duration of CSN must stay unselected between transactions. The value is specified in number of 64 MHz clock cycles (15.625 ns).

NRFY_STATIC_INLINE uint32_t nrfy_spim_csn_pin_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_csn_pin_get Function for getting the CSN pin selection.

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

Returns:

CSN pin selection.

NRFY_STATIC_INLINE void nrfy_spim_dcx_pin_set(NRF_SPIM_Type *p_reg, uint32_t dcx_pin)

See also

nrf_spim_dcx_pin_set Function for configuring the SPIM DCX pin.

If this signal is not needed, pass the NRF_SPIM_PIN_NOT_CONNECTED value instead of its pin number.

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

  • dcx_pin[in] DCX pin number.

NRFY_STATIC_INLINE uint32_t nrfy_spim_dcx_pin_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_dcx_pin_get Function for getting the DCX pin selection.

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

Returns:

DCX pin selection.

NRFY_STATIC_INLINE void nrfy_spim_dcx_cnt_set(NRF_SPIM_Type *p_reg, uint32_t count)

See also

nrf_spim_dcx_cnt_set Function for configuring the number of command bytes.

Maximum value available for dividing the transmitted bytes into command bytes and data bytes is NRF_SPIM_DCX_CNT_ALL_CMD - 1. The NRF_SPIM_DCX_CNT_ALL_CMD value passed as the count parameter causes all transmitted bytes to be marked as command bytes.

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

  • count[in] Number of command bytes preceding the data bytes.

NRFY_STATIC_INLINE void nrfy_spim_iftiming_set(NRF_SPIM_Type *p_reg, uint32_t rxdelay)

See also

nrf_spim_iftiming_set Function for configuring the extended SPIM interface.

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

  • rxdelay[in] Sample delay for input serial data on MISO, specified in 64 MHz clock cycles (15.625 ns) from the sampling edge of SCK.

NRFY_STATIC_INLINE void nrfy_spim_stallstat_rx_clear(NRF_SPIM_Type *p_reg)

See also

nrf_spim_stallstat_rx_clear Function for clearing stall status for RX EasyDMA RAM accesses.

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

NRFY_STATIC_INLINE bool nrfy_spim_stallstat_rx_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_stallstat_rx_get Function for getting stall status for RX EasyDMA RAM accesses.

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

Returns:

Stall status of RX EasyDMA RAM accesses.

NRFY_STATIC_INLINE void nrfy_spim_stallstat_tx_clear(NRF_SPIM_Type *p_reg)

See also

nrf_spim_stallstat_tx_clear Function for clearing stall status for TX EasyDMA RAM accesses.

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

NRFY_STATIC_INLINE bool nrfy_spim_stallstat_tx_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_stallstat_tx_get Function for getting stall status for TX EasyDMA RAM accesses.

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

Returns:

Stall status of TX EasyDMA RAM accesses.

NRFY_STATIC_INLINE void nrfy_spim_frequency_set(NRF_SPIM_Type *p_reg, nrf_spim_frequency_t frequency)

See also

nrf_spim_frequency_set Function for setting the SPI master data rate.

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

  • frequency[in] SPI frequency.

NRFY_STATIC_INLINE void nrfy_spim_prescaler_set(NRF_SPIM_Type *p_reg, uint32_t prescaler)

See also

nrf_spim_prescaler_set Function for setting the prescaler value.

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

  • prescaler[in] Prescaler value.

NRFY_STATIC_INLINE uint32_t nrfy_spim_prescaler_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_prescaler_get Function for getting the prescaler value.

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

Returns:

Prescaler value.

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

See also

nrf_spim_tx_buffer_set Function for setting the transmit buffer.

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

  • p_buffer[in] Pointer to the buffer with data to send.

  • length[in] Maximum number of data bytes to transmit.

NRFY_STATIC_INLINE uint32_t nrfy_spim_tx_amount_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_tx_amount_get Function for getting number of bytes transmitted in the last transaction.

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

Return values:

Amount – of bytes transmitted.

NRFY_STATIC_INLINE uint32_t nrfy_spim_tx_maxcnt_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_tx_maxcnt_get Function for getting number of bytes to be transmitted in the next transaction.

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

Return values:

Amount – of bytes to be transmitted.

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

See also

nrf_spim_rx_buffer_set Function for setting the receive buffer.

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

  • p_buffer[in] Pointer to the buffer for received data.

  • length[in] Maximum number of data bytes to receive.

NRFY_STATIC_INLINE uint32_t nrfy_spim_rx_amount_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_tx_amount_get Function for getting number of bytes transmitted in the last transaction.

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

Return values:

Amount – of bytes transmitted.

NRFY_STATIC_INLINE uint32_t nrfy_spim_rx_maxcnt_get(NRF_SPIM_Type const *p_reg)

See also

nrf_spim_rx_maxcnt_get Function for getting number of bytes to be received in the next transaction.

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

Return values:

Amount – of bytes to be received.

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)

See also

nrf_spim_configure Function for setting the SPI configuration.

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

  • spi_mode[in] SPI mode.

  • spi_bit_order[in] SPI bit order.

NRFY_STATIC_INLINE void nrfy_spim_orc_set(NRF_SPIM_Type *p_reg, uint8_t orc)

See also

nrf_spim_orc_set Function for setting the over-read character.

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

  • orc[in] Over-read character that is clocked out in case of an over-read of the TXD buffer.

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.

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.