nRF5 SDK v13.0.0
Macros | Enumerations | Functions

Hardware access layer for accessing 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 }
 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

__STATIC_INLINE void nrf_spi_event_clear (NRF_SPI_Type *p_reg, nrf_spi_event_t spi_event)
 Function for clearing a specific SPI event. More...
 
__STATIC_INLINE bool nrf_spi_event_check (NRF_SPI_Type *p_reg, nrf_spi_event_t spi_event)
 Function for checking the state of a specific SPI event. More...
 
__STATIC_INLINE uint32_t * nrf_spi_event_address_get (NRF_SPI_Type *p_reg, nrf_spi_event_t spi_event)
 Function for getting the address of a specific SPI event register. More...
 
__STATIC_INLINE void nrf_spi_int_enable (NRF_SPI_Type *p_reg, uint32_t spi_int_mask)
 Function for enabling specified interrupts. More...
 
__STATIC_INLINE void nrf_spi_int_disable (NRF_SPI_Type *p_reg, uint32_t spi_int_mask)
 Function for disabling specified interrupts. More...
 
__STATIC_INLINE bool nrf_spi_int_enable_check (NRF_SPI_Type *p_reg, nrf_spi_int_mask_t spi_int)
 Function for retrieving the state of a given interrupt. More...
 
__STATIC_INLINE void nrf_spi_enable (NRF_SPI_Type *p_reg)
 Function for enabling the SPI peripheral. More...
 
__STATIC_INLINE void nrf_spi_disable (NRF_SPI_Type *p_reg)
 Function for disabling the SPI peripheral. More...
 
__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...
 
__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...
 
__STATIC_INLINE uint8_t nrf_spi_rxd_get (NRF_SPI_Type *p_reg)
 Function for reading data from the SPI receiver register. More...
 
__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...
 
__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 accessing the SPI peripheral.

Enumeration Type Documentation

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.

SPI events.

Enumerator
NRF_SPI_EVENT_READY 

TXD byte sent and RXD byte received.

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.

SPI interrupts.

Enumerator
NRF_SPI_INT_READY_MASK 

Interrupt on READY event.

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

__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 peripheral registers structure.
[in]spi_modeSPI mode.
[in]spi_bit_orderSPI bit order.
__STATIC_INLINE void nrf_spi_disable ( NRF_SPI_Type *  p_reg)

Function for disabling the SPI peripheral.

Parameters
[in]p_regPointer to the peripheral registers structure.
__STATIC_INLINE void nrf_spi_enable ( NRF_SPI_Type *  p_reg)

Function for enabling the SPI peripheral.

Parameters
[in]p_regPointer to the peripheral registers structure.
__STATIC_INLINE uint32_t* nrf_spi_event_address_get ( NRF_SPI_Type *  p_reg,
nrf_spi_event_t  spi_event 
)

Function for getting the address of a specific SPI event register.

Parameters
[in]p_regPointer to the peripheral registers structure.
[in]spi_eventRequested event.
Returns
Address of the specified event register.
__STATIC_INLINE bool nrf_spi_event_check ( NRF_SPI_Type *  p_reg,
nrf_spi_event_t  spi_event 
)

Function for checking the state of a specific SPI event.

Parameters
[in]p_regPointer to the peripheral registers structure.
[in]spi_eventEvent to check.
Return values
trueIf the event is set.
falseIf the event is not set.
__STATIC_INLINE void nrf_spi_event_clear ( NRF_SPI_Type *  p_reg,
nrf_spi_event_t  spi_event 
)

Function for clearing a specific SPI event.

Parameters
[in]p_regPointer to the peripheral registers structure.
[in]spi_eventEvent to clear.
__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 peripheral registers structure.
[in]frequencySPI frequency.
__STATIC_INLINE void nrf_spi_int_disable ( NRF_SPI_Type *  p_reg,
uint32_t  spi_int_mask 
)

Function for disabling specified interrupts.

Parameters
[in]p_regPointer to the peripheral registers structure.
[in]spi_int_maskInterrupts to disable.
__STATIC_INLINE void nrf_spi_int_enable ( NRF_SPI_Type *  p_reg,
uint32_t  spi_int_mask 
)

Function for enabling specified interrupts.

Parameters
[in]p_regPointer to the peripheral registers structure.
[in]spi_int_maskInterrupts to enable.
__STATIC_INLINE bool nrf_spi_int_enable_check ( NRF_SPI_Type *  p_reg,
nrf_spi_int_mask_t  spi_int 
)

Function for retrieving the state of a given interrupt.

Parameters
[in]p_regPointer to the peripheral registers structure.
[in]spi_intInterrupt to check.
Return values
trueIf the interrupt is enabled.
falseIf the interrupt is not enabled.
__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 peripheral registers structure.
[in]sck_pinSCK pin number.
[in]mosi_pinMOSI pin number.
[in]miso_pinMISO pin number.
__STATIC_INLINE uint8_t nrf_spi_rxd_get ( NRF_SPI_Type *  p_reg)

Function for reading data from the SPI receiver register.

Parameters
[in]p_regPointer to the peripheral registers structure.
Returns
RX data received.
__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 peripheral registers structure.
[in]dataTX data to send.

Documentation feedback | Developer Zone | Subscribe | Updated