From b89deaf8e31565fa2165bc502e05875028e91c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 25 Jul 2017 09:47:56 +0200 Subject: [PATCH] tap-v1/tap_pwr.c: make sure to invoke the button notification on registering the cb --- src/drivers/boards/tap-v1/tap_pwr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/drivers/boards/tap-v1/tap_pwr.c b/src/drivers/boards/tap-v1/tap_pwr.c index 040ebd0f01..156115b2ee 100644 --- a/src/drivers/boards/tap-v1/tap_pwr.c +++ b/src/drivers/boards/tap-v1/tap_pwr.c @@ -59,6 +59,9 @@ extern void led_on(int led); extern void led_off(int led); +static struct timespec time_down; + + /************************************************************************************ * Private Data ************************************************************************************/ @@ -80,6 +83,12 @@ static power_button_state_notification_t power_state_notification = default_powe int board_register_power_state_notification_cb(power_button_state_notification_t cb) { power_state_notification = cb; + + if (board_pwr_button_down() && (time_down.tv_nsec != 0 || time_down.tv_sec != 0)) { + // make sure we don't miss the first event + power_state_notification(PWR_BUTTON_DOWN); + } + return OK; } @@ -99,8 +108,6 @@ int board_shutdown() static int board_button_irq(int irq, FAR void *context) { - static struct timespec time_down; - if (board_pwr_button_down()) { led_on(BOARD_LED_RED);