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

Merge Twis i2c slave example in ble_template project

Hello everyone,

I am trying to add twis i2c slave in ble_template project. I found twi_master_twis_slave example in the sdk. I merge the project but ended up with following error

‘NRFX_TWIS1_INST_IDX’ undeclared here (not in a function); did you mean ‘NRFX_TWIS_INSTANCE’?

i have enabled the NRFX_TWIS in sdk_config.h file but still getting the error. 

Can anyone help me to solve this issue. Please provide me merging guide for twis slave and ble_template project. it would be really helpful.

Currently i am using

sdk version: - 16.0.0

DK: - nrf52832

segger embedded studio

Thanks & Regards

Pradeep

Parents
  • Hello,

    Can you send me a copy of your sdk_config.h file?

    I suspect that you only set the NRFX_TWIS definitions in sdk_config.h, but you still have the old "legacy" definitions of NRF_TWI as well, which will overwrite the NRFX definitions in the project.

    Please look for the apply_old_config.h file in your project, and you can see how it is used. 

    Solution:

    Either completely remove the legacy (non NRFX_...) for TWI(S) or set them equal to the NRFX_TWIS_... definitions.

    Best Regards,

    Edvin

Reply
  • Hello,

    Can you send me a copy of your sdk_config.h file?

    I suspect that you only set the NRFX_TWIS definitions in sdk_config.h, but you still have the old "legacy" definitions of NRF_TWI as well, which will overwrite the NRFX definitions in the project.

    Please look for the apply_old_config.h file in your project, and you can see how it is used. 

    Solution:

    Either completely remove the legacy (non NRFX_...) for TWI(S) or set them equal to the NRFX_TWIS_... definitions.

    Best Regards,

    Edvin

Children
  • Hi Edvin,

    Thank you so much for the response. Please find the sdk_config.h file. Sorry but i am not able to find the apply_old_config.h file. If there is old legacy definitions in the project. Can you please suggest me how can i remove old legacy definitions. 

    6507.sdk_config.h

  • pradeep8892 said:
    Sorry but i am not able to find the apply_old_config.h file.

     Search for NRFX_TWIS_ENABLED in your project. You should see that it is used in a file called apply_old_config.h.

    This is the section from apply_old_config.h that is relevant for you:

    // TWIS
    
    #if defined(TWIS_ENABLED)
    
    #undef NRFX_TWIS_ENABLED
    #define NRFX_TWIS_ENABLED  TWIS_ENABLED
    
    #if defined(TWIS0_ENABLED)
    #undef NRFX_TWIS0_ENABLED
    #define NRFX_TWIS0_ENABLED  TWIS0_ENABLED
    #endif
    #if defined(TWIS1_ENABLED)
    #undef NRFX_TWIS1_ENABLED
    #define NRFX_TWIS1_ENABLED  TWIS1_ENABLED
    #endif
    
    #if defined(TWIS_ASSUME_INIT_AFTER_RESET_ONLY)
    #undef NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY
    #define NRFX_TWIS_ASSUME_INIT_AFTER_RESET_ONLY  TWIS_ASSUME_INIT_AFTER_RESET_ONLY
    #endif
    #if defined(TWIS_NO_SYNC_MODE)
    #undef NRFX_TWIS_NO_SYNC_MODE
    #define NRFX_TWIS_NO_SYNC_MODE  TWIS_NO_SYNC_MODE
    #endif
    
    #if defined(TWIS_DEFAULT_CONFIG_ADDR0)
    #undef NRFX_TWIS_DEFAULT_CONFIG_ADDR0
    #define NRFX_TWIS_DEFAULT_CONFIG_ADDR0  TWIS_DEFAULT_CONFIG_ADDR0
    #endif
    #if defined(TWIS_DEFAULT_CONFIG_ADDR1)
    #undef NRFX_TWIS_DEFAULT_CONFIG_ADDR1
    #define NRFX_TWIS_DEFAULT_CONFIG_ADDR1  TWIS_DEFAULT_CONFIG_ADDR1
    #endif
    #if defined(TWIS_DEFAULT_CONFIG_SCL_PULL)
    #undef NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL
    #define NRFX_TWIS_DEFAULT_CONFIG_SCL_PULL  TWIS_DEFAULT_CONFIG_SCL_PULL
    #endif
    #if defined(TWIS_DEFAULT_CONFIG_SDA_PULL)
    #undef NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL
    #define NRFX_TWIS_DEFAULT_CONFIG_SDA_PULL  TWIS_DEFAULT_CONFIG_SDA_PULL
    #endif
    #if defined(TWIS_DEFAULT_CONFIG_IRQ_PRIORITY)
    #undef NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY
    #define NRFX_TWIS_DEFAULT_CONFIG_IRQ_PRIORITY  TWIS_DEFAULT_CONFIG_IRQ_PRIORITY
    #endif
    
    #if defined(TWIS_CONFIG_LOG_ENABLED)
    #undef NRFX_TWIS_CONFIG_LOG_ENABLED
    #define NRFX_TWIS_CONFIG_LOG_ENABLED  TWIS_CONFIG_LOG_ENABLED
    #endif
    #if defined(TWIS_CONFIG_LOG_LEVEL)
    #undef NRFX_TWIS_CONFIG_LOG_LEVEL
    #define NRFX_TWIS_CONFIG_LOG_LEVEL  TWIS_CONFIG_LOG_LEVEL
    #endif
    #if defined(TWIS_CONFIG_INFO_COLOR)
    #undef NRFX_TWIS_CONFIG_INFO_COLOR
    #define NRFX_TWIS_CONFIG_INFO_COLOR  TWIS_CONFIG_INFO_COLOR
    #endif
    #if defined(TWIS_CONFIG_DEBUG_COLOR)
    #undef NRFX_TWIS_CONFIG_DEBUG_COLOR
    #define NRFX_TWIS_CONFIG_DEBUG_COLOR  TWIS_CONFIG_DEBUG_COLOR
    #endif
    
    #endif // defined(TWIS_ENABLED)

    As you can see, if TWIS_ENABLED is defined, something it is in your sdk_config.h, then all the NRFX_TWIS_... will be redefined based on the non-NRFX definitions.

    However, your problem consists of two parts:

    1a) You think that by configuring NRFX_TWIS_... definitions in sdk_config.h, you will change the settings of the projects. This is not true unless the TWIS_ENABLED definition in sdk_config.h is removed. Try to comment it out. 

    1b) The alternative solution is to use the TWIS_ENABLED_... definitions instead of NRFX_TWIS_ENABLED, because these will change the settings. Again: See the apply_old_config.h file in your project. Search for TWIS_ENABLED in your project to see where it is used. One of them should be the apply_old_config.h file.

    2)

    You need to enable at least one of the TWIS instances, so either TWIS0 or TWIS1 needs to be enabled. To see how to enable it, please refer to 1a or 1b.

Related