]> www.average.org Git - pulsecounter.git/commitdiff
pass handler id to userspace
authorEugene Crosser <crosser@average.org>
Thu, 10 Dec 2015 20:34:32 +0000 (23:34 +0300)
committerEugene Crosser <crosser@average.org>
Thu, 10 Dec 2015 20:34:32 +0000 (23:34 +0300)
Hal/Hal.c
Hal/Hal.h
Pulsecounter-Prog.c

index b4944e2c79090a97dcba17ea049e04377d85a231..f7b801c4aed7174759f08fc616f26a4ade4f54d9 100644 (file)
--- 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 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];
 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 -------- */
 
 
 /* -------- APP-HAL INTERFACE -------- */
 
-void Hal_buttonEnable(void (*handler)(void)) {
+void Hal_buttonEnable(Hal_Handler handler) {
     handlerTab[BUTTON_HANDLER_ID] = buttonHandler;
     appButtonHandler = handler;
     BUTTON_CONFIG();
     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) {
 static void buttonHandler(uint8_t id) {
     Hal_delay(BUTTON_DEBOUNCE_MSECS);
     if (BUTTON_PRESSED() && appButtonHandler) {
-        appButtonHandler();
+        appButtonHandler(id);
     }
     BUTTON_ENABLE();
 }
     }
     BUTTON_ENABLE();
 }
index 9af8ec811cc1745daca6aedcb13f449177cc4935..aa5f7c2db816c31b6addefbe00e6093449b61527 100644 (file)
--- a/Hal/Hal.h
+++ b/Hal/Hal.h
@@ -47,7 +47,7 @@ typedef void (*Hal_Handler)(uint8_t id);
  *   BUTTON interrupt enabled
  *
  **/
  *   BUTTON interrupt enabled
  *
  **/
-extern void Hal_buttonEnable(void (*handler)(void));
+extern void Hal_buttonEnable(Hal_Handler handler);
 /**
  * --------- Hal_connected ---------
  *
 /**
  * --------- Hal_connected ---------
  *
index d5170af1a5adc722a38b1d86ef05883570e6ac85..5b9beab300232c87ff693167fecdb4a040ad3b49 100644 (file)
@@ -1,7 +1,7 @@
 #include "Pulsecounter.h"
 #include "Hal.h"
 
 #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;
 static void tickHandler(void);
 static bool connected = false;
 static int32_t base4 = 0;
@@ -19,7 +19,7 @@ void main() {
     Hal_idleLoop();
 }
 
     Hal_idleLoop();
 }
 
-static void buttonHandler(void) {
+static void buttonHandler(uint8_t id) {
     uint8_t i;
 
     cold = !cold;
     uint8_t i;
 
     cold = !cold;