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

Regarding changes in nrf_drv_twi.c

typedef struct
{
nrf_drv_twi_evt_handler_t handler;
void * p_context;
volatile uint32_t int_mask;
nrf_drv_twi_xfer_desc_t xfer_desc;
uint32_t flags;
uint8_t * p_curr_buf;
uint8_t curr_length;
bool curr_no_stop;
nrf_drv_state_t state;
bool error;
bool busy;
bool repeated;
uint8_t bytes_transferred;
bool hold_bus_uninit;
#if NRF_MODULE_ENABLED(TWIM_NRF52_ANOMALY_109_WORKAROUND)
nrf_twim_frequency_t bus_frequency;
#endif
} twi_control_block_t;

const twi_control_block_t m_cb[ENABLED_TWI_COUNT];

I have a query regarding the nrf_drv_twi.c that contains the structure definition of twi_control_block_t.I wanted to ask is it feasible to make changes to the given structure or any way we can create ant smaller structure using this structure with the relevant changes.

  • I just wanted to wanted to briefly update the problem here.

    Actually one of the object of the structure i.e., bool busy was defined as volatile, and when I was using this structure for sensor data capturing,it showed error 17 for the sensors and when I removed volatile keyword from there then the error was sorted.

    But the new thing that I observed was If I compile my code in segger studio using volatile definition then I observed correct results.

    So can anyone please help with what exactly is the problem.

  • Hi,

    You should not change the structure. The busy variable is volatile as it can be changed unexpectedly by external parts of the application. If you declare it as non-volatile, the compiler might optimize the variable away, as it does not see any use for it. If you get NRF_ERROR_BUSY (17), you have another issue in your application that you need to solve. Changing the driver to mitigate the error is not a valid solution.

    Best regards,
    Jørgen

Related