nRF51 SDK - S110 SoftDevice
|
The two-wire interface (TWI) driver includes two layers: the hardware abstraction layer (HAL) and the driver layer (DRV).
The hardware abstraction layer provides basic APIs for accessing the registers of the TWI. See the API documentation for the TWI HAL for details.
The driver layer provides APIs on a higher level than the HAL. See the API documentation for the TWI driver for details.
Key features include:
Blocking mode is enabled if no event handler is provided during initialization. If an event handler is provided, calls like nrf_drv_twi_tx or nrf_drv_twi_rx will return instantly with NRF_SUCCESS. Notifications of end of transmission or error will be passed to the application using the nrf_drv_twi_evt_t structure.
The following code shows a simple write sequence without pending transfer:
The following code shows a write sequence with pending transfer:
Errors (like time-out or NACK) will stop the transmission: