Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Adding twi support to ble_app_hrs_freertos

Hi,
I read so many articles but just can't find the correct way to add twi support to the ble_app_hrs_feertos app in the latest SDK15.
This what did:
- Copied 3 lines from twi_sensor example that define nrf_drv_twi_t object  just before my main (see screen cap)
- In sdk_config.h enabled NRFX_TWI_ENABLED & NRFX_TWI0_ENABLED
- Tried enabling nRF_Drivers\nrf_twi / nrf_drv_twi (whats the difference between the two?) in Keil's RTE manager
Nothing could get rid from the NRF_DRV_TWI_INSTANCE_0 undefined error.
Is there any guide how to integrate and use nrf drivers in general and twi in particular?  Specifically what to include and how (sdk_config.h? RTE ? both ?)
Thanks
Parents
  • Hi Nordic,

    I did some further research and need your assistance in figuring out this Mystery ....

    recap - I'm trying to implement twi support on freertos ble project (SDK15.0) the following way -

    - My target project is a copy of ble_app_hrs_freertos folder

    - My reference project is twi_sensor

    - Added nrfx_twi.c & nrfx_twim.c to the nRF_Drivers group of the target project (imported from <SDK_folder>\modules\nrfx\drivers\src as in the reference project)

    - Included the following at the beginning of main.c:

    #include <nrfx.h>

    #include "sdk_config.h"

    #include "nrf_drv_twi.h"

    - In sdk_config.h I've enabled NRFX_TWI_ENABLED & NRFX_TWIM_ENABLED and their immediate child NRFX_TWI0_ENABLED & ERFX_TWIM0_ENABLED

    - in my main.c just before main() I've copied two lines from the reference project:

    /* TWI instance ID. */
    #define TWI_INSTANCE_ID 0
    /* TWI instance. */
    static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID)

    Mysteriously I keep getting "NRF_DRV_TWI_INSTANCE_0 undefined" error and noticed that although I've enabled TWI & TWIM in sdk_config.h they remained undef'd when looking in nrfx_twi.c & nrfx_twim.c (code grayed out). See screen capture

    What make it even stranger is that in the reference project, again, both NRF_TWI_ENABLED & NRF_TWIM_ENABLED are set to 1 in sdk_config.h, but this time nrfx_twim.c become enabled while nerfx_twi.c remains grayed out...

    I tried to follow the definition route and everything looks OK so I'm pretty lost here......

    Thanks in advance for any support

  • Problem solved!

    Hello, eyalasko, I had the same problem, and I did exactly what you did.
    I followed the NRFX_TWI0_ENABLED of the line #if NRFX_CHECK(NRFX_TWI0_ENABLED)

    and it got me to this kind of transition file name apply_old_config.h and at this file NRFX_TWI0_ENABLED and NRFX_TWI_ENABLED appear as a combination of TWI0_ENABLED and TWI_ENABLED and so on, as you can see in the image below. 

    So I basically did the same sdk_config.h as you and also enabled TWI0_ENABLED and TWI_ENABLED  and it worked like that!

    Hope it also solves your issue ;) !

Reply
  • Problem solved!

    Hello, eyalasko, I had the same problem, and I did exactly what you did.
    I followed the NRFX_TWI0_ENABLED of the line #if NRFX_CHECK(NRFX_TWI0_ENABLED)

    and it got me to this kind of transition file name apply_old_config.h and at this file NRFX_TWI0_ENABLED and NRFX_TWI_ENABLED appear as a combination of TWI0_ENABLED and TWI_ENABLED and so on, as you can see in the image below. 

    So I basically did the same sdk_config.h as you and also enabled TWI0_ENABLED and TWI_ENABLED  and it worked like that!

    Hope it also solves your issue ;) !

Children
No Data
Related