Driver for managing the TWI.
More...
|
ret_code_t | nrf_drv_twi_init (nrf_drv_twi_t const *const p_instance, nrf_drv_twi_config_t const *p_config, nrf_drv_twi_evt_handler_t event_handler, void *p_context) |
| Function for initializing the TWI instance. More...
|
|
void | nrf_drv_twi_uninit (nrf_drv_twi_t const *const p_instance) |
| Function for uninitializing the TWI. More...
|
|
void | nrf_drv_twi_enable (nrf_drv_twi_t const *const p_instance) |
| Function for enabling the TWI instance. More...
|
|
void | nrf_drv_twi_disable (nrf_drv_twi_t const *const p_instance) |
| Function for disabling the TWI instance. More...
|
|
ret_code_t | nrf_drv_twi_tx (nrf_drv_twi_t const *const p_instance, uint8_t address, uint8_t const *p_data, uint32_t length, bool xfer_pending) |
| Function for sending data to a TWI slave. More...
|
|
ret_code_t | nrf_drv_twi_rx (nrf_drv_twi_t const *const p_instance, uint8_t address, uint8_t *p_data, uint32_t length, bool xfer_pending) |
| Function for reading data from a TWI slave. More...
|
|
uint32_t | nrf_drv_twi_data_count_get (nrf_drv_twi_t const *const p_instance) |
| Function for getting transferred data count. More...
|
|
__STATIC_INLINE uint32_t | nrf_drv_twi_task_address_get (nrf_drv_twi_t const *const p_instance, nrf_twi_tasks_t task) |
| Function for returning the address of a specific TWI task. More...
|
|
__STATIC_INLINE uint32_t | nrf_drv_twi_event_address_get (nrf_drv_twi_t const *const p_instance, nrf_twi_events_t event) |
| Function for returning the address of a specific TWI event. More...
|
|
Driver for managing the TWI.
#define NRF_DRV_TWI_DEFAULT_CONFIG |
( |
|
id | ) |
|
Value:{ \
.frequency = CONCAT_3(TWI, id, _CONFIG_FREQUENCY), \
.scl = CONCAT_3(TWI, id, _CONFIG_SCL), \
.sda = CONCAT_3(TWI, id, _CONFIG_SDA), \
.interrupt_priority = CONCAT_3(TWI, id, _CONFIG_IRQ_PRIORITY) \
}
TWI instance default configuration.
#define NRF_DRV_TWI_INSTANCE |
( |
|
id | ) |
|
Value:{ \
.p_reg = CONCAT_2(NRF_TWI, id), \
.irq = CONCAT_3(TWI, id, _IRQ), \
.instance_id = CONCAT_3(TWI, id, _INSTANCE_INDEX) \
}
Macro for creating a TWI driver instance.
uint32_t nrf_drv_twi_data_count_get |
( |
nrf_drv_twi_t const *const |
p_instance | ) |
|
Function for getting transferred data count.
- Parameters
-
[in] | p_instance | TWI instance. |
- Returns
- Data count.
void nrf_drv_twi_disable |
( |
nrf_drv_twi_t const *const |
p_instance | ) |
|
Function for disabling the TWI instance.
- Parameters
-
[in] | p_instance | TWI instance. |
Function for enabling the TWI instance.
- Parameters
-
[in] | p_instance | TWI instance. |
Function for returning the address of a specific TWI event.
- Parameters
-
[in] | p_instance | TWI instance. |
[in] | event | Event. |
- Returns
- Event address.
Function for initializing the TWI instance.
- Parameters
-
[in] | p_instance | TWI instance. |
[in] | p_config | Initial configuration. If NULL, the default configuration is used. |
[in] | event_handler | Event handler provided by the user. If NULL, blocking mode is enabled. |
[in] | p_context | Context pointer, passed to event handler. |
- Return values
-
NRF_SUCCESS | If initialization was successful. |
NRF_ERROR_INVALID_STATE | If the driver is in invalid state. |
ret_code_t nrf_drv_twi_rx |
( |
nrf_drv_twi_t const *const |
p_instance, |
|
|
uint8_t |
address, |
|
|
uint8_t * |
p_data, |
|
|
uint32_t |
length, |
|
|
bool |
xfer_pending |
|
) |
| |
Function for reading data from a TWI slave.
Transmission will be stopped when error or time-out occurs.
- Parameters
-
[in] | p_instance | TWI instance. |
[in] | address | Address of a specific slave device (only 7 LSB). |
[in] | p_data | Pointer to a receive buffer. |
[in] | length | Number of bytes to be received. |
[in] | xfer_pending | After a specified number of bytes, transmission will be suspended (if xfer_pending is set) or stopped (if not). |
- Return values
-
NRF_SUCCESS | If the procedure was successful. |
NRF_ERROR_BUSY | If the driver is not ready for a new transfer. |
NRF_ERROR_INTERNAL | If an NRF_TWI_EVENTS_ERROR or a time-out has occured (only in blocking mode). |
Function for returning the address of a specific TWI task.
- Parameters
-
[in] | p_instance | TWI instance. |
[in] | task | Task. |
- Returns
- Task address.
ret_code_t nrf_drv_twi_tx |
( |
nrf_drv_twi_t const *const |
p_instance, |
|
|
uint8_t |
address, |
|
|
uint8_t const * |
p_data, |
|
|
uint32_t |
length, |
|
|
bool |
xfer_pending |
|
) |
| |
Function for sending data to a TWI slave.
The transmission will be stopped when an error or time-out occurs.
- Parameters
-
[in] | p_instance | TWI instance. |
[in] | address | Address of a specific slave device (only 7 LSB). |
[in] | p_data | Pointer to a transmit buffer. |
[in] | length | Number of bytes to send. |
[in] | xfer_pending | After a specified number of bytes, transmission will be suspended (if xfer_pending is set) or stopped (if not). |
- Return values
-
NRF_SUCCESS | If the procedure was successful. |
NRF_ERROR_BUSY | If the driver is not ready for a new transfer. |
NRF_ERROR_INTERNAL | If an NRF_TWI_EVENTS_ERROR or a time-out has occurred (only in blocking mode). |
Function for uninitializing the TWI.
- Parameters
-
[in] | p_instance | TWI instance. |