From a093ad6f13b6eb46075c179ade93bf07fb0d93a0 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 31 Aug 2017 14:17:35 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10515 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/STM32/multi/PAL/cfg-stm32l476_discovery/portab.h | 1 + testhal/STM32/multi/PAL/main.c | 16 +++++++--------- 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(); } -- cgit v1.2.3