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

how to read data from slave via TWI

Hi,

I am trying to use GPIOTE_PIN_HANDLER in the master nrf52. What is the correct way to read data from slave?

Slave device is sending data using nrfx_twis_tx_prepare() and in master device, I am trying to receive data like below:

void gpiote_pin_event_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
	if ((pin == INTERRUPT_PIN) && (NRF_GPIOTE_POLARITY_HITOLO)) {

    	uint8_t rx_buf[1];

        err_code = nrfx_twim_rx(&m_twi, ADDR_SLAVE, rx_buf, sizeof(rx_buf));
        APP_ERROR_CHECK(err_code);
    }

I could not receive anything in master as nrfx_twim_rx() does not executes fully.

Is above the correct way to receive data in master device? Or does master first need to transmit buffer to slave and then slave fills that buffer with data?

If any examples exist for this kind of scenario, please provide pointers.

Parents Reply Children
No Data
Related