The current example TWI_handler will hang forever is it exits with anything other than NRF_DRV_TWI_EVT_DONE. This can occur if a TWI slave fails to acknowledge the address or data phase. I am looking for how to gracefully exit a nrf_drv_twi_tx() or nrf_drv_twi_rx() call if an error occurs. Would it be best to poll for m_xfer_done before the call to nrf_drv_twi_tx() or nrf_drv_twi_rx()? In that manner, if an error occurred from a previous call, the firmware can handle the exception gracefully. I am using SDK 15.2 and a nrf52832 device.
It appears that back-to-back calls to either of the TWI driver calls can cause erroneous behavior if one doesn't wait for the first transfer to finish. Does the TWI driver have the ability to determine if it is busy (in process of a previous transfer)?