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

Error with #define NRFX_TWI_INSTANCE(id)

I am currently trying to connect an accelerometer to my Nordic board, but I am having some issues with #define NRFX_TWI_INSTANCE(id) 



.p_twi = NRFX_CONCAT_2(NRF_TWI, id), \
.drv_inst_idx = NRFX_CONCAT_3(NRFX_TWI, id, _INST_IDX), \

With these two lines, I am getting the errors

and

error: 'nrf_drv_twi_t' has no member named 'drv_inst_idx';

error: 'nrf_drv_twi_t' has no member named 'p_twi'

I am very new to using the board so apologies if I'm leaving out way too much information. I'm not sure what is  relevant and what is not.

Parents
  • Hi,

    It looks like you are mixing some defines here. If you are assigning to an object of type nrf_drv_twi_t, you should use NRF_DRV_TWI_INSTANCE(id), not NRFX_TWI_INSTANCE(id). Internally, this will be translated to NRFX macros, depending on the sdk_config.h configurations. See this code:

    #define NRF_DRV_TWI_INSTANCE(id)    NRF_DRV_TWI_INSTANCE_(id)
    #define NRF_DRV_TWI_INSTANCE_(id)   NRF_DRV_TWI_INSTANCE_ ## id
    #if NRFX_CHECK(NRFX_TWIM0_ENABLED)
        #define NRF_DRV_TWI_INSTANCE_0 \
            { 0, { .twim = NRFX_TWIM_INSTANCE(0) }, true }
    #elif NRFX_CHECK(NRFX_TWI0_ENABLED)
        #define NRF_DRV_TWI_INSTANCE_0 \
            { 0, { .twi = NRFX_TWI_INSTANCE(0) }, false }
    #endif
    #if NRFX_CHECK(NRFX_TWIM1_ENABLED)
        #define NRF_DRV_TWI_INSTANCE_1 \
            { 1, { .twim = NRFX_TWIM_INSTANCE(1) }, true }
    #elif NRFX_CHECK(NRFX_TWI1_ENABLED)
        #define NRF_DRV_TWI_INSTANCE_1 \
            { 1, { .twi = NRFX_TWI_INSTANCE(1) }, false }
    #endif

    Best regards,
    Jørgen

Reply
  • Hi,

    It looks like you are mixing some defines here. If you are assigning to an object of type nrf_drv_twi_t, you should use NRF_DRV_TWI_INSTANCE(id), not NRFX_TWI_INSTANCE(id). Internally, this will be translated to NRFX macros, depending on the sdk_config.h configurations. See this code:

    #define NRF_DRV_TWI_INSTANCE(id)    NRF_DRV_TWI_INSTANCE_(id)
    #define NRF_DRV_TWI_INSTANCE_(id)   NRF_DRV_TWI_INSTANCE_ ## id
    #if NRFX_CHECK(NRFX_TWIM0_ENABLED)
        #define NRF_DRV_TWI_INSTANCE_0 \
            { 0, { .twim = NRFX_TWIM_INSTANCE(0) }, true }
    #elif NRFX_CHECK(NRFX_TWI0_ENABLED)
        #define NRF_DRV_TWI_INSTANCE_0 \
            { 0, { .twi = NRFX_TWI_INSTANCE(0) }, false }
    #endif
    #if NRFX_CHECK(NRFX_TWIM1_ENABLED)
        #define NRF_DRV_TWI_INSTANCE_1 \
            { 1, { .twim = NRFX_TWIM_INSTANCE(1) }, true }
    #elif NRFX_CHECK(NRFX_TWI1_ENABLED)
        #define NRF_DRV_TWI_INSTANCE_1 \
            { 1, { .twi = NRFX_TWI_INSTANCE(1) }, false }
    #endif

    Best regards,
    Jørgen

Children
No Data
Related