Hardware access layer for managing the TWI peripheral. More...
Macros | |
#define | NRF_TWI_INST_GET(idx) NRFX_CONCAT(NRF_, TWI, idx) |
Macro getting pointer to the structure of registers of the TWI peripheral. | |
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. | |
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. | |
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. | |
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. | |
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. | |
NRF_STATIC_INLINE void | nrf_twi_shorts_enable (NRF_TWI_Type *p_reg, uint32_t mask) |
Function for enabling the specified shortcuts. | |
NRF_STATIC_INLINE void | nrf_twi_shorts_disable (NRF_TWI_Type *p_reg, uint32_t mask) |
Function for disabling the specified shortcuts. | |
NRF_STATIC_INLINE void | nrf_twi_int_enable (NRF_TWI_Type *p_reg, uint32_t mask) |
Function for enabling the specified interrupts. | |
NRF_STATIC_INLINE void | nrf_twi_int_disable (NRF_TWI_Type *p_reg, uint32_t mask) |
Function for disabling the specified interrupts. | |
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. | |
NRF_STATIC_INLINE void | nrf_twi_enable (NRF_TWI_Type *p_reg) |
Function for enabling the TWI peripheral. | |
NRF_STATIC_INLINE void | nrf_twi_disable (NRF_TWI_Type *p_reg) |
Function for disabling the TWI peripheral. | |
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. | |
NRF_STATIC_INLINE uint32_t | nrf_twi_scl_pin_get (NRF_TWI_Type const *p_reg) |
Function for retrieving the SCL pin selection. | |
NRF_STATIC_INLINE uint32_t | nrf_twi_sda_pin_get (NRF_TWI_Type const *p_reg) |
Function for retrieving the SDA pin selection. | |
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. | |
NRF_STATIC_INLINE uint32_t | nrf_twi_errorsrc_get_and_clear (NRF_TWI_Type *p_reg) |
Function for checking the TWI error source. | |
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. | |
NRF_STATIC_INLINE uint8_t | nrf_twi_rxd_get (NRF_TWI_Type const *p_reg) |
Function for reading data received by TWI. | |
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. | |
NRF_STATIC_INLINE void | nrf_twi_shorts_set (NRF_TWI_Type *p_reg, uint32_t mask) |
Function for setting the specified shortcuts. | |
Hardware access layer for managing the TWI peripheral.
#define NRF_TWI_INST_GET | ( | idx | ) | NRFX_CONCAT(NRF_, TWI, idx) |
Macro getting pointer to the structure of registers of the TWI peripheral.
[in] | idx | TWI instance index. |
enum nrf_twi_error_t |
TWI error source.
enum nrf_twi_event_t |
TWI events.
enum nrf_twi_frequency_t |
enum nrf_twi_int_mask_t |
TWI interrupts.
enum nrf_twi_short_mask_t |
enum nrf_twi_task_t |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | address | Address to be used in transfers. |
NRF_STATIC_INLINE void nrf_twi_disable | ( | NRF_TWI_Type * | p_reg | ) |
Function for disabling the TWI peripheral.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE void nrf_twi_enable | ( | NRF_TWI_Type * | p_reg | ) |
Function for enabling the TWI peripheral.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | event | The specified event. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | event | Event to be checked. |
true | The event has been generated. |
false | The event has not been generated. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | event | Event to clear. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | frequency | TWI frequency. |
NRF_STATIC_INLINE void nrf_twi_int_disable | ( | NRF_TWI_Type * | p_reg, |
uint32_t | mask | ||
) |
Function for disabling the specified interrupts.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mask | Mask of interrupts to be disabled. Use nrf_twi_int_mask_t values for bit masking. |
NRF_STATIC_INLINE void nrf_twi_int_enable | ( | NRF_TWI_Type * | p_reg, |
uint32_t | mask | ||
) |
Function for enabling the specified interrupts.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mask | Mask of interrupts to be enabled. Use nrf_twi_int_mask_t values for bit masking. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mask | Mask of interrupts to be checked. Use nrf_twi_int_mask_t values for bit masking. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | scl_pin | SCL pin number. |
[in] | sda_pin | SDA pin number. |
NRF_STATIC_INLINE uint8_t nrf_twi_rxd_get | ( | NRF_TWI_Type const * | p_reg | ) |
Function for reading data received by TWI.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE uint32_t nrf_twi_scl_pin_get | ( | NRF_TWI_Type const * | p_reg | ) |
Function for retrieving the SCL pin selection.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE uint32_t nrf_twi_sda_pin_get | ( | NRF_TWI_Type const * | p_reg | ) |
Function for retrieving the SDA pin selection.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
NRF_STATIC_INLINE void nrf_twi_shorts_disable | ( | NRF_TWI_Type * | p_reg, |
uint32_t | mask | ||
) |
Function for disabling the specified shortcuts.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mask | Shortcuts to be disabled. |
NRF_STATIC_INLINE void nrf_twi_shorts_enable | ( | NRF_TWI_Type * | p_reg, |
uint32_t | mask | ||
) |
Function for enabling the specified shortcuts.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mask | Shortcuts to be enabled. |
NRF_STATIC_INLINE void nrf_twi_shorts_set | ( | NRF_TWI_Type * | p_reg, |
uint32_t | mask | ||
) |
Function for setting the specified shortcuts.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | mask | Shortcuts to be set. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | task | The specified task. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | task | Task to be activated. |
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.
[in] | p_reg | Pointer to the structure of registers of the peripheral. |
[in] | data | Data to be transmitted. |