Dear Nordic,
I want to scan slave devices , so I use TWIM nrfx driver to send zero byte data, I don't got error code, but I don't receive TWIM event too. I found a example using `
nrfx_twim_rx` to scan slaves, I was just wondering if I can't use `nrfx_twim_tx` to scan slave devices by send zero byte data?
uint8_t HAL_I2C_End_Transmission(HAL_I2C_Interface i2c, uint8_t stop,void* reserved)
{
HAL_I2C_Acquire(i2c, NULL);
uint32_t err_code;
// FIXME: workaround, not support send zero byte data,
// scan slave device by resquestting 1 bytes from slave
if (m_i2c_map[i2c].tx_buf_length)
{
m_i2c_map[i2c].transmitting = true;
err_code = nrfx_twim_tx(m_i2c_map[i2c].instance, m_i2c_map[i2c].address, m_i2c_map[i2c].tx_buf,
m_i2c_map[i2c].tx_buf_length, !stop);
if (err_code)
{
m_i2c_map[i2c].transmitting = false;
}
while (m_i2c_map[i2c].transmitting);
m_i2c_map[i2c].tx_buf_index = 0;
m_i2c_map[i2c].tx_buf_length = 0;
}
else
{
uint8_t dummy = 0;
m_i2c_map[i2c].transmitting = true;
err_code = nrfx_twim_rx(m_i2c_map[i2c].instance, m_i2c_map[i2c].address, &dummy, 1);
if (err_code)
{
m_i2c_map[i2c].transmitting = false;
}
while (m_i2c_map[i2c].transmitting);
}
HAL_I2C_Release(i2c, NULL);
return 0;
}
Best Regards,
Eugene