I have to initialize a i2c multiplexer, for that I am sending the device address and register address to be written using the function:
nrf_drv_twi_tx(&m_twi, (0x70), tx_buf, sizeof(tx_buf), false);
Whenever I call this function, the flow is stuck inside a while block which checks m_xfer_done:
while (m_xfer_done == false) {}
Why the flow is stuck inside this loop?
I have initialized the twi master initialization as follows:
void twi_master_init(void)
{
ret_code_t err_code;
// Configure the settings for twi communication
const nrf_drv_twi_config_t twi_config = {
.scl = TWI_SCL_M, //SCL Pin
.sda = TWI_SDA_M, //SDA Pin
.frequency = NRF_DRV_TWI_FREQ_400K, //Communication Speed
.interrupt_priority = APP_IRQ_PRIORITY_HIGH, //Interrupt Priority(Note: if using Bluetooth then select priority carefully)
.clear_bus_init = false //automatically clear bus
};
//A function to initialize the twi communication
err_code = nrf_drv_twi_init(&m_twi, &twi_config, twi_handler, NULL);
APP_ERROR_CHECK(err_code);
//NRF_LOG_INFO("error code in twi init= %d", err_code);
//Enable the TWI Communication
nrf_drv_twi_enable(&m_twi);
//NRF_LOG_INFO("twi is initialized");
}
Thanks