nRF5 SDK v17.1.0
Enumerations | Functions
TWIM HAL

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

Enumerations

enum  nrf_twim_task_t {
  NRF_TWIM_TASK_STARTRX = offsetof(NRF_TWIM_Type, TASKS_STARTRX),
  NRF_TWIM_TASK_STARTTX = offsetof(NRF_TWIM_Type, TASKS_STARTTX),
  NRF_TWIM_TASK_STOP = offsetof(NRF_TWIM_Type, TASKS_STOP),
  NRF_TWIM_TASK_SUSPEND = offsetof(NRF_TWIM_Type, TASKS_SUSPEND),
  NRF_TWIM_TASK_RESUME = offsetof(NRF_TWIM_Type, TASKS_RESUME)
}
 TWIM tasks. More...
 
enum  nrf_twim_event_t {
  NRF_TWIM_EVENT_STOPPED = offsetof(NRF_TWIM_Type, EVENTS_STOPPED),
  NRF_TWIM_EVENT_ERROR = offsetof(NRF_TWIM_Type, EVENTS_ERROR),
  NRF_TWIM_EVENT_SUSPENDED = 0x148,
  NRF_TWIM_EVENT_RXSTARTED = offsetof(NRF_TWIM_Type, EVENTS_RXSTARTED),
  NRF_TWIM_EVENT_TXSTARTED = offsetof(NRF_TWIM_Type, EVENTS_TXSTARTED),
  NRF_TWIM_EVENT_LASTRX = offsetof(NRF_TWIM_Type, EVENTS_LASTRX),
  NRF_TWIM_EVENT_LASTTX = offsetof(NRF_TWIM_Type, EVENTS_LASTTX)
}
 TWIM events. More...
 
enum  nrf_twim_short_mask_t {
  NRF_TWIM_SHORT_LASTTX_STARTRX_MASK = TWIM_SHORTS_LASTTX_STARTRX_Msk,
  NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK = TWIM_SHORTS_LASTTX_SUSPEND_Msk,
  NRF_TWIM_SHORT_LASTTX_STOP_MASK = TWIM_SHORTS_LASTTX_STOP_Msk,
  NRF_TWIM_SHORT_LASTRX_STARTTX_MASK = TWIM_SHORTS_LASTRX_STARTTX_Msk,
  NRF_TWIM_SHORT_LASTRX_STOP_MASK = TWIM_SHORTS_LASTRX_STOP_Msk,
  NRF_TWIM_ALL_SHORTS_MASK
}
 TWIM shortcuts. More...
 
enum  nrf_twim_int_mask_t {
  NRF_TWIM_INT_STOPPED_MASK = TWIM_INTENSET_STOPPED_Msk,
  NRF_TWIM_INT_ERROR_MASK = TWIM_INTENSET_ERROR_Msk,
  NRF_TWIM_INT_SUSPENDED_MASK = TWIM_INTENSET_SUSPENDED_Msk,
  NRF_TWIM_INT_RXSTARTED_MASK = TWIM_INTENSET_RXSTARTED_Msk,
  NRF_TWIM_INT_TXSTARTED_MASK = TWIM_INTENSET_TXSTARTED_Msk,
  NRF_TWIM_INT_LASTRX_MASK = TWIM_INTENSET_LASTRX_Msk,
  NRF_TWIM_INT_LASTTX_MASK = TWIM_INTENSET_LASTTX_Msk,
  NRF_TWIM_ALL_INTS_MASK
}
 TWIM interrupts. More...
 
enum  nrf_twim_frequency_t {
  NRF_TWIM_FREQ_100K = TWIM_FREQUENCY_FREQUENCY_K100,
  NRF_TWIM_FREQ_250K = TWIM_FREQUENCY_FREQUENCY_K250,
  NRF_TWIM_FREQ_400K = TWIM_FREQUENCY_FREQUENCY_K400
}
 TWIM master clock frequency. More...
 
enum  nrf_twim_error_t {
  NRF_TWIM_ERROR_ADDRESS_NACK = TWIM_ERRORSRC_ANACK_Msk,
  NRF_TWIM_ERROR_DATA_NACK = TWIM_ERRORSRC_DNACK_Msk,
  NRF_TWIM_ERROR_OVERRUN = TWIM_ERRORSRC_OVERRUN_Msk
}
 TWIM error source. More...
 

Functions

__STATIC_INLINE void nrf_twim_task_trigger (NRF_TWIM_Type *p_reg, nrf_twim_task_t task)
 Function for activating the specified TWIM task. More...
 
__STATIC_INLINE uint32_t * nrf_twim_task_address_get (NRF_TWIM_Type *p_reg, nrf_twim_task_t task)
 Function for getting the address of the specified TWIM task register. More...
 
__STATIC_INLINE void nrf_twim_event_clear (NRF_TWIM_Type *p_reg, nrf_twim_event_t event)
 Function for clearing the specified TWIM event. More...
 
__STATIC_INLINE bool nrf_twim_event_check (NRF_TWIM_Type *p_reg, nrf_twim_event_t event)
 Function for retrieving the state of the TWIM event. More...
 
__STATIC_INLINE uint32_t * nrf_twim_event_address_get (NRF_TWIM_Type *p_reg, nrf_twim_event_t event)
 Function for getting the address of the specified TWIM event register. More...
 
__STATIC_INLINE void nrf_twim_shorts_enable (NRF_TWIM_Type *p_reg, uint32_t mask)
 Function for enabling the specified shortcuts. More...
 
__STATIC_INLINE void nrf_twim_shorts_disable (NRF_TWIM_Type *p_reg, uint32_t mask)
 Function for disabling the specified shortcuts. More...
 
__STATIC_INLINE void nrf_twim_int_enable (NRF_TWIM_Type *p_reg, uint32_t mask)
 Function for enabling the specified interrupts. More...
 
__STATIC_INLINE void nrf_twim_int_disable (NRF_TWIM_Type *p_reg, uint32_t mask)
 Function for disabling the specified interrupts. More...
 
__STATIC_INLINE bool nrf_twim_int_enable_check (NRF_TWIM_Type *p_reg, nrf_twim_int_mask_t twim_int)
 Function for checking the state of a given interrupt. More...
 
__STATIC_INLINE void nrf_twim_subscribe_set (NRF_TWIM_Type *p_reg, nrf_twim_task_t task, uint8_t channel)
 Function for setting the subscribe configuration for a given TWIM task. More...
 
__STATIC_INLINE void nrf_twim_subscribe_clear (NRF_TWIM_Type *p_reg, nrf_twim_task_t task)
 Function for clearing the subscribe configuration for a given TWIM task. More...
 
__STATIC_INLINE void nrf_twim_publish_set (NRF_TWIM_Type *p_reg, nrf_twim_event_t event, uint8_t channel)
 Function for setting the publish configuration for a given TWIM event. More...
 
__STATIC_INLINE void nrf_twim_publish_clear (NRF_TWIM_Type *p_reg, nrf_twim_event_t event)
 Function for clearing the publish configuration for a given TWIM event. More...
 
__STATIC_INLINE void nrf_twim_enable (NRF_TWIM_Type *p_reg)
 Function for enabling the TWIM peripheral. More...
 
__STATIC_INLINE void nrf_twim_disable (NRF_TWIM_Type *p_reg)
 Function for disabling the TWIM peripheral. More...
 
__STATIC_INLINE void nrf_twim_pins_set (NRF_TWIM_Type *p_reg, uint32_t scl_pin, uint32_t sda_pin)
 Function for configuring TWI pins. More...
 
__STATIC_INLINE void nrf_twim_frequency_set (NRF_TWIM_Type *p_reg, nrf_twim_frequency_t frequency)
 Function for setting the TWI master clock frequency. More...
 
__STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear (NRF_TWIM_Type *p_reg)
 Function for checking the TWI error source. More...
 
__STATIC_INLINE void nrf_twim_address_set (NRF_TWIM_Type *p_reg, uint8_t address)
 Function for setting the address to be used in TWI transfers. More...
 
__STATIC_INLINE void nrf_twim_tx_buffer_set (NRF_TWIM_Type *p_reg, uint8_t const *p_buffer, size_t length)
 Function for setting the transmit buffer. More...
 
__STATIC_INLINE void nrf_twim_rx_buffer_set (NRF_TWIM_Type *p_reg, uint8_t *p_buffer, size_t length)
 Function for setting the receive buffer. More...
 
__STATIC_INLINE void nrf_twim_shorts_set (NRF_TWIM_Type *p_reg, uint32_t mask)
 Function for setting the specified shortcuts. More...
 
__STATIC_INLINE uint32_t nrf_twim_shorts_get (NRF_TWIM_Type const *p_reg)
 Function for getting the shortcut setting. More...
 
__STATIC_INLINE size_t nrf_twim_txd_amount_get (NRF_TWIM_Type *p_reg)
 Function for getting the amount of transmitted bytes. More...
 
__STATIC_INLINE size_t nrf_twim_rxd_amount_get (NRF_TWIM_Type *p_reg)
 Function for getting the amount of received bytes. More...
 
__STATIC_INLINE void nrf_twim_tx_list_enable (NRF_TWIM_Type *p_reg)
 Function for enabling the TX list feature. More...
 
__STATIC_INLINE void nrf_twim_tx_list_disable (NRF_TWIM_Type *p_reg)
 Function for disabling the TX list feature. More...
 
__STATIC_INLINE void nrf_twim_rx_list_enable (NRF_TWIM_Type *p_reg)
 Function for enabling the RX list feature. More...
 
__STATIC_INLINE void nrf_twim_rx_list_disable (NRF_TWIM_Type *p_reg)
 Function for disabling the RX list feature. More...
 

Detailed Description

Hardware access layer for managing the TWIM peripheral.

Enumeration Type Documentation

TWIM error source.

Enumerator
NRF_TWIM_ERROR_ADDRESS_NACK 

NACK received after sending the address.

NRF_TWIM_ERROR_DATA_NACK 

NACK received after sending a data byte.

NRF_TWIM_ERROR_OVERRUN 

Overrun error.

A new byte was received before the previous byte was handled by peripheral. (previous data is lost).

TWIM events.

Enumerator
NRF_TWIM_EVENT_STOPPED 

TWI stopped.

NRF_TWIM_EVENT_ERROR 

TWI error.

NRF_TWIM_EVENT_SUSPENDED 

TWI suspended.

NRF_TWIM_EVENT_RXSTARTED 

Receive sequence started.

NRF_TWIM_EVENT_TXSTARTED 

Transmit sequence started.

NRF_TWIM_EVENT_LASTRX 

Byte boundary, starting to receive the last byte.

NRF_TWIM_EVENT_LASTTX 

Byte boundary, starting to transmit the last byte.

TWIM master clock frequency.

Enumerator
NRF_TWIM_FREQ_100K 

100 kbps.

NRF_TWIM_FREQ_250K 

250 kbps.

NRF_TWIM_FREQ_400K 

400 kbps.

TWIM interrupts.

Enumerator
NRF_TWIM_INT_STOPPED_MASK 

Interrupt on STOPPED event.

NRF_TWIM_INT_ERROR_MASK 

Interrupt on ERROR event.

NRF_TWIM_INT_SUSPENDED_MASK 

Interrupt on SUSPENDED event.

NRF_TWIM_INT_RXSTARTED_MASK 

Interrupt on RXSTARTED event.

NRF_TWIM_INT_TXSTARTED_MASK 

Interrupt on TXSTARTED event.

NRF_TWIM_INT_LASTRX_MASK 

Interrupt on LASTRX event.

NRF_TWIM_INT_LASTTX_MASK 

Interrupt on LASTTX event.

NRF_TWIM_ALL_INTS_MASK 

All TWIM interrupts.

TWIM shortcuts.

Enumerator
NRF_TWIM_SHORT_LASTTX_STARTRX_MASK 

Shortcut between LASTTX event and STARTRX task.

NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK 

Shortcut between LASTTX event and SUSPEND task.

NRF_TWIM_SHORT_LASTTX_STOP_MASK 

Shortcut between LASTTX event and STOP task.

NRF_TWIM_SHORT_LASTRX_STARTTX_MASK 

Shortcut between LASTRX event and STARTTX task.

NRF_TWIM_SHORT_LASTRX_STOP_MASK 

Shortcut between LASTRX event and STOP task.

NRF_TWIM_ALL_SHORTS_MASK 

All TWIM shortcuts.

TWIM tasks.

Enumerator
NRF_TWIM_TASK_STARTRX 

Start TWI receive sequence.

NRF_TWIM_TASK_STARTTX 

Start TWI transmit sequence.

NRF_TWIM_TASK_STOP 

Stop TWI transaction.

NRF_TWIM_TASK_SUSPEND 

Suspend TWI transaction.

NRF_TWIM_TASK_RESUME 

Resume TWI transaction.

Function Documentation

__STATIC_INLINE void nrf_twim_address_set ( NRF_TWIM_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.
__STATIC_INLINE void nrf_twim_disable ( NRF_TWIM_Type *  p_reg)

Function for disabling the TWIM peripheral.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
__STATIC_INLINE void nrf_twim_enable ( NRF_TWIM_Type *  p_reg)

Function for enabling the TWIM peripheral.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
__STATIC_INLINE uint32_t nrf_twim_errorsrc_get_and_clear ( NRF_TWIM_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.
__STATIC_INLINE uint32_t* nrf_twim_event_address_get ( NRF_TWIM_Type *  p_reg,
nrf_twim_event_t  event 
)

Function for getting the address of the specified TWIM 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.
__STATIC_INLINE bool nrf_twim_event_check ( NRF_TWIM_Type *  p_reg,
nrf_twim_event_t  event 
)

Function for retrieving the state of the TWIM 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.
__STATIC_INLINE void nrf_twim_event_clear ( NRF_TWIM_Type *  p_reg,
nrf_twim_event_t  event 
)

Function for clearing the specified TWIM event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to clear.
__STATIC_INLINE void nrf_twim_frequency_set ( NRF_TWIM_Type *  p_reg,
nrf_twim_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.
__STATIC_INLINE void nrf_twim_int_disable ( NRF_TWIM_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.
__STATIC_INLINE void nrf_twim_int_enable ( NRF_TWIM_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.
__STATIC_INLINE bool nrf_twim_int_enable_check ( NRF_TWIM_Type *  p_reg,
nrf_twim_int_mask_t  twim_int 
)

Function for checking the state of a given interrupt.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]twim_intInterrupt to be checked.
Return values
trueThe interrupt is enabled.
falseThe interrupt is not enabled.
__STATIC_INLINE void nrf_twim_pins_set ( NRF_TWIM_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.
__STATIC_INLINE void nrf_twim_publish_clear ( NRF_TWIM_Type *  p_reg,
nrf_twim_event_t  event 
)

Function for clearing the publish configuration for a given TWIM event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent for which to clear the configuration.
__STATIC_INLINE void nrf_twim_publish_set ( NRF_TWIM_Type *  p_reg,
nrf_twim_event_t  event,
uint8_t  channel 
)

Function for setting the publish configuration for a given TWIM event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent for which to set the configuration.
[in]channelChannel through which to publish the event.
__STATIC_INLINE void nrf_twim_rx_buffer_set ( NRF_TWIM_Type *  p_reg,
uint8_t *  p_buffer,
size_t  length 
)

Function for setting the receive buffer.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]p_bufferPointer to the buffer for received data.
[in]lengthMaximum number of data bytes to receive.
__STATIC_INLINE void nrf_twim_rx_list_disable ( NRF_TWIM_Type *  p_reg)

Function for disabling the RX list feature.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
__STATIC_INLINE void nrf_twim_rx_list_enable ( NRF_TWIM_Type *  p_reg)

Function for enabling the RX list feature.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
__STATIC_INLINE size_t nrf_twim_rxd_amount_get ( NRF_TWIM_Type *  p_reg)

Function for getting the amount of received bytes.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Amount of received bytes.
__STATIC_INLINE void nrf_twim_shorts_disable ( NRF_TWIM_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.
__STATIC_INLINE void nrf_twim_shorts_enable ( NRF_TWIM_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.
__STATIC_INLINE uint32_t nrf_twim_shorts_get ( NRF_TWIM_Type const *  p_reg)

Function for getting the shortcut setting.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Current shortcut configuration.
__STATIC_INLINE void nrf_twim_shorts_set ( NRF_TWIM_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.
__STATIC_INLINE void nrf_twim_subscribe_clear ( NRF_TWIM_Type *  p_reg,
nrf_twim_task_t  task 
)

Function for clearing the subscribe configuration for a given TWIM task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask for which to clear the configuration.
__STATIC_INLINE void nrf_twim_subscribe_set ( NRF_TWIM_Type *  p_reg,
nrf_twim_task_t  task,
uint8_t  channel 
)

Function for setting the subscribe configuration for a given TWIM task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask for which to set the configuration.
[in]channelChannel through which to subscribe events.
__STATIC_INLINE uint32_t* nrf_twim_task_address_get ( NRF_TWIM_Type *  p_reg,
nrf_twim_task_t  task 
)

Function for getting the address of the specified TWIM 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.
__STATIC_INLINE void nrf_twim_task_trigger ( NRF_TWIM_Type *  p_reg,
nrf_twim_task_t  task 
)

Function for activating the specified TWIM task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask to be activated.
__STATIC_INLINE void nrf_twim_tx_buffer_set ( NRF_TWIM_Type *  p_reg,
uint8_t const *  p_buffer,
size_t  length 
)

Function for setting the transmit buffer.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]p_bufferPointer to the buffer with data to send.
[in]lengthMaximum number of data bytes to transmit.
__STATIC_INLINE void nrf_twim_tx_list_disable ( NRF_TWIM_Type *  p_reg)

Function for disabling the TX list feature.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
__STATIC_INLINE void nrf_twim_tx_list_enable ( NRF_TWIM_Type *  p_reg)

Function for enabling the TX list feature.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
__STATIC_INLINE size_t nrf_twim_txd_amount_get ( NRF_TWIM_Type *  p_reg)

Function for getting the amount of transmitted bytes.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Amount of transmitted bytes.

Documentation feedback | Developer Zone | Subscribe | Updated