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

Pure NRFX RTC code - how to?

Hi,

I'm trying to adopt my nRF52832 projects to the nRF5 SDK version 15.2.0 and the NRFX drivers framework. I'm using a short app_config.h with NRFX_RTC_ENABLED and NRFX_RTC0_ENABLED only. Unfortunately, it won't work because it's locked on the legacy stuff from the integration/nrfx/legacy/apply_old_config.h. Particularly, the following chunk of defs in the apply_old_config.h are enforced to redefine my NRFX_RTC0_ENABLED because sdk_config.h has the default RTC_ENABLED value (defined as 0):

#if defined(RTC_ENABLED)

#undef NRFX_RTC_ENABLED
#define NRFX_RTC_ENABLED  RTC_ENABLED

#if defined(RTC0_ENABLED)
#undef NRFX_RTC0_ENABLED
#define NRFX_RTC0_ENABLED  RTC0_ENABLED
...

What would be the recommended way to enable the pure NRFX RTC without legacy code involved?

Thanks!

Parents
  • Okay, here are more details on what happens:

    Compiling file: sys_rtc.c
    In file included from /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/nrfx.h:45:0,
                     from /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/drivers/include/nrfx_rtc.h:44,
                     from sys_rtc.c:2:
    /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/drivers/include/nrfx_rtc.h:86:39: error: 'NRFX_RTC0_INST_IDX' undeclared here (not in a function)
         .instance_id      = NRFX_CONCAT_3(NRFX_RTC, id, _INST_IDX), \
                                           ^
    /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/drivers/nrfx_common.h:117:37: note: in definition of macro 'NRFX_CONCAT_3_'
     #define NRFX_CONCAT_3_(p1, p2, p3)  p1 ## p2 ## p3
                                         ^~
    /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/drivers/include/nrfx_rtc.h:86:25: note: in expansion of macro 'NRFX_CONCAT_3'
         .instance_id      = NRFX_CONCAT_3(NRFX_RTC, id, _INST_IDX), \
                             ^~~~~~~~~~~~~
    sys_rtc.c:9:24: note: in expansion of macro 'NRFX_RTC_INSTANCE'
     const nrfx_rtc_t rtc = NRFX_RTC_INSTANCE(0);
                            ^~~~~~~~~~~~~~~~~
    make: *** [obj/dhrystone/sys_rtc.c.o] Error 1
    

    The NRFX_RTC_INSTANCE macro refers to NRFX_RTC0_INST_IDX which should be "initialized" by the enum in the modules/nrfx/drivers/include/nrfx_rtc.h (see below), but it fails to do so because the NRFX_RTC0_ENABLED will always be reset to 0 due to the integration/nrfx/legacy/apply_old_config.h defs (please see the originating post).

    enum {
    #if NRFX_CHECK(NRFX_RTC0_ENABLED)
        NRFX_RTC0_INST_IDX,
    #endif
    #if NRFX_CHECK(NRFX_RTC1_ENABLED)
        NRFX_RTC1_INST_IDX,
    #endif
    #if NRFX_CHECK(NRFX_RTC2_ENABLED)
        NRFX_RTC2_INST_IDX,
    #endif
        NRFX_RTC_ENABLED_COUNT
    };

    Perhaps the SDK should not always include legacy defs, but rather make it optional.

Reply
  • Okay, here are more details on what happens:

    Compiling file: sys_rtc.c
    In file included from /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/nrfx.h:45:0,
                     from /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/drivers/include/nrfx_rtc.h:44,
                     from sys_rtc.c:2:
    /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/drivers/include/nrfx_rtc.h:86:39: error: 'NRFX_RTC0_INST_IDX' undeclared here (not in a function)
         .instance_id      = NRFX_CONCAT_3(NRFX_RTC, id, _INST_IDX), \
                                           ^
    /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/drivers/nrfx_common.h:117:37: note: in definition of macro 'NRFX_CONCAT_3_'
     #define NRFX_CONCAT_3_(p1, p2, p3)  p1 ## p2 ## p3
                                         ^~
    /Users/mishka/my/l.a.b./src/sdk/modules/nrfx/drivers/include/nrfx_rtc.h:86:25: note: in expansion of macro 'NRFX_CONCAT_3'
         .instance_id      = NRFX_CONCAT_3(NRFX_RTC, id, _INST_IDX), \
                             ^~~~~~~~~~~~~
    sys_rtc.c:9:24: note: in expansion of macro 'NRFX_RTC_INSTANCE'
     const nrfx_rtc_t rtc = NRFX_RTC_INSTANCE(0);
                            ^~~~~~~~~~~~~~~~~
    make: *** [obj/dhrystone/sys_rtc.c.o] Error 1
    

    The NRFX_RTC_INSTANCE macro refers to NRFX_RTC0_INST_IDX which should be "initialized" by the enum in the modules/nrfx/drivers/include/nrfx_rtc.h (see below), but it fails to do so because the NRFX_RTC0_ENABLED will always be reset to 0 due to the integration/nrfx/legacy/apply_old_config.h defs (please see the originating post).

    enum {
    #if NRFX_CHECK(NRFX_RTC0_ENABLED)
        NRFX_RTC0_INST_IDX,
    #endif
    #if NRFX_CHECK(NRFX_RTC1_ENABLED)
        NRFX_RTC1_INST_IDX,
    #endif
    #if NRFX_CHECK(NRFX_RTC2_ENABLED)
        NRFX_RTC2_INST_IDX,
    #endif
        NRFX_RTC_ENABLED_COUNT
    };

    Perhaps the SDK should not always include legacy defs, but rather make it optional.

Children
No Data
Related