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

Custom button event not firing

I have modified pca10040.h as

#define BUTTONS_NUMBER 5

#define BUTTON_START   13
#define BUTTON_1       13
#define BUTTON_2       14
#define BUTTON_3       15
#define BUTTON_4       16
#define BUTTON_5       17
#define BUTTON_STOP    17
#define BUTTON_PULL    NRF_GPIO_PIN_PULLUP

#define BUTTONS_ACTIVE_STATE 0

#define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4, BUTTON_5 }

#define BSP_BUTTON_0   BUTTON_1
#define BSP_BUTTON_1   BUTTON_2
#define BSP_BUTTON_2   BUTTON_3
#define BSP_BUTTON_3   BUTTON_4
#define BSP_BUTTON_4   BUTTON_5

Modified sdk_config.h

#ifndef GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
#define GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 5
#endif

Add a button on breadboard one leg on gnd one on pin 17

On press i was expecting bsp_event_handler to get fired with event BSP_EVENT_KEY_4. But it did not.

So i added custom code to assign an event

err_code = bsp_event_to_button_action_assign(4,
                                                     BSP_BUTTON_ACTION_PUSH,
                                                     BSP_EVENT_KEY_4);
		
err_code = bsp_event_to_button_action_assign(4,
                                                 BSP_BUTTON_ACTION_RELEASE,
                                                 BSP_EVENT_KEY_4);
		
err_code = bsp_event_to_button_action_assign(4,
                                                 BSP_BUTTON_ACTION_LONG_PUSH,
                                                 BSP_EVENT_KEY_4);

But it still not firing. But if i assign new event to any of pca10040 boards button it works. But just does not work for custom button.

Assigning to pca10040 board button number 4

err_code = bsp_event_to_button_action_assign(3,
                                                 BSP_BUTTON_ACTION_RELEASE,
                                                 BSP_EVENT_KEY_5);

Also if i connect pin 16 (pca10040 button 4) to custom button on breadboard then also it works.

So i tried all combinations to make sure connections are right but my custom button code does not work. What is wrong with my code for custom button?

Related