Skip to content

Instantly share code, notes, and snippets.

Created November 9, 2017 09:20
Show Gist options
  • Save anonymous/73ad243663f18d860389ba373b4bea07 to your computer and use it in GitHub Desktop.
Save anonymous/73ad243663f18d860389ba373b4bea07 to your computer and use it in GitHub Desktop.
TWI Handler
void twi_event_handler(nrf_drv_twi_evt_t const * p_event, void * p_context)
{
switch(p_event->type)
{
case NRF_DRV_TWI_EVT_DONE:
switch(p_event->xfer_desc.type)
{
case NRF_DRV_TWI_XFER_TX:
//NRF_LOG_INFO(" 1. NRF_DRV_TWI_XFER_TX.\r\n");
twi_tx_done = true;
break;
case NRF_DRV_TWI_XFER_TXTX:
//NRF_LOG_INFO(" 2. NRF_DRV_TWI_XFER_TXTX.\r\n");
twi_tx_done = true;
break;
case NRF_DRV_TWI_XFER_RX:
//NRF_LOG_INFO(" 3. NRF_DRV_TWI_XFER_RX.\r\n");
twi_rx_done = true;
// Disable TWI when packet received
nrf_drv_twi_disable(&m_twi_instance);
break;
case NRF_DRV_TWI_XFER_TXRX:
//NRF_LOG_INFO(" 4. NRF_DRV_TWI_XFER_TXRX.\r\n");
twi_rx_done = true;
break;
default:
break;
}
break;
case NRF_DRV_TWI_EVT_ADDRESS_NACK:
break;
case NRF_DRV_TWI_EVT_DATA_NACK:
break;
default:
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment