This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Clarification on nrf_drv_twi_rx being blocking

Hello

nrf_drv_twi_rx and nrf_drv_twi_tx are non blocking calls? 

in the SDK example, I see a while loop is used in the read call for instance which basically is blocking the caller function unless the m_xfer_done flag is set from within an interrupt. Is this how the driver call is typically used...to avoid invoking it before the current read is done?

uint32_t SENSOR::read()
{
    m_xfer_done = false;
    ret_code_t err_code = nrf_drv_twi_rx(&m_twi, MCP9808_ADDR, _buffer, 2);
    
    APP_ERROR_CHECK(err_code);
 
    while(!m_xfer_done);

    return err_code;	         
}

- When I run SystemView while running the app, I see the interrupt is triggered every 11us, and it doesn't even mention the name of the ISR invoked leaving me confused, since SENSOR::read() call is invoked every 3s in my app.

void SENSOR::mainThread()
{
    ret_code_t err_code;

    err_code = nrf_drv_twi_tx(&m_twi, ADDR, &reg, size, false);
    APP_ERROR_CHECK(err_code);
    while (!m_xfer_done);
    while(true)  
{
read();
vTaskDelay(pdMS_TO_TICKS(3000));
}

}

Related