TWIM HALY

group nrfy_twim

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

Defines

NRFY_TWIM_HAS_ARRAY_LIST

@refhal{NRF_TWIM_HAS_ARRAY_LIST}

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)

@refhal{nrf_twim_task_trigger}

NRFY_STATIC_INLINE uint32_t nrfy_twim_task_address_get(NRF_TWIM_Type const *p_reg, nrf_twim_task_t task)

@refhal{nrf_twim_task_address_get}

NRFY_STATIC_INLINE void nrfy_twim_event_clear(NRF_TWIM_Type *p_reg, nrf_twim_event_t event)

@refhal{nrf_twim_event_clear}

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

@refhal{nrf_twim_event_check}

NRFY_STATIC_INLINE uint32_t nrfy_twim_event_address_get(NRF_TWIM_Type const *p_reg, nrf_twim_event_t event)

@refhal{nrf_twim_event_address_get}

NRFY_STATIC_INLINE void nrfy_twim_shorts_enable(NRF_TWIM_Type *p_reg, uint32_t mask)

@refhal{nrf_twim_shorts_enable}

NRFY_STATIC_INLINE void nrfy_twim_shorts_disable(NRF_TWIM_Type *p_reg, uint32_t mask)

@refhal{nrf_twim_shorts_disable}

NRFY_STATIC_INLINE void nrfy_twim_int_enable(NRF_TWIM_Type *p_reg, uint32_t mask)

@refhal{nrf_twim_int_enable}

NRFY_STATIC_INLINE void nrfy_twim_int_disable(NRF_TWIM_Type *p_reg, uint32_t mask)

@refhal{nrf_twim_int_disable}

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

@refhal{nrf_twim_int_enable_check}

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

@refhal{nrf_twim_subscribe_set}

NRFY_STATIC_INLINE void nrfy_twim_subscribe_clear(NRF_TWIM_Type *p_reg, nrf_twim_task_t task)

@refhal{nrf_twim_subscribe_clear}

NRFY_STATIC_INLINE void nrfy_twim_publish_set(NRF_TWIM_Type *p_reg, nrf_twim_event_t event, uint8_t channel)

@refhal{nrf_twim_publish_set}

NRFY_STATIC_INLINE void nrfy_twim_publish_clear(NRF_TWIM_Type *p_reg, nrf_twim_event_t event)

@refhal{nrf_twim_publish_clear}

NRFY_STATIC_INLINE void nrfy_twim_enable(NRF_TWIM_Type *p_reg)

@refhal{nrf_twim_enable}

NRFY_STATIC_INLINE void nrfy_twim_disable(NRF_TWIM_Type *p_reg)

@refhal{nrf_twim_disable}

NRFY_STATIC_INLINE uint32_t nrfy_twim_scl_pin_get(NRF_TWIM_Type const *p_reg)

@refhal{nrf_twim_scl_pin_get}

NRFY_STATIC_INLINE uint32_t nrfy_twim_sda_pin_get(NRF_TWIM_Type const *p_reg)

@refhal{nrf_twim_sda_pin_get}

NRFY_STATIC_INLINE void nrfy_twim_frequency_set(NRF_TWIM_Type *p_reg, nrf_twim_frequency_t frequency)

@refhal{nrf_twim_frequency_set}

NRFY_STATIC_INLINE uint32_t nrfy_twim_errorsrc_get_and_clear(NRF_TWIM_Type *p_reg)

@refhal{nrf_twim_errorsrc_get_and_clear}

NRFY_STATIC_INLINE void nrfy_twim_address_set(NRF_TWIM_Type *p_reg, uint8_t address)

@refhal{nrf_twim_address_set}

NRFY_STATIC_INLINE void nrfy_twim_shorts_set(NRF_TWIM_Type *p_reg, uint32_t mask)

@refhal{nrf_twim_shorts_set}

NRFY_STATIC_INLINE uint32_t nrfy_twim_shorts_get(NRF_TWIM_Type const *p_reg)

@refhal{nrf_twim_shorts_get}

NRFY_STATIC_INLINE size_t nrfy_twim_txd_amount_get(NRF_TWIM_Type const *p_reg)

@refhal{nrf_twim_txd_amount_get}

NRFY_STATIC_INLINE size_t nrfy_twim_rxd_amount_get(NRF_TWIM_Type const *p_reg)

@refhal{nrf_twim_rxd_amount_get}

NRFY_STATIC_INLINE void nrfy_twim_tx_list_enable(NRF_TWIM_Type *p_reg)

@refhal{nrf_twim_tx_list_enable}

NRFY_STATIC_INLINE void nrfy_twim_tx_list_disable(NRF_TWIM_Type *p_reg)

@refhal{nrf_twim_tx_list_disable}

NRFY_STATIC_INLINE void nrfy_twim_rx_list_enable(NRF_TWIM_Type *p_reg)

@refhal{nrf_twim_rx_list_enable}

NRFY_STATIC_INLINE void nrfy_twim_rx_list_disable(NRF_TWIM_Type *p_reg)

@refhal{nrf_twim_rx_list_disable}

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.