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

nrfx_gpiote_init undefined reference

Hi,

I have shifted from Arduino to nrf. Arduino is straight forward and with very less dev time. I understand this is way more powerful and next level platform, but does it have to be so painful to work on this platform? 

From the past four hours, I have been struggling with the implementation of the interrupt. I am looking at the code in the example "pin_change_int". Everything makes sense and when i copy the logic to my own program I get following GPIOTE errors. 

I have tried copying sdk_config.h GPIOTE text and enabling it from CMSIS editor. 

I have tried importing nrf_gpiote.c file from modules\nrfx\drivers\src

I watched the video that shows how to import driver. GPIOTE driver does not exist in the given folder

nrf_drv_gpiote. exists in the legacy folder. If it's legacy what is new? 

errors are

undefined reference to `nrfx_gpiote_init'

undefined reference to `nrfx_gpiote_in_init'

undefined reference to `nrfx_gpiote_in_event_enable'

  • It looks like you have either forgotten to add #include nrfx_gpiote.h to your source file or you have not added the nrfx_gpiote files to your project. 

    Check your sdk_config.h for nrfx_gpiote and make sure it is enabled. While you’re there you can also delete references to nrf_drv_gpiote. 

  • It is enabled in sdk_config. What source file are you referring? the example uses nrf_drv_gpiote..h

  • The simplest way is probably going to be to change the function calls in your original message to nrf_drv_gpiote_ rather than nrfx_gpiote_

  • That is what I had previously. The errors are interesting

  • For people out there they need to do the following. 

    1. Include file from nRF5_SDK\modules\nrfx\drivers\src\nrfx_gpiote.c

    2. Copy `sdk_config.h` text 

    //==========================================================
    // <e> GPIOTE_ENABLED - nrf_drv_gpiote - GPIOTE peripheral driver - legacy layer
    //==========================================================
    #ifndef GPIOTE_ENABLED
    #define GPIOTE_ENABLED 1
    #endif
    // <o> GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins 
    #ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
    #define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1
    #endif
    
    // <o> GPIOTE_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    
    // <i> Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef GPIOTE_CONFIG_IRQ_PRIORITY
    #define GPIOTE_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // </e>
    
    // <e> NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver
    //==========================================================
    #ifndef NRFX_GPIOTE_ENABLED
    #define NRFX_GPIOTE_ENABLED 1
    #endif
    // <o> NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins 
    #ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
    #define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1
    #endif
    
    // <o> NRFX_GPIOTE_CONFIG_IRQ_PRIORITY  - Interrupt priority
     
    // <0=> 0 (highest) 
    // <1=> 1 
    // <2=> 2 
    // <3=> 3 
    // <4=> 4 
    // <5=> 5 
    // <6=> 6 
    // <7=> 7 
    
    #ifndef NRFX_GPIOTE_CONFIG_IRQ_PRIORITY
    #define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6
    #endif
    
    // <e> NRFX_GPIOTE_CONFIG_LOG_ENABLED - Enables logging in the module.
    //==========================================================
    #ifndef NRFX_GPIOTE_CONFIG_LOG_ENABLED
    #define NRFX_GPIOTE_CONFIG_LOG_ENABLED 0
    #endif
    // <o> NRFX_GPIOTE_CONFIG_LOG_LEVEL  - Default Severity level
     
    // <0=> Off 
    // <1=> Error 
    // <2=> Warning 
    // <3=> Info 
    // <4=> Debug 
    
    #ifndef NRFX_GPIOTE_CONFIG_LOG_LEVEL
    #define NRFX_GPIOTE_CONFIG_LOG_LEVEL 3
    #endif
    
    // <o> NRFX_GPIOTE_CONFIG_INFO_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRFX_GPIOTE_CONFIG_INFO_COLOR
    #define NRFX_GPIOTE_CONFIG_INFO_COLOR 0
    #endif
    
    // <o> NRFX_GPIOTE_CONFIG_DEBUG_COLOR  - ANSI escape code prefix.
     
    // <0=> Default 
    // <1=> Black 
    // <2=> Red 
    // <3=> Green 
    // <4=> Yellow 
    // <5=> Blue 
    // <6=> Magenta 
    // <7=> Cyan 
    // <8=> White 
    
    #ifndef NRFX_GPIOTE_CONFIG_DEBUG_COLOR
    #define NRFX_GPIOTE_CONFIG_DEBUG_COLOR 0
    #endif
    
    // </e>
    
    // </e> REMOVE ME OR ELSE CMSIS WILL NOT WORK
    // </h> 

    3. Remove one // </e> from bottom of text out of 2 otherwise CMISS wont work

    4. Go armgcc folder and open makefile. in SRC files add $(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_gpiote.c \

    Too much to do for a simple task. 

Related