nrf_twi_mngr_transfer_t and const write data

I am trying to populate a nrf_twi_mngr_transfer_t at runtime depending on chunks of an input file that I'm pushing to i2c. 

nrf_twi_mngr_transfer_t const write_cfg_transfers[] = {
   NRF_TWI_MNGR_WRITE(bytes[0] >> 1, &data, i-1, 0),
};
Then I get a build error - 

error: initializer element is not constant

How is this done? 

I've tried using the twi instance from the twi_mngr struct, I can see it on the wire, but I get a hardfault on invoking the callback (likley undefined at this point)

ret_code_t err_code = nrf_drv_twi_tx(&(m_nrf_twi_mngr.twi), bytes[0] >> 1, data, i-1, false);
Parents
  • It looks like NRF_TWI_MNGR_BUFFERS_IN_RAM is being set.
    I wrapped my transaction with #ifdef NRF_TWI_MNGR_BUFFERS_IN_RAM and I still get the 
    error: initializer element is not constant.

    Specifically on the byte count, which for me, varies every time this function is called. My i2c address is also variable, as my device address varies in normal operation vs ROM mode. Can the byte count and I2C address also be in RAM? 

    I see the example twi_master_using_nrf_twi_mngr claims to be using buffers in RAM, but it is using constants for the byte count and device address.

Reply
  • It looks like NRF_TWI_MNGR_BUFFERS_IN_RAM is being set.
    I wrapped my transaction with #ifdef NRF_TWI_MNGR_BUFFERS_IN_RAM and I still get the 
    error: initializer element is not constant.

    Specifically on the byte count, which for me, varies every time this function is called. My i2c address is also variable, as my device address varies in normal operation vs ROM mode. Can the byte count and I2C address also be in RAM? 

    I see the example twi_master_using_nrf_twi_mngr claims to be using buffers in RAM, but it is using constants for the byte count and device address.

Children
No Data
Related