nrfx 2.5
Enumerations | Functions
TWI HAL

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

Enumerations

enum  nrf_twi_task_t {
  NRF_TWI_TASK_STARTRX = offsetof(NRF_TWI_Type, TASKS_STARTRX),
  NRF_TWI_TASK_STARTTX = offsetof(NRF_TWI_Type, TASKS_STARTTX),
  NRF_TWI_TASK_STOP = offsetof(NRF_TWI_Type, TASKS_STOP),
  NRF_TWI_TASK_SUSPEND = offsetof(NRF_TWI_Type, TASKS_SUSPEND),
  NRF_TWI_TASK_RESUME = offsetof(NRF_TWI_Type, TASKS_RESUME)
}
 TWI tasks. More...
 
enum  nrf_twi_event_t {
  NRF_TWI_EVENT_STOPPED = offsetof(NRF_TWI_Type, EVENTS_STOPPED),
  NRF_TWI_EVENT_RXDREADY = offsetof(NRF_TWI_Type, EVENTS_RXDREADY),
  NRF_TWI_EVENT_TXDSENT = offsetof(NRF_TWI_Type, EVENTS_TXDSENT),
  NRF_TWI_EVENT_ERROR = offsetof(NRF_TWI_Type, EVENTS_ERROR),
  NRF_TWI_EVENT_BB = offsetof(NRF_TWI_Type, EVENTS_BB),
  NRF_TWI_EVENT_SUSPENDED = offsetof(NRF_TWI_Type, EVENTS_SUSPENDED)
}
 TWI events. More...
 
enum  nrf_twi_short_mask_t {
  NRF_TWI_SHORT_BB_SUSPEND_MASK = TWI_SHORTS_BB_SUSPEND_Msk,
  NRF_TWI_SHORT_BB_STOP_MASK = TWI_SHORTS_BB_STOP_Msk,
  NRF_TWI_ALL_SHORTS_MASK
}
 TWI shortcuts. More...
 
enum  nrf_twi_int_mask_t {
  NRF_TWI_INT_STOPPED_MASK = TWI_INTENSET_STOPPED_Msk,
  NRF_TWI_INT_RXDREADY_MASK = TWI_INTENSET_RXDREADY_Msk,
  NRF_TWI_INT_TXDSENT_MASK = TWI_INTENSET_TXDSENT_Msk,
  NRF_TWI_INT_ERROR_MASK = TWI_INTENSET_ERROR_Msk,
  NRF_TWI_INT_BB_MASK = TWI_INTENSET_BB_Msk,
  NRF_TWI_INT_SUSPENDED_MASK = TWI_INTENSET_SUSPENDED_Msk,
  NRF_TWI_ALL_INTS_MASK
}
 TWI interrupts. More...
 
enum  nrf_twi_error_t {
  NRF_TWI_ERROR_ADDRESS_NACK = TWI_ERRORSRC_ANACK_Msk,
  NRF_TWI_ERROR_DATA_NACK = TWI_ERRORSRC_DNACK_Msk,
  NRF_TWI_ERROR_OVERRUN = TWI_ERRORSRC_OVERRUN_Msk
}
 TWI error source. More...
 
enum  nrf_twi_frequency_t {
  NRF_TWI_FREQ_100K = TWI_FREQUENCY_FREQUENCY_K100,
  NRF_TWI_FREQ_250K = TWI_FREQUENCY_FREQUENCY_K250,
  NRF_TWI_FREQ_400K = TWI_FREQUENCY_FREQUENCY_K400
}
 TWI master clock frequency. More...
 

Functions

NRF_STATIC_INLINE void nrf_twi_task_trigger (NRF_TWI_Type *p_reg, nrf_twi_task_t task)
 Function for activating the specified TWI task. More...
 
NRF_STATIC_INLINE uint32_t nrf_twi_task_address_get (NRF_TWI_Type const *p_reg, nrf_twi_task_t task)
 Function for getting the address of the specified TWI task register. More...
 
NRF_STATIC_INLINE void nrf_twi_event_clear (NRF_TWI_Type *p_reg, nrf_twi_event_t event)
 Function for clearing the specified TWI event. More...
 
NRF_STATIC_INLINE bool nrf_twi_event_check (NRF_TWI_Type const *p_reg, nrf_twi_event_t event)
 Function for retrieving the state of the TWI event. More...
 
NRF_STATIC_INLINE uint32_t nrf_twi_event_address_get (NRF_TWI_Type const *p_reg, nrf_twi_event_t event)
 Function for getting the address of the specified TWI event register. More...
 
NRF_STATIC_INLINE void nrf_twi_shorts_enable (NRF_TWI_Type *p_reg, uint32_t mask)
 Function for enabling the specified shortcuts. More...
 
NRF_STATIC_INLINE void nrf_twi_shorts_disable (NRF_TWI_Type *p_reg, uint32_t mask)
 Function for disabling the specified shortcuts. More...
 
NRF_STATIC_INLINE void nrf_twi_int_enable (NRF_TWI_Type *p_reg, uint32_t mask)
 Function for enabling the specified interrupts. More...
 
NRF_STATIC_INLINE void nrf_twi_int_disable (NRF_TWI_Type *p_reg, uint32_t mask)
 Function for disabling the specified interrupts. More...
 
NRF_STATIC_INLINE uint32_t nrf_twi_int_enable_check (NRF_TWI_Type const *p_reg, uint32_t mask)
 Function for checking if the specified interrupts are enabled. More...
 
NRF_STATIC_INLINE void nrf_twi_enable (NRF_TWI_Type *p_reg)
 Function for enabling the TWI peripheral. More...
 
NRF_STATIC_INLINE void nrf_twi_disable (NRF_TWI_Type *p_reg)
 Function for disabling the TWI peripheral. More...
 
NRF_STATIC_INLINE void nrf_twi_pins_set (NRF_TWI_Type *p_reg, uint32_t scl_pin, uint32_t sda_pin)
 Function for configuring TWI pins. More...
 
NRF_STATIC_INLINE uint32_t nrf_twi_scl_pin_get (NRF_TWI_Type const *p_reg)
 Function for retrieving the SCL pin selection. More...
 
NRF_STATIC_INLINE uint32_t nrf_twi_sda_pin_get (NRF_TWI_Type const *p_reg)
 Function for retrieving the SDA pin selection. More...
 
NRF_STATIC_INLINE void nrf_twi_frequency_set (NRF_TWI_Type *p_reg, nrf_twi_frequency_t frequency)
 Function for setting the TWI master clock frequency. More...
 
NRF_STATIC_INLINE uint32_t nrf_twi_errorsrc_get_and_clear (NRF_TWI_Type *p_reg)
 Function for checking the TWI error source. More...
 
NRF_STATIC_INLINE void nrf_twi_address_set (NRF_TWI_Type *p_reg, uint8_t address)
 Function for setting the address to be used in TWI transfers. More...
 
NRF_STATIC_INLINE uint8_t nrf_twi_rxd_get (NRF_TWI_Type const *p_reg)
 Function for reading data received by TWI. More...
 
NRF_STATIC_INLINE void nrf_twi_txd_set (NRF_TWI_Type *p_reg, uint8_t data)
 Function for writing data to be transmitted by TWI. More...
 
NRF_STATIC_INLINE void nrf_twi_shorts_set (NRF_TWI_Type *p_reg, uint32_t mask)
 Function for setting the specified shortcuts. More...
 

Detailed Description

Hardware access layer for managing the TWI peripheral.

Enumeration Type Documentation

◆ nrf_twi_error_t

TWI error source.

Enumerator
NRF_TWI_ERROR_ADDRESS_NACK 

NACK received after sending the address.

NRF_TWI_ERROR_DATA_NACK 

NACK received after sending a data byte.

NRF_TWI_ERROR_OVERRUN 

Overrun error.

A new byte was received before the previous byte was read from the RXD register (previous data is lost).

◆ nrf_twi_event_t

TWI events.

Enumerator
NRF_TWI_EVENT_STOPPED 

TWI stopped.

NRF_TWI_EVENT_RXDREADY 

TWI RXD byte received.

NRF_TWI_EVENT_TXDSENT 

TWI TXD byte sent.

NRF_TWI_EVENT_ERROR 

TWI error.

NRF_TWI_EVENT_BB 

TWI byte boundary, generated before each byte that is sent or received.

NRF_TWI_EVENT_SUSPENDED 

TWI entered the suspended state.

◆ nrf_twi_frequency_t

TWI master clock frequency.

Enumerator
NRF_TWI_FREQ_100K 

100 kbps.

NRF_TWI_FREQ_250K 

250 kbps.

NRF_TWI_FREQ_400K 

400 kbps.

◆ nrf_twi_int_mask_t

TWI interrupts.

Enumerator
NRF_TWI_INT_STOPPED_MASK 

Interrupt on STOPPED event.

NRF_TWI_INT_RXDREADY_MASK 

Interrupt on RXDREADY event.

NRF_TWI_INT_TXDSENT_MASK 

Interrupt on TXDSENT event.

NRF_TWI_INT_ERROR_MASK 

Interrupt on ERROR event.

NRF_TWI_INT_BB_MASK 

Interrupt on BB event.

NRF_TWI_INT_SUSPENDED_MASK 

Interrupt on SUSPENDED event.

NRF_TWI_ALL_INTS_MASK 

All TWI interrupts.

◆ nrf_twi_short_mask_t

TWI shortcuts.

Enumerator
NRF_TWI_SHORT_BB_SUSPEND_MASK 

Shortcut between BB event and SUSPEND task.

NRF_TWI_SHORT_BB_STOP_MASK 

Shortcut between BB event and STOP task.

NRF_TWI_ALL_SHORTS_MASK 

All TWI shortcuts.

◆ nrf_twi_task_t

TWI tasks.

Enumerator
NRF_TWI_TASK_STARTRX 

Start TWI receive sequence.

NRF_TWI_TASK_STARTTX 

Start TWI transmit sequence.

NRF_TWI_TASK_STOP 

Stop TWI transaction.

NRF_TWI_TASK_SUSPEND 

Suspend TWI transaction.

NRF_TWI_TASK_RESUME 

Resume TWI transaction.

Function Documentation

◆ nrf_twi_address_set()

NRF_STATIC_INLINE void nrf_twi_address_set ( NRF_TWI_Type *  p_reg,
uint8_t  address 
)

Function for setting the address to be used in TWI transfers.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]addressAddress to be used in transfers.

◆ nrf_twi_disable()

NRF_STATIC_INLINE void nrf_twi_disable ( NRF_TWI_Type *  p_reg)

Function for disabling the TWI peripheral.

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

◆ nrf_twi_enable()

NRF_STATIC_INLINE void nrf_twi_enable ( NRF_TWI_Type *  p_reg)

Function for enabling the TWI peripheral.

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

◆ nrf_twi_errorsrc_get_and_clear()

NRF_STATIC_INLINE uint32_t nrf_twi_errorsrc_get_and_clear ( NRF_TWI_Type *  p_reg)

Function for checking the TWI error source.

The error flags are cleared after reading.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Mask with error source flags.

◆ nrf_twi_event_address_get()

NRF_STATIC_INLINE uint32_t nrf_twi_event_address_get ( NRF_TWI_Type const *  p_reg,
nrf_twi_event_t  event 
)

Function for getting the address of the specified TWI 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_twi_event_check()

NRF_STATIC_INLINE bool nrf_twi_event_check ( NRF_TWI_Type const *  p_reg,
nrf_twi_event_t  event 
)

Function for retrieving the state of the TWI 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_twi_event_clear()

NRF_STATIC_INLINE void nrf_twi_event_clear ( NRF_TWI_Type *  p_reg,
nrf_twi_event_t  event 
)

Function for clearing the specified TWI event.

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

◆ nrf_twi_frequency_set()

NRF_STATIC_INLINE void nrf_twi_frequency_set ( NRF_TWI_Type *  p_reg,
nrf_twi_frequency_t  frequency 
)

Function for setting the TWI master clock frequency.

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

◆ nrf_twi_int_disable()

NRF_STATIC_INLINE void nrf_twi_int_disable ( NRF_TWI_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_twi_int_enable()

NRF_STATIC_INLINE void nrf_twi_int_enable ( NRF_TWI_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_twi_int_enable_check()

NRF_STATIC_INLINE uint32_t nrf_twi_int_enable_check ( NRF_TWI_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_twi_pins_set()

NRF_STATIC_INLINE void nrf_twi_pins_set ( NRF_TWI_Type *  p_reg,
uint32_t  scl_pin,
uint32_t  sda_pin 
)

Function for configuring TWI pins.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]scl_pinSCL pin number.
[in]sda_pinSDA pin number.

◆ nrf_twi_rxd_get()

NRF_STATIC_INLINE uint8_t nrf_twi_rxd_get ( NRF_TWI_Type const *  p_reg)

Function for reading data received by TWI.

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

◆ nrf_twi_scl_pin_get()

NRF_STATIC_INLINE uint32_t nrf_twi_scl_pin_get ( NRF_TWI_Type const *  p_reg)

Function for retrieving the SCL pin selection.

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

◆ nrf_twi_sda_pin_get()

NRF_STATIC_INLINE uint32_t nrf_twi_sda_pin_get ( NRF_TWI_Type const *  p_reg)

Function for retrieving the SDA pin selection.

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

◆ nrf_twi_shorts_disable()

NRF_STATIC_INLINE void nrf_twi_shorts_disable ( NRF_TWI_Type *  p_reg,
uint32_t  mask 
)

Function for disabling the specified shortcuts.

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

◆ nrf_twi_shorts_enable()

NRF_STATIC_INLINE void nrf_twi_shorts_enable ( NRF_TWI_Type *  p_reg,
uint32_t  mask 
)

Function for enabling the specified shortcuts.

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

◆ nrf_twi_shorts_set()

NRF_STATIC_INLINE void nrf_twi_shorts_set ( NRF_TWI_Type *  p_reg,
uint32_t  mask 
)

Function for setting the specified shortcuts.

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

◆ nrf_twi_task_address_get()

NRF_STATIC_INLINE uint32_t nrf_twi_task_address_get ( NRF_TWI_Type const *  p_reg,
nrf_twi_task_t  task 
)

Function for getting the address of the specified TWI task register.

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

◆ nrf_twi_task_trigger()

NRF_STATIC_INLINE void nrf_twi_task_trigger ( NRF_TWI_Type *  p_reg,
nrf_twi_task_t  task 
)

Function for activating the specified TWI task.

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

◆ nrf_twi_txd_set()

NRF_STATIC_INLINE void nrf_twi_txd_set ( NRF_TWI_Type *  p_reg,
uint8_t  data 
)

Function for writing data to be transmitted by TWI.

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

Documentation feedback | Developer Zone | Subscribe | Updated