nrfx 2.5
Macros | Enumerations | Functions
SPI HAL

Hardware access layer for managing the SPI peripheral. More...

Macros

#define NRF_SPI_PIN_NOT_CONNECTED   0xFFFFFFFF
 This value can be used as a parameter for the nrf_spi_pins_set function to specify that a given SPI signal (SCK, MOSI, or MISO) shall not be connected to a physical pin.
 

Enumerations

enum  nrf_spi_event_t { NRF_SPI_EVENT_READY = offsetof(NRF_SPI_Type, EVENTS_READY) }
 SPI events. More...
 
enum  nrf_spi_int_mask_t {
  NRF_SPI_INT_READY_MASK = SPI_INTENSET_READY_Msk,
  NRF_SPI_ALL_INTS_MASK = SPI_INTENSET_READY_Msk
}
 SPI interrupts. More...
 
enum  nrf_spi_frequency_t {
  NRF_SPI_FREQ_125K = SPI_FREQUENCY_FREQUENCY_K125,
  NRF_SPI_FREQ_250K = SPI_FREQUENCY_FREQUENCY_K250,
  NRF_SPI_FREQ_500K = SPI_FREQUENCY_FREQUENCY_K500,
  NRF_SPI_FREQ_1M = SPI_FREQUENCY_FREQUENCY_M1,
  NRF_SPI_FREQ_2M = SPI_FREQUENCY_FREQUENCY_M2,
  NRF_SPI_FREQ_4M = SPI_FREQUENCY_FREQUENCY_M4,
  NRF_SPI_FREQ_8M = (int)SPI_FREQUENCY_FREQUENCY_M8
}
 SPI data rates. More...
 
enum  nrf_spi_mode_t {
  NRF_SPI_MODE_0,
  NRF_SPI_MODE_1,
  NRF_SPI_MODE_2,
  NRF_SPI_MODE_3
}
 SPI modes. More...
 
enum  nrf_spi_bit_order_t {
  NRF_SPI_BIT_ORDER_MSB_FIRST = SPI_CONFIG_ORDER_MsbFirst,
  NRF_SPI_BIT_ORDER_LSB_FIRST = SPI_CONFIG_ORDER_LsbFirst
}
 SPI bit orders. More...
 

Functions

NRF_STATIC_INLINE void nrf_spi_event_clear (NRF_SPI_Type *p_reg, nrf_spi_event_t event)
 Function for clearing the specified SPI event. More...
 
NRF_STATIC_INLINE bool nrf_spi_event_check (NRF_SPI_Type const *p_reg, nrf_spi_event_t event)
 Function for retrieving the state of the SPI event. More...
 
NRF_STATIC_INLINE uint32_t nrf_spi_event_address_get (NRF_SPI_Type const *p_reg, nrf_spi_event_t event)
 Function for getting the address of the specified SPI event register. More...
 
NRF_STATIC_INLINE void nrf_spi_int_enable (NRF_SPI_Type *p_reg, uint32_t mask)
 Function for enabling the specified interrupts. More...
 
NRF_STATIC_INLINE void nrf_spi_int_disable (NRF_SPI_Type *p_reg, uint32_t mask)
 Function for disabling the specified interrupts. More...
 
NRF_STATIC_INLINE uint32_t nrf_spi_int_enable_check (NRF_SPI_Type const *p_reg, uint32_t mask)
 Function for checking if the specified interrupts are enabled. More...
 
NRF_STATIC_INLINE void nrf_spi_enable (NRF_SPI_Type *p_reg)
 Function for enabling the SPI peripheral. More...
 
NRF_STATIC_INLINE void nrf_spi_disable (NRF_SPI_Type *p_reg)
 Function for disabling the SPI peripheral. More...
 
NRF_STATIC_INLINE void nrf_spi_pins_set (NRF_SPI_Type *p_reg, uint32_t sck_pin, uint32_t mosi_pin, uint32_t miso_pin)
 Function for configuring SPI pins. More...
 
NRF_STATIC_INLINE uint32_t nrf_spi_sck_pin_get (NRF_SPI_Type const *p_reg)
 Function for getting the SCK pin selection. More...
 
NRF_STATIC_INLINE uint32_t nrf_spi_mosi_pin_get (NRF_SPI_Type const *p_reg)
 Function for getting the MOSI pin selection. More...
 
NRF_STATIC_INLINE uint32_t nrf_spi_miso_pin_get (NRF_SPI_Type const *p_reg)
 Function for getting the MISO pin selection. More...
 
NRF_STATIC_INLINE void nrf_spi_txd_set (NRF_SPI_Type *p_reg, uint8_t data)
 Function for writing data to the SPI transmitter register. More...
 
NRF_STATIC_INLINE uint8_t nrf_spi_rxd_get (NRF_SPI_Type const *p_reg)
 Function for reading data from the SPI receiver register. More...
 
NRF_STATIC_INLINE void nrf_spi_frequency_set (NRF_SPI_Type *p_reg, nrf_spi_frequency_t frequency)
 Function for setting the SPI master data rate. More...
 
NRF_STATIC_INLINE void nrf_spi_configure (NRF_SPI_Type *p_reg, nrf_spi_mode_t spi_mode, nrf_spi_bit_order_t spi_bit_order)
 Function for setting the SPI configuration. More...
 

Detailed Description

Hardware access layer for managing the SPI peripheral.

Enumeration Type Documentation

◆ nrf_spi_bit_order_t

SPI bit orders.

Enumerator
NRF_SPI_BIT_ORDER_MSB_FIRST 

Most significant bit shifted out first.

NRF_SPI_BIT_ORDER_LSB_FIRST 

Least significant bit shifted out first.

◆ nrf_spi_event_t

SPI events.

Enumerator
NRF_SPI_EVENT_READY 

TXD byte sent and RXD byte received.

◆ nrf_spi_frequency_t

SPI data rates.

Enumerator
NRF_SPI_FREQ_125K 

125 kbps.

NRF_SPI_FREQ_250K 

250 kbps.

NRF_SPI_FREQ_500K 

500 kbps.

NRF_SPI_FREQ_1M 

1 Mbps.

NRF_SPI_FREQ_2M 

2 Mbps.

NRF_SPI_FREQ_4M 

4 Mbps.

NRF_SPI_FREQ_8M 

8 Mbps.

◆ nrf_spi_int_mask_t

SPI interrupts.

Enumerator
NRF_SPI_INT_READY_MASK 

Interrupt on READY event.

NRF_SPI_ALL_INTS_MASK 

All SPI interrupts.

◆ nrf_spi_mode_t

SPI modes.

Enumerator
NRF_SPI_MODE_0 

SCK active high, sample on leading edge of clock.

NRF_SPI_MODE_1 

SCK active high, sample on trailing edge of clock.

NRF_SPI_MODE_2 

SCK active low, sample on leading edge of clock.

NRF_SPI_MODE_3 

SCK active low, sample on trailing edge of clock.

Function Documentation

◆ nrf_spi_configure()

NRF_STATIC_INLINE void nrf_spi_configure ( NRF_SPI_Type *  p_reg,
nrf_spi_mode_t  spi_mode,
nrf_spi_bit_order_t  spi_bit_order 
)

Function for setting the SPI configuration.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]spi_modeSPI mode.
[in]spi_bit_orderSPI bit order.

◆ nrf_spi_disable()

NRF_STATIC_INLINE void nrf_spi_disable ( NRF_SPI_Type *  p_reg)

Function for disabling the SPI peripheral.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_spi_enable()

NRF_STATIC_INLINE void nrf_spi_enable ( NRF_SPI_Type *  p_reg)

Function for enabling the SPI peripheral.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ nrf_spi_event_address_get()

NRF_STATIC_INLINE uint32_t nrf_spi_event_address_get ( NRF_SPI_Type const *  p_reg,
nrf_spi_event_t  event 
)

Function for getting the address of the specified SPI event register.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventThe specified event.
Returns
Address of the specified event register.

◆ nrf_spi_event_check()

NRF_STATIC_INLINE bool nrf_spi_event_check ( NRF_SPI_Type const *  p_reg,
nrf_spi_event_t  event 
)

Function for retrieving the state of the SPI event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to be checked.
Return values
trueThe event has been generated.
falseThe event has not been generated.

◆ nrf_spi_event_clear()

NRF_STATIC_INLINE void nrf_spi_event_clear ( NRF_SPI_Type *  p_reg,
nrf_spi_event_t  event 
)

Function for clearing the specified SPI event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to be cleared.

◆ nrf_spi_frequency_set()

NRF_STATIC_INLINE void nrf_spi_frequency_set ( NRF_SPI_Type *  p_reg,
nrf_spi_frequency_t  frequency 
)

Function for setting the SPI master data rate.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]frequencySPI frequency.

◆ nrf_spi_int_disable()

NRF_STATIC_INLINE void nrf_spi_int_disable ( NRF_SPI_Type *  p_reg,
uint32_t  mask 
)

Function for disabling the specified interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be disabled.

◆ nrf_spi_int_enable()

NRF_STATIC_INLINE void nrf_spi_int_enable ( NRF_SPI_Type *  p_reg,
uint32_t  mask 
)

Function for enabling the specified interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be enabled.

◆ nrf_spi_int_enable_check()

NRF_STATIC_INLINE uint32_t nrf_spi_int_enable_check ( NRF_SPI_Type const *  p_reg,
uint32_t  mask 
)

Function for checking if the specified interrupts are enabled.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be checked.
Returns
Mask of enabled interrupts.

◆ nrf_spi_miso_pin_get()

NRF_STATIC_INLINE uint32_t nrf_spi_miso_pin_get ( NRF_SPI_Type const *  p_reg)

Function for getting the MISO pin selection.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
MISO pin selection;

◆ nrf_spi_mosi_pin_get()

NRF_STATIC_INLINE uint32_t nrf_spi_mosi_pin_get ( NRF_SPI_Type const *  p_reg)

Function for getting the MOSI pin selection.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
MOSI pin selection;

◆ nrf_spi_pins_set()

NRF_STATIC_INLINE void nrf_spi_pins_set ( NRF_SPI_Type *  p_reg,
uint32_t  sck_pin,
uint32_t  mosi_pin,
uint32_t  miso_pin 
)

Function for configuring SPI pins.

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

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]sck_pinSCK pin number.
[in]mosi_pinMOSI pin number.
[in]miso_pinMISO pin number.

◆ nrf_spi_rxd_get()

NRF_STATIC_INLINE uint8_t nrf_spi_rxd_get ( NRF_SPI_Type const *  p_reg)

Function for reading data from the SPI receiver register.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
RX data received.

◆ nrf_spi_sck_pin_get()

NRF_STATIC_INLINE uint32_t nrf_spi_sck_pin_get ( NRF_SPI_Type const *  p_reg)

Function for getting the SCK pin selection.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
SCK pin selection;

◆ nrf_spi_txd_set()

NRF_STATIC_INLINE void nrf_spi_txd_set ( NRF_SPI_Type *  p_reg,
uint8_t  data 
)

Function for writing data to the SPI transmitter register.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]dataTX data to send.

Documentation feedback | Developer Zone | Subscribe | Updated