From: Eugene Crosser Date: Thu, 10 Dec 2015 20:34:32 +0000 (+0300) Subject: pass handler id to userspace X-Git-Url: http://www.average.org/gitweb/?p=pulsecounter.git;a=commitdiff_plain;h=62d25e937392e215935ad07e554ef9b18dba18fe;hp=4868ec0934cb78bf2349296ec33401cf9ce4a953 pass handler id to userspace --- diff --git a/Hal/Hal.c b/Hal/Hal.c index b4944e2..f7b801c 100644 --- a/Hal/Hal.c +++ b/Hal/Hal.c @@ -97,7 +97,7 @@ static void buttonHandler(uint8_t id); static void postEvent(uint8_t handlerId); -static void (*appButtonHandler)(void); +static Hal_Handler appButtonHandler; static volatile uint16_t handlerEvents = 0; static uint16_t clockTick = 0; static Hal_Handler handlerTab[NUM_HANDLERS]; @@ -105,7 +105,7 @@ static Hal_Handler handlerTab[NUM_HANDLERS]; /* -------- APP-HAL INTERFACE -------- */ -void Hal_buttonEnable(void (*handler)(void)) { +void Hal_buttonEnable(Hal_Handler handler) { handlerTab[BUTTON_HANDLER_ID] = buttonHandler; appButtonHandler = handler; BUTTON_CONFIG(); @@ -331,7 +331,7 @@ void Em_Hal_watchOn(void) { static void buttonHandler(uint8_t id) { Hal_delay(BUTTON_DEBOUNCE_MSECS); if (BUTTON_PRESSED() && appButtonHandler) { - appButtonHandler(); + appButtonHandler(id); } BUTTON_ENABLE(); } diff --git a/Hal/Hal.h b/Hal/Hal.h index 9af8ec8..aa5f7c2 100644 --- a/Hal/Hal.h +++ b/Hal/Hal.h @@ -47,7 +47,7 @@ typedef void (*Hal_Handler)(uint8_t id); * BUTTON interrupt enabled * **/ -extern void Hal_buttonEnable(void (*handler)(void)); +extern void Hal_buttonEnable(Hal_Handler handler); /** * --------- Hal_connected --------- * diff --git a/Pulsecounter-Prog.c b/Pulsecounter-Prog.c index d5170af..5b9beab 100644 --- a/Pulsecounter-Prog.c +++ b/Pulsecounter-Prog.c @@ -1,7 +1,7 @@ #include "Pulsecounter.h" #include "Hal.h" -static void buttonHandler(void); +static void buttonHandler(uint8_t id); static void tickHandler(void); static bool connected = false; static int32_t base4 = 0; @@ -19,7 +19,7 @@ void main() { Hal_idleLoop(); } -static void buttonHandler(void) { +static void buttonHandler(uint8_t id) { uint8_t i; cold = !cold;