Skip to main content

Wakeup from extended sleep mode by two different pins

DA14531

1 month ago

Posted by overleon 20 points 1 reply
0 upvotes

Hi there, I am setting the DA14531 to central mode, the process is 120ms sleeping and 30ms scanning for advertising, I have two different pin interruptions, P0_9 and P0_6, since I am sending to extended sleep mode to the DA I am using the functions wkupct_enable_irq() and wkupct_register_callback() to set the pins.

interrupt activate function

When I set the two pins as interrupt wakeup only the lastest configured works.

Is there a way to set two different pins to wake up the DA14531 from extended sleep mode?

 

Thanks.

1 month ago

AA_Dialog

Hi overleon,

Thank you for your comment online.

We created a small demo based on SDK’s ble_app_sleepmode example that showcases waking up from two different pins. By adding the code below in the button configuration section in user_periph_setup.h

#define GPIO_BUTTON_PORT        GPIO_PORT_0
#define GPIO_BUTTON_PIN         GPIO_PIN_11
		
#define GPIO_BUTTON_PORT_2      GPIO_PORT_0
#define GPIO_BUTTON_PIN_2       GPIO_PIN_9

the code below to function GPIO_reservations in user_periph_setup.c

RESERVE_GPIO(PUSH_BUTTON, GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, PID_GPIO);
RESERVE_GPIO(PUSH_BUTTON_2, GPIO_BUTTON_PORT_2, GPIO_BUTTON_PIN_2, PID_GPIO);

and the code below to function set_pad_functions in user_periph_setup.c

GPIO_ConfigurePin(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, INPUT_PULLUP, PID_GPIO, false);
GPIO_ConfigurePin(GPIO_BUTTON_PORT_2, GPIO_BUTTON_PIN_2, INPUT_PULLUP, PID_GPIO, false);

 we reserve and configure pins 9 and 11.

Adding the code below to function app_button in user_sleepmode.c 

static void app_button_enable(void)
{
    app_easy_wakeup_set(app_wakeup_cb);
    wkupct_register_callback(app_button_press_cb);
    wkupct_enable_irq( ( WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN) |  
	                     WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT_2, GPIO_BUTTON_PIN_2) ), // select pin 
                        (WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW) | 
	                       WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT_2, GPIO_BUTTON_PIN_2, WKUPCT_PIN_POLARITY_LOW)), // polarity low
                                          1, // 1 event
                                          40); // debouncing time = 0
}

we set up the wake up controller to wake DA14531 up from both pins 9 and 11.

 

Thank you, AA_Dialog