TWIM HALY

group nrfy_twim

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

Defines

NRFY_TWIM_HAS_ARRAY_LIST

See also

NRF_TWIM_HAS_ARRAY_LIST Symbol indicating whether EasyDMA array list feature is present.

Functions

NRFY_STATIC_INLINE void nrfy_twim_periph_configure(NRF_TWIM_Type *p_reg, nrfy_twim_config_t const *p_config)

Function for configuring the TWIM.

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_twim_int_init(NRF_TWIM_Type *p_reg, uint32_t mask, uint8_t irq_priority, bool enable)

Function for initializing the specified TWIM 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_twim_int_uninit(NRF_TWIM_Type *p_reg)

Function for uninitializing the TWIM interrupts.

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

NRFY_STATIC_INLINE uint32_t nrfy_twim_events_process(NRF_TWIM_Type *p_reg, uint32_t mask, nrfy_twim_xfer_desc_t const *p_xfer)

Function for processing the specified TWIM 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 buffer associated with the last reception. 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_twim_tx_buffer_set(NRF_TWIM_Type *p_reg, nrfy_twim_xfer_desc_t const *p_xfer)

Function for setting the TWIM transaction buffer.

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

  • p_xfer[in] Pointer to the structure containing transaction buffer.

NRFY_STATIC_INLINE void nrfy_twim_rx_buffer_set(NRF_TWIM_Type *p_reg, nrfy_twim_xfer_desc_t const *p_xfer)

Function for setting the TWIM reception buffer.

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

  • p_xfer[in] Pointer to the structure containing reception buffer.

NRFY_STATIC_INLINE void nrfy_twim_tx_start(NRF_TWIM_Type *p_reg, nrfy_twim_xfer_desc_t const *p_xfer)

Function for starting TWIM transaction.

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

  • p_xfer[in] Pointer to the structure containing transaction buffer.

NRFY_STATIC_INLINE void nrfy_twim_rx_start(NRF_TWIM_Type *p_reg, nrfy_twim_xfer_desc_t const *p_xfer)

Function for starting TWIM reception.

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

  • p_xfer[in] Pointer to the structure containing reception buffer.

NRFY_STATIC_INLINE void nrfy_twim_abort(NRF_TWIM_Type *p_reg, nrfy_twim_xfer_desc_t const *p_xfer)

Function for aborting the ongoing TWIM transaction.

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

  • p_xfer[in] Pointer to the structure containing reception buffer if the abort is to be blocking. NULL for non-blocking operation.

NRFY_STATIC_INLINE void nrfy_twim_pins_get(NRF_TWIM_Type const *p_reg, nrfy_twim_pins_t *p_pins)

Function for getting TWIM 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 TWIM pins configuration.

NRFY_STATIC_INLINE void nrfy_twim_stop(NRF_TWIM_Type *p_reg)

Function for disabling TWIM with all interrupts and shortcuts.

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

NRFY_STATIC_INLINE void nrfy_twim_tx_list_set(NRF_TWIM_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_twim_rx_list_set(NRF_TWIM_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_twim_pins_set(NRF_TWIM_Type *p_reg, nrfy_twim_pins_t const *p_pins)

Function for setting the TWIM pins configuration.

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

  • p_pins[out] Pointer to the TWIM pin configurartion structure.

NRFY_STATIC_INLINE void nrfy_twim_task_trigger(NRF_TWIM_Type *p_reg, nrf_twim_task_t task)

See also

nrf_twim_task_trigger Function for activating the specified TWIM 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_twim_task_address_get(NRF_TWIM_Type const *p_reg, nrf_twim_task_t task)

See also

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

See also

nrf_twim_event_clear Function for clearing the specified TWIM event.

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

  • event[in] Event to clear.

NRFY_STATIC_INLINE bool nrfy_twim_event_check(NRF_TWIM_Type const *p_reg, nrf_twim_event_t event)

See also

nrf_twim_event_check Function for retrieving the state of the TWIM 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_twim_event_address_get(NRF_TWIM_Type const *p_reg, nrf_twim_event_t event)

See also

nrf_twim_event_address_get Function for getting the address of the specified TWIM 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_twim_shorts_enable(NRF_TWIM_Type *p_reg, uint32_t mask)

See also

nrf_twim_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_twim_shorts_disable(NRF_TWIM_Type *p_reg, uint32_t mask)

See also

nrf_twim_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 void nrfy_twim_int_enable(NRF_TWIM_Type *p_reg, uint32_t mask)

See also

nrf_twim_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_twim_int_mask_t values for bit masking.

NRFY_STATIC_INLINE void nrfy_twim_int_disable(NRF_TWIM_Type *p_reg, uint32_t mask)

See also

nrf_twim_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_twim_int_mask_t values for bit masking.

NRFY_STATIC_INLINE uint32_t nrfy_twim_int_enable_check(NRF_TWIM_Type const *p_reg, uint32_t mask)

See also

nrf_twim_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_twim_int_mask_t values for bit masking.

Returns:

Mask of enabled interrupts.

NRFY_STATIC_INLINE void nrfy_twim_subscribe_set(NRF_TWIM_Type *p_reg, nrf_twim_task_t task, uint8_t channel)

See also

nrf_twim_subscribe_set Function for setting the subscribe configuration for a given TWIM 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_twim_subscribe_clear(NRF_TWIM_Type *p_reg, nrf_twim_task_t task)

See also

nrf_twim_subscribe_clear Function for clearing the subscribe configuration for a given TWIM 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_twim_publish_set(NRF_TWIM_Type *p_reg, nrf_twim_event_t event, uint8_t channel)

See also

nrf_twim_publish_set Function for setting the publish configuration for a given TWIM 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_twim_publish_clear(NRF_TWIM_Type *p_reg, nrf_twim_event_t event)

See also

nrf_twim_publish_clear Function for clearing the publish configuration for a given TWIM 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_twim_enable(NRF_TWIM_Type *p_reg)

See also

nrf_twim_enable Function for enabling the TWIM peripheral.

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

NRFY_STATIC_INLINE void nrfy_twim_disable(NRF_TWIM_Type *p_reg)

See also

nrf_twim_disable Function for disabling the TWIM peripheral.

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

NRFY_STATIC_INLINE uint32_t nrfy_twim_scl_pin_get(NRF_TWIM_Type const *p_reg)

See also

nrf_twim_scl_pin_get Function for retrieving the SCL pin selection.

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

Returns:

SCL pin selection.

NRFY_STATIC_INLINE uint32_t nrfy_twim_sda_pin_get(NRF_TWIM_Type const *p_reg)

See also

nrf_twim_sda_pin_get Function for retrieving the SDA pin selection.

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

Returns:

SDA pin selection.

NRFY_STATIC_INLINE void nrfy_twim_frequency_set(NRF_TWIM_Type *p_reg, nrf_twim_frequency_t frequency)

See also

nrf_twim_frequency_set Function for setting the TWI master clock frequency.

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

  • frequency[in] TWI frequency.

NRFY_STATIC_INLINE uint32_t nrfy_twim_errorsrc_get_and_clear(NRF_TWIM_Type *p_reg)

See also

nrf_twim_errorsrc_get_and_clear Function for checking the TWI error source.

The error flags are cleared after reading.

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

Returns:

Mask with error source flags.

NRFY_STATIC_INLINE void nrfy_twim_address_set(NRF_TWIM_Type *p_reg, uint8_t address)

See also

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

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

  • address[in] Address to be used in transfers.

NRFY_STATIC_INLINE void nrfy_twim_shorts_set(NRF_TWIM_Type *p_reg, uint32_t mask)

See also

nrf_twim_shorts_set Function for setting the specified shortcuts.

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

  • mask[in] Shortcuts to be set.

NRFY_STATIC_INLINE uint32_t nrfy_twim_shorts_get(NRF_TWIM_Type const *p_reg)

See also

nrf_twim_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 size_t nrfy_twim_txd_amount_get(NRF_TWIM_Type const *p_reg)

See also

nrf_twim_txd_amount_get Function for getting the amount of transmitted bytes.

Note

In case of NACK error, includes the NACK’ed byte.

Note

Number of bytes are updated after the END event and each MATCH event.

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

Returns:

Amount of transmitted bytes.

NRFY_STATIC_INLINE size_t nrfy_twim_rxd_amount_get(NRF_TWIM_Type const *p_reg)

See also

nrf_twim_rxd_amount_get Function for getting the amount of received bytes in the last transaction.

Note

In case of NACK error, includes the NACK’ed byte.

Note

Number of bytes are updated after the END event and each MATCH event.

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

Returns:

Amount of received bytes.

NRFY_STATIC_INLINE void nrfy_twim_tx_list_enable(NRF_TWIM_Type *p_reg)

See also

nrf_twim_tx_list_enable Function for enabling the TX list feature.

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

NRFY_STATIC_INLINE void nrfy_twim_tx_list_disable(NRF_TWIM_Type *p_reg)

See also

nrf_twim_tx_list_disable Function for disabling the TX list feature.

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

NRFY_STATIC_INLINE void nrfy_twim_rx_list_enable(NRF_TWIM_Type *p_reg)

See also

nrf_twim_rx_list_enable Function for enabling the RX list feature.

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

NRFY_STATIC_INLINE void nrfy_twim_rx_list_disable(NRF_TWIM_Type *p_reg)

See also

nrf_twim_rx_list_disable Function for disabling the RX list feature.

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

struct nrfy_twim_pins_t
#include <nrfy_twim.h>

TWIM pins configuration structure.

Public Members

uint32_t scl_pin

SCL pin number.

uint32_t sda_pin

SDA pin number.

struct nrfy_twim_config_t
#include <nrfy_twim.h>

TWIM configuration structure.

Public Members

nrfy_twim_pins_t pins

TWIM pins configuation.

nrf_twim_frequency_t frequency

TWIM frequency.

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.

struct nrfy_twim_xfer_desc_t
#include <nrfy_twim.h>

Structure describing a TWIM transfer.

Public Members

uint8_t *p_buffer

Pointer to transferred data.

size_t length

Number of bytes transferred.