Hi,
I am using the following function to read the content of a register:
static ret_code_t read_reg(uint8_t slave_address, uint8_t register_address, uint8_t *value) {
ret_code_t err_code;
err_code = nrf_drv_twi_tx(&m_twi, slave_address, ®ister_address, 1, true);
VERIFY_SUCCESS(err_code);
err_code = nrf_drv_twi_rx(&m_twi, slave_address, value, 1);
VERIFY_SUCCESS(err_code);
return err_code;
}
I call is this way:
#define MAX30101_ADDR (0xAE >> 1)
#define MAX30101_REG_PART_ID 0xFFU
uint8_t part_id;
ret_code_t err_code;
err_code = read_reg(MAX30101_ADDR, MAX30101_REG_PART_ID, &part_id);
VERIFY_SUCCESS(err_code);
The problem is that this always return NRF_ERROR_BUSY
When I try to use it this way:
do {
err_code = read_reg(MAX30101_ADDR, MAX30101_REG_PART_ID, &part_id);
} while (err_code == NRF_ERROR_BUSY);
I never exit the do-while.
What am I doing wrong ? why does it keep returning NRF_ERROR_BUSY ?