Driver for managing the TWI. More...
Data Structures |
|
| struct | nrf_drv_twi_evt_t |
|
Structure for a TWI event.
More...
|
|
| struct | nrf_drv_twi_t |
|
TWI driver instance structure.
More...
|
|
| struct | nrf_drv_twi_config_t |
|
Structure for TWI instance configuration.
More...
|
|
Macros |
|
| #define | NRF_DRV_TWI_INSTANCE (id) |
|
Macro for creating a TWI driver instance.
More...
|
|
| #define | NRF_DRV_TWI_DEFAULT_CONFIG (id) |
|
TWI instance default configuration.
More...
|
|
Typedefs |
|
| typedef void(* | nrf_drv_twi_evt_handler_t )( nrf_drv_twi_evt_t const *p_event, void *p_context) |
|
TWI event handler prototype.
|
|
Enumerations |
|
| enum |
nrf_drv_twi_evt_type_t
{
NRF_DRV_TWI_RX_DONE , NRF_DRV_TWI_TX_DONE , NRF_DRV_TWI_ERROR } |
|
TWI events.
|
|
Functions |
|
| 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...
|
|
Detailed Description
Driver for managing the TWI.
Macro Definition Documentation
| #define NRF_DRV_TWI_DEFAULT_CONFIG | ( | id | ) |
TWI instance default configuration.
| #define NRF_DRV_TWI_INSTANCE | ( | id | ) |
Macro for creating a TWI driver instance.
Function Documentation
| 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.
| void nrf_drv_twi_enable | ( | nrf_drv_twi_t const *const | p_instance | ) |
Function for enabling the TWI instance.
- Parameters
-
[in] p_instance TWI instance.
| __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.
- Parameters
-
[in] p_instance TWI instance. [in] event Event.
- Returns
- Event address.
| 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.
- 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).
| __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.
- 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).
| void nrf_drv_twi_uninit | ( | nrf_drv_twi_t const *const | p_instance | ) |
Function for uninitializing the TWI.
- Parameters
-
[in] p_instance TWI instance.