aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testhal/STM32/multi/PAL/cfg-stm32l476_discovery/portab.h1
-rw-r--r--testhal/STM32/multi/PAL/main.c16
2 files changed, 8 insertions, 9 deletions
diff --git a/testhal/STM32/multi/PAL/cfg-stm32l476_discovery/portab.h b/testhal/STM32/multi/PAL/cfg-stm32l476_discovery/portab.h
index a887e3190..69ebdd3d1 100644
--- a/testhal/STM32/multi/PAL/cfg-stm32l476_discovery/portab.h
+++ b/testhal/STM32/multi/PAL/cfg-stm32l476_discovery/portab.h
@@ -32,6 +32,7 @@
#define PORTAB_LINE_LED1 LINE_LED_GREEN
#define PORTAB_LINE_LED2 LINE_LED_RED
#define PORTAB_LINE_BUTTON LINE_JOY_CENTER
+#define PORTAB_BUTTON_PRESSED PAL_HIGH
/*===========================================================================*/
/* Module pre-compile time settings. */
diff --git a/testhal/STM32/multi/PAL/main.c b/testhal/STM32/multi/PAL/main.c
index 81d520cc5..5c1660c50 100644
--- a/testhal/STM32/multi/PAL/main.c
+++ b/testhal/STM32/multi/PAL/main.c
@@ -31,28 +31,26 @@ static THD_FUNCTION(Thread1, arg) {
(void)arg;
chRegSetThreadName("blinker");
while (true) {
- systime_t time = palReadLine(PORTAB_LINE_BUTTON) == PAL_LOW ? 500 : 250;
- palClearLine(PORTAB_LINE_LED2);
- chThdSleepMilliseconds(time);
- palSetLine(PORTAB_LINE_LED2);
+ systime_t time = palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED ? 250 : 500;
+ palToggleLine(PORTAB_LINE_LED2);
chThdSleepMilliseconds(time);
}
}
#endif
-event_source_t button_pressed_event;
-event_source_t button_released_event;
+static event_source_t button_pressed_event;
+static event_source_t button_released_event;
static void button_cb(void *arg) {
(void)arg;
chSysLockFromISR();
- if (palReadLine(PORTAB_LINE_BUTTON) == PAL_LOW) {
- chEvtBroadcastI(&button_released_event);
+ if (palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED) {
+ chEvtBroadcastI(&button_pressed_event);
}
else {
- chEvtBroadcastI(&button_pressed_event);
+ chEvtBroadcastI(&button_released_event);
}
chSysUnlockFromISR();
}