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

nAN-36 + nRF51822 PCA10028 APP_BUTTON_INIT [SOLVED]

in the code below, the keil IDE is flagging with red squiggly APP_BUTTON_INIT, claiming that it is an undefined symbol. It also says that this implicit declaration of 'APP_BUTTON_INIT' is not valid for c99

I called out the proper GPIOTE function before this and I have the "app_button.h" included. I dont know what to do this has been driving me crazy.

    static void buttons_init(void)
{   
    // Note: Array must be static because a pointer to it will be saved in the Button handler
    //       module.	
    static app_button_cfg_t buttons[] =
    {
        {WAKEUP_BUTTON_PIN, false, BUTTON_PULL, NULL},
        {LEDBUTTON_BUTTON_PIN_NO, false, BUTTON_PULL, button_event_handler}
    };

    APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, true);
			
}

TL;DR ANSWER Below:

The Correct solution was to replace

APP_BUTTON_INIT(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, true);

with

app_button_init(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY);

differences Note: the method is lower case, and the last parameter within said method is no longer defined.

Parents
  • The only way I can reproduce this is if I deliberately delete the #define APP_BUTTON_INIT(...) definition in app_button.h.

    Are you sure there are no typos or something in app_button.h? Is the file added to the include paths?

    If you download the example from git again (github.com/.../nrf51-ble-app-lbs), and put it in the SDK 7.1 examples/ble_peripheral folder without modifying it, does it compile?

    What happens if you replace the call to the APP_BUTTON_INIT macro in main.c with a direct call to app_button_init()? like this:

    app_button_init(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, app_button_evt_schedule);
    
Reply
  • The only way I can reproduce this is if I deliberately delete the #define APP_BUTTON_INIT(...) definition in app_button.h.

    Are you sure there are no typos or something in app_button.h? Is the file added to the include paths?

    If you download the example from git again (github.com/.../nrf51-ble-app-lbs), and put it in the SDK 7.1 examples/ble_peripheral folder without modifying it, does it compile?

    What happens if you replace the call to the APP_BUTTON_INIT macro in main.c with a direct call to app_button_init()? like this:

    app_button_init(buttons, sizeof(buttons) / sizeof(buttons[0]), BUTTON_DETECTION_DELAY, app_button_evt_schedule);
    
Children
Related