Hardware access layer for Two Wire Interface Slave with EasyDMA (TWIS) peripheral. More...
Typedefs | |
typedef uint8_t | nrf_twis_amount_t |
Variable type to hold amount of data for EasyDMA. More... | |
typedef uint8_t | nrf_twis_address_t |
Smallest variable type to hold TWI address. More... | |
Enumerations | |
enum | nrf_twis_task_t { NRF_TWIS_TASK_STOP = offsetof(NRF_TWIS_Type, TASKS_STOP), NRF_TWIS_TASK_SUSPEND = offsetof(NRF_TWIS_Type, TASKS_SUSPEND), NRF_TWIS_TASK_RESUME = offsetof(NRF_TWIS_Type, TASKS_RESUME), NRF_TWIS_TASK_PREPARERX = offsetof(NRF_TWIS_Type, TASKS_PREPARERX), NRF_TWIS_TASK_PREPARETX = offsetof(NRF_TWIS_Type, TASKS_PREPARETX) } |
TWIS tasks. More... | |
enum | nrf_twis_event_t { NRF_TWIS_EVENT_STOPPED = offsetof(NRF_TWIS_Type, EVENTS_STOPPED), NRF_TWIS_EVENT_ERROR = offsetof(NRF_TWIS_Type, EVENTS_ERROR), NRF_TWIS_EVENT_RXSTARTED = offsetof(NRF_TWIS_Type, EVENTS_RXSTARTED), NRF_TWIS_EVENT_TXSTARTED = offsetof(NRF_TWIS_Type, EVENTS_TXSTARTED), NRF_TWIS_EVENT_WRITE = offsetof(NRF_TWIS_Type, EVENTS_WRITE), NRF_TWIS_EVENT_READ = offsetof(NRF_TWIS_Type, EVENTS_READ) } |
TWIS events. More... | |
enum | nrf_twis_short_mask_t { NRF_TWIS_SHORT_WRITE_SUSPEND_MASK = TWIS_SHORTS_WRITE_SUSPEND_Msk, NRF_TWIS_SHORT_READ_SUSPEND_MASK = TWIS_SHORTS_READ_SUSPEND_Msk } |
TWIS shortcuts. More... | |
enum | nrf_twis_int_mask_t { NRF_TWIS_INT_STOPPED_MASK = TWIS_INTEN_STOPPED_Msk, NRF_TWIS_INT_ERROR_MASK = TWIS_INTEN_ERROR_Msk, NRF_TWIS_INT_RXSTARTED_MASK = TWIS_INTEN_RXSTARTED_Msk, NRF_TWIS_INT_TXSTARTED_MASK = TWIS_INTEN_TXSTARTED_Msk, NRF_TWIS_INT_WRITE_MASK = TWIS_INTEN_WRITE_Msk, NRF_TWIS_INT_READ_MASK = TWIS_INTEN_READ_Msk } |
TWIS interrupts. More... | |
enum | nrf_twis_error_t { NRF_TWIS_ERROR_OVERFLOW = TWIS_ERRORSRC_OVERFLOW_Msk, NRF_TWIS_ERROR_DATA_NACK = TWIS_ERRORSRC_DNACK_Msk, NRF_TWIS_ERROR_OVERREAD = TWIS_ERRORSRC_OVERREAD_Msk } |
TWIS error source. More... | |
enum | nrf_twis_config_addr_mask_t { NRF_TWIS_CONFIG_ADDRESS0_MASK = TWIS_CONFIG_ADDRESS0_Msk, NRF_TWIS_CONFIG_ADDRESS1_MASK = TWIS_CONFIG_ADDRESS1_Msk, NRF_TWIS_CONFIG_ADDRESS01_MASK = TWIS_CONFIG_ADDRESS0_Msk | TWIS_CONFIG_ADDRESS1_Msk } |
TWIS address matching configuration. More... | |
Functions | |
__STATIC_INLINE void | nrf_twis_task_trigger (NRF_TWIS_Type *const p_reg, nrf_twis_task_t task) |
Function for activating a specific TWIS task. More... | |
__STATIC_INLINE uint32_t | nrf_twis_task_address_get (NRF_TWIS_Type const *const p_reg, nrf_twis_task_t task) |
Function for returning the address of a specific TWIS task register. More... | |
__STATIC_INLINE void | nrf_twis_event_clear (NRF_TWIS_Type *const p_reg, nrf_twis_event_t event) |
Function for clearing a specific event. More... | |
__STATIC_INLINE bool | nrf_twis_event_check (NRF_TWIS_Type const *const p_reg, nrf_twis_event_t event) |
Function for returning the state of a specific event. More... | |
__STATIC_INLINE bool | nrf_twis_event_get_and_clear (NRF_TWIS_Type *const p_reg, nrf_twis_event_t event) |
Function for getting and clearing the state of specific event. More... | |
__STATIC_INLINE uint32_t | nrf_twis_event_address_get (NRF_TWIS_Type const *const p_reg, nrf_twis_event_t event) |
Function for returning the address of a specific TWIS event register. More... | |
__STATIC_INLINE void | nrf_twis_shorts_enable (NRF_TWIS_Type *const p_reg, uint32_t short_mask) |
Function for setting a shortcut. More... | |
__STATIC_INLINE void | nrf_twis_shorts_disable (NRF_TWIS_Type *const p_reg, uint32_t short_mask) |
Function for clearing shortcuts. More... | |
__STATIC_INLINE uint32_t | nrf_twis_shorts_get (NRF_TWIS_Type *const p_reg) |
Get the shorts mask. More... | |
__STATIC_INLINE void | nrf_twis_int_enable (NRF_TWIS_Type *const p_reg, uint32_t int_mask) |
Function for enabling selected interrupts. More... | |
__STATIC_INLINE bool | nrf_twis_int_enable_check (NRF_TWIS_Type const *const p_reg, uint32_t int_mask) |
Function for retrieving the state of selected interrupts. More... | |
__STATIC_INLINE void | nrf_twis_int_disable (NRF_TWIS_Type *const p_reg, uint32_t int_mask) |
Function for disabling selected interrupts. More... | |
__STATIC_INLINE uint32_t | nrf_twis_error_source_get_and_clear (NRF_TWIS_Type *const p_reg) |
Function for retrieving and clearing the TWIS error source. More... | |
__STATIC_INLINE uint_fast8_t | nrf_twis_match_get (NRF_TWIS_Type const *p_reg) |
Get information which of addresses matched. More... | |
__STATIC_INLINE void | nrf_twis_enable (NRF_TWIS_Type *const p_reg) |
Function for enabling TWIS. More... | |
__STATIC_INLINE void | nrf_twis_disable (NRF_TWIS_Type *const p_reg) |
Function for disabling TWIS. More... | |
__STATIC_INLINE void | nrf_twis_pins_set (NRF_TWIS_Type *const p_reg, uint32_t scl, uint32_t sda) |
Function for configuring TWIS pins. More... | |
__STATIC_INLINE void | nrf_twis_rx_buffer_set (NRF_TWIS_Type *const p_reg, uint8_t *p_buf, nrf_twis_amount_t length) |
Function for setting the receive buffer. More... | |
__STATIC_INLINE void | nrf_twis_rx_prepare (NRF_TWIS_Type *const p_reg, uint8_t *p_buf, nrf_twis_amount_t length) |
Function that prepares TWIS for receiving. More... | |
__STATIC_INLINE nrf_twis_amount_t | nrf_twis_rx_amount_get (NRF_TWIS_Type const *const p_reg) |
Function for getting number of bytes received in the last transaction. More... | |
__STATIC_INLINE void | nrf_twis_tx_buffer_set (NRF_TWIS_Type *const p_reg, uint8_t const *p_buf, nrf_twis_amount_t length) |
Function for setting the transmit buffer. More... | |
__STATIC_INLINE void | nrf_twis_tx_prepare (NRF_TWIS_Type *const p_reg, uint8_t const *p_buf, nrf_twis_amount_t length) |
Function that prepares TWIS for transmitting. More... | |
__STATIC_INLINE nrf_twis_amount_t | nrf_twis_tx_amount_get (NRF_TWIS_Type const *const p_reg) |
Function for getting number of bytes transmitted in the last transaction. More... | |
__STATIC_INLINE void | nrf_twis_address_set (NRF_TWIS_Type *const p_reg, uint_fast8_t n, nrf_twis_address_t addr) |
Function for setting slave address. More... | |
__STATIC_INLINE nrf_twis_address_t | nrf_twis_address_get (NRF_TWIS_Type const *const p_reg, uint_fast8_t n) |
Function for retrieving configured slave address. More... | |
__STATIC_INLINE void | nrf_twis_config_address_set (NRF_TWIS_Type *const p_reg, nrf_twis_config_addr_mask_t addr_mask) |
Function for setting the device address configuration. More... | |
__STATIC_INLINE nrf_twis_config_addr_mask_t | nrf_twis_config_address_get (NRF_TWIS_Type const *const p_reg) |
Function for retrieving the device address configuration. More... | |
__STATIC_INLINE void | nrf_twis_orc_set (NRF_TWIS_Type *const p_reg, uint8_t orc) |
Function for setting the over-read character. More... | |
__STATIC_INLINE uint8_t | nrf_twis_orc_get (NRF_TWIS_Type const *const p_reg) |
Function for setting the over-read character. More... | |
Hardware access layer for Two Wire Interface Slave with EasyDMA (TWIS) peripheral.
typedef uint8_t nrf_twis_address_t |
Smallest variable type to hold TWI address.
Variable of the minimum size that can hold single TWI address.
typedef uint8_t nrf_twis_amount_t |
Variable type to hold amount of data for EasyDMA.
Variable of the minimum size that can hold the amount of data to transfer.
enum nrf_twis_error_t |
enum nrf_twis_event_t |
enum nrf_twis_int_mask_t |
TWIS interrupts.
enum nrf_twis_task_t |
TWIS tasks.
__STATIC_INLINE nrf_twis_address_t nrf_twis_address_get | ( | NRF_TWIS_Type const *const | p_reg, |
uint_fast8_t | n | ||
) |
Function for retrieving configured slave address.
Function gets the selected address for this TWI interface.
[in] | p_reg | Pointer to the peripheral registers structure. |
n | Index of address to get |
__STATIC_INLINE void nrf_twis_address_set | ( | NRF_TWIS_Type *const | p_reg, |
uint_fast8_t | n, | ||
nrf_twis_address_t | addr | ||
) |
Function for setting slave address.
Function sets the selected address for this TWI interface.
[in] | p_reg | Pointer to the peripheral registers structure. |
n | Index of address to set | |
addr | Addres to set |
__STATIC_INLINE nrf_twis_config_addr_mask_t nrf_twis_config_address_get | ( | NRF_TWIS_Type const *const | p_reg | ) |
Function for retrieving the device address configuration.
[in] | p_reg | Pointer to the peripheral registers structure. |
__STATIC_INLINE void nrf_twis_config_address_set | ( | NRF_TWIS_Type *const | p_reg, |
nrf_twis_config_addr_mask_t | addr_mask | ||
) |
Function for setting the device address configuration.
[in] | p_reg | Pointer to the peripheral registers structure. |
addr_mask | Mask of address indexes of what device should answer to. |
__STATIC_INLINE void nrf_twis_disable | ( | NRF_TWIS_Type *const | p_reg | ) |
Function for disabling TWIS.
[in] | p_reg | Pointer to the peripheral registers structure. |
__STATIC_INLINE void nrf_twis_enable | ( | NRF_TWIS_Type *const | p_reg | ) |
Function for enabling TWIS.
[in] | p_reg | Pointer to the peripheral registers structure. |
__STATIC_INLINE uint32_t nrf_twis_error_source_get_and_clear | ( | NRF_TWIS_Type *const | p_reg | ) |
Function for retrieving and clearing the TWIS error source.
[in] | p_reg | Pointer to the peripheral registers structure. |
__STATIC_INLINE uint32_t nrf_twis_event_address_get | ( | NRF_TWIS_Type const *const | p_reg, |
nrf_twis_event_t | event | ||
) |
Function for returning the address of a specific TWIS event register.
[in] | p_reg | Pointer to the peripheral registers structure. |
event | Event. |
__STATIC_INLINE bool nrf_twis_event_check | ( | NRF_TWIS_Type const *const | p_reg, |
nrf_twis_event_t | event | ||
) |
Function for returning the state of a specific event.
[in] | p_reg | Pointer to the peripheral registers structure. |
event | Event. |
true | If the event is set. |
false | If the event is not set. |
__STATIC_INLINE void nrf_twis_event_clear | ( | NRF_TWIS_Type *const | p_reg, |
nrf_twis_event_t | event | ||
) |
Function for clearing a specific event.
[in] | p_reg | Pointer to the peripheral registers structure. |
event | Event. |
__STATIC_INLINE bool nrf_twis_event_get_and_clear | ( | NRF_TWIS_Type *const | p_reg, |
nrf_twis_event_t | event | ||
) |
Function for getting and clearing the state of specific event.
This function checks the state of the event and clears it.
[in,out] | p_reg | Pointer to the peripheral registers structure. |
event | Event. |
true | If the event was set. |
false | If the event was not set. |
__STATIC_INLINE void nrf_twis_int_disable | ( | NRF_TWIS_Type *const | p_reg, |
uint32_t | int_mask | ||
) |
Function for disabling selected interrupts.
[in] | p_reg | Pointer to the peripheral registers structure. |
int_mask | Interrupts mask. |
__STATIC_INLINE void nrf_twis_int_enable | ( | NRF_TWIS_Type *const | p_reg, |
uint32_t | int_mask | ||
) |
Function for enabling selected interrupts.
[in] | p_reg | Pointer to the peripheral registers structure. |
int_mask | Interrupts mask. |
__STATIC_INLINE bool nrf_twis_int_enable_check | ( | NRF_TWIS_Type const *const | p_reg, |
uint32_t | int_mask | ||
) |
Function for retrieving the state of selected interrupts.
[in] | p_reg | Pointer to the peripheral registers structure. |
int_mask | Interrupts mask. |
true | If any of selected interrupts is enabled. |
false | If none of selected interrupts is enabled. |
__STATIC_INLINE uint_fast8_t nrf_twis_match_get | ( | NRF_TWIS_Type const * | p_reg | ) |
Get information which of addresses matched.
Function returns index in the address table that points to the address that already matched.
[in] | p_reg | Pointer to the peripheral registers structure. |
__STATIC_INLINE uint8_t nrf_twis_orc_get | ( | NRF_TWIS_Type const *const | p_reg | ) |
Function for setting the over-read character.
[in] | p_reg | Pointer to the peripheral registers structure. |
__STATIC_INLINE void nrf_twis_orc_set | ( | NRF_TWIS_Type *const | p_reg, |
uint8_t | orc | ||
) |
Function for setting the over-read character.
[in] | p_reg | Pointer to the peripheral registers structure. |
[in] | orc | Over-read character. Character clocked out in case of over-read of the TXD buffer. |
__STATIC_INLINE void nrf_twis_pins_set | ( | NRF_TWIS_Type *const | p_reg, |
uint32_t | scl, | ||
uint32_t | sda | ||
) |
Function for configuring TWIS pins.
[in] | p_reg | Pointer to the peripheral registers structure. |
scl | SCL pin number. | |
sda | SDA pin number. |
__STATIC_INLINE nrf_twis_amount_t nrf_twis_rx_amount_get | ( | NRF_TWIS_Type const *const | p_reg | ) |
Function for getting number of bytes received in the last transaction.
[in] | p_reg | TWIS instance. |
__STATIC_INLINE void nrf_twis_rx_buffer_set | ( | NRF_TWIS_Type *const | p_reg, |
uint8_t * | p_buf, | ||
nrf_twis_amount_t | length | ||
) |
Function for setting the receive buffer.
[in] | p_reg | Pointer to the peripheral registers structure. |
p_buf | Pointer to the buffer for received data. | |
length | Maximum number of data bytes to receive. |
__STATIC_INLINE void nrf_twis_rx_prepare | ( | NRF_TWIS_Type *const | p_reg, |
uint8_t * | p_buf, | ||
nrf_twis_amount_t | length | ||
) |
Function that prepares TWIS for receiving.
This function sets receive buffer and then sets NRF_TWIS_TASK_PREPARERX task.
[in] | p_reg | Pointer to the peripheral registers structure. |
p_buf | Pointer to the buffer for received data. | |
length | Maximum number of data bytes to receive. |
__STATIC_INLINE void nrf_twis_shorts_disable | ( | NRF_TWIS_Type *const | p_reg, |
uint32_t | short_mask | ||
) |
Function for clearing shortcuts.
[in] | p_reg | Pointer to the peripheral registers structure. |
short_mask | Shortcuts mask. |
__STATIC_INLINE void nrf_twis_shorts_enable | ( | NRF_TWIS_Type *const | p_reg, |
uint32_t | short_mask | ||
) |
Function for setting a shortcut.
[in] | p_reg | Pointer to the peripheral registers structure. |
short_mask | Shortcuts mask. |
__STATIC_INLINE uint32_t nrf_twis_shorts_get | ( | NRF_TWIS_Type *const | p_reg | ) |
Get the shorts mask.
Function returns shorts register.
[in] | p_reg | Pointer to the peripheral registers structure. |
__STATIC_INLINE uint32_t nrf_twis_task_address_get | ( | NRF_TWIS_Type const *const | p_reg, |
nrf_twis_task_t | task | ||
) |
Function for returning the address of a specific TWIS task register.
[in] | p_reg | Pointer to the peripheral registers structure. |
task | Task. |
__STATIC_INLINE void nrf_twis_task_trigger | ( | NRF_TWIS_Type *const | p_reg, |
nrf_twis_task_t | task | ||
) |
Function for activating a specific TWIS task.
[in] | p_reg | Pointer to the peripheral registers structure. |
task | Task. |
__STATIC_INLINE nrf_twis_amount_t nrf_twis_tx_amount_get | ( | NRF_TWIS_Type const *const | p_reg | ) |
Function for getting number of bytes transmitted in the last transaction.
[in] | p_reg | Pointer to the peripheral registers structure. |
__STATIC_INLINE void nrf_twis_tx_buffer_set | ( | NRF_TWIS_Type *const | p_reg, |
uint8_t const * | p_buf, | ||
nrf_twis_amount_t | length | ||
) |
Function for setting the transmit buffer.
[in] | p_reg | Pointer to the peripheral registers structure. |
p_buf | Pointer to the buffer with data to send. | |
length | Maximum number of data bytes to transmit. |
__STATIC_INLINE void nrf_twis_tx_prepare | ( | NRF_TWIS_Type *const | p_reg, |
uint8_t const * | p_buf, | ||
nrf_twis_amount_t | length | ||
) |
Function that prepares TWIS for transmitting.
This function sets transmit buffer and then sets NRF_TWIS_TASK_PREPARETX task.
[in] | p_reg | Pointer to the peripheral registers structure. |
p_buf | Pointer to the buffer with data to send. | |
length | Maximum number of data bytes to transmit. |