tap-v1/tap_pwr.c: make sure to invoke the button notification on registering the cb

This commit is contained in:
Beat Küng 2017-07-25 09:47:56 +02:00 committed by Lorenz Meier
parent c5a1d1928d
commit b89deaf8e3

View File

@ -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);