Driver for managing the TWI.
More...
|
#define | NRF_DRV_TWI_INSTANCE(id) |
| Macro for creating a TWI driver instance. More...
|
|
#define | TWI_CONFIG_FREQUENCY(id) TWI##id##_CONFIG_FREQUENCY |
|
#define | TWI_CONFIG_SCL(id) TWI##id##_CONFIG_SCL |
|
#define | TWI_CONFIG_SDA(id) TWI##id##_CONFIG_SDA |
|
#define | TWI_CONFIG_IRQ_PRIORITY(id) TWI##id##_CONFIG_IRQ_PRIORITY |
|
#define | NRF_DRV_TWI_DEFAULT_CONFIG(id) |
| TWI instance default configuration. 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) |
| 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_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 = TWI_CONFIG_FREQUENCY(id), \
.scl = TWI_CONFIG_SCL(id), \
.sda = TWI_CONFIG_SDA(id), \
.interrupt_priority = TWI_CONFIG_IRQ_PRIORITY(id), \
}
TWI instance default configuration.
#define NRF_DRV_TWI_INSTANCE |
( |
|
id | ) |
|
Value:{ \
.p_reg = NRF_TWI##id, \
.irq = SPI##id##_TWI##id##_IRQn, \
.instance_id = TWI##id##_INSTANCE_INDEX \
}
Macro for creating a TWI driver instance.
uint32_t nrf_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. |
- 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. |