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

App_util_platform.c cannot compile nrf_nvic_state_t is undefined

Here's the original error:

compiling app_util_platform.c... C:\Keil_v5\Nordic_SDK\nRF5_SDK_12.1.0_0d23e2a\components\libraries\util\app_util_platform.c(17): error: #20: identifier "nrf_nvic_state_t" is undefined nrf_nvic_state_t nrf_nvic_state;

I'm working with SDK 12.1 and have traced the error back to a lack of identifier declaration in nrf_nvic.h.... so after looking around online I found

typedef struct { uint32_t volatile __irq_masks[__NRF_NVIC_ISER_COUNT]; /**< IRQs enabled by the application in the NVIC. */

uint32_t volatile __cr_flag; /**< Non-zero if already in a critical region */

} nrf_nvic_state_t;

I tried adding this struct to my nrf_nvic.h file but no luck

I also have the files included in my path and SOFTDEVICE_PRESENT is in the Define section for the compiler and the assembler options for target.

any ideas?

  • Do you have these include paths in Keil ?

    ..\..\..\..\..\..\components\softdevice\s132\headers\
    
     ..\..\..\..\..\..\components\softdevice\common\softdevice_handler
    
    ..\..\..\..\..\..\components\softdevice\s132\headers\nr52
    

    What SDK example is your project based on?

  • Hi,

    nrf_nvic_state_t should already be defined in nrf_nvic.h at line 129.

    The file nrf_nvic.h is located in <SDK_InstallFolder>\components\softdevice\s132\headers\, so make sure that you have this path in the Keil Include Paths(Options for Target.. -> C/C++ tab)

  • Hey, thanks for helping me out Update: Found the definition and fix, go figures, just gotta pay more attention. Follow this path provided by the error: C:\Keil_v5\Nordic_SDK\nRF5_SDK_12.1.0_0d23e2a\components\drivers_nrf\nrf_soc_nosd\nrf_nvic.h(88): error: #256: invalid redeclaration of type name "nrf_nvic_state_t" (declared at line 88)

    2nd problem below (solved) __ I have it included and I have nrf_nvic_state_t struct defined. I commented out the #ifndef NRF_SOC_H__ and #endif which changed the error. It now says nrf_nvic_state_t is a redeclaration but when I comment it out it says it cant find the identifier....?

    I'm also unable to find a second declaration of the nrf_nvic_state_t, does it exist anywhere else besides nrf_nvic.h?

    on top of that it mentions the include order of files, do you know if that matters? Do I have to load the s132 headers after or before something else?

  • I commented out the #ifndef NRF_SOC_H__ and #endif

    for this error: error: #256: invalid redeclaration of type name "nrf_nvic_state_t" (declared at line 88)

    Follow this path provided by the error: C:\Keil_v5\Nordic_SDK\nRF5_SDK_12.1.0_0d23e2a\components\drivers_nrf\nrf_soc_nosd\nrf_nvic.h(88)

  • add pathToDir\components\drivers_nrf\nrf_soc_nosd to the include paths in Options for Target

Related