From de948189c313a4b5b036aed8ecdb0e397fbd110f Mon Sep 17 00:00:00 2001 From: smlng Date: Tue, 20 Jun 2017 21:11:34 +0200 Subject: [PATCH] periph: generalized button macros --- boards/calliope-mini/include/board.h | 3 +++ boards/calliope-mini/include/gpio_params.h | 9 +++++---- boards/cc2650stk/include/board.h | 7 +++++-- boards/maple-mini/include/board.h | 6 +++++- boards/maple-mini/include/gpio_params.h | 5 +++-- boards/microbit/include/board.h | 3 +++ boards/microbit/include/gpio_params.h | 9 +++++---- boards/nrf52840dk/include/board.h | 14 +++++++++----- boards/nrf52840dk/include/gpio_params.h | 18 +++++++++--------- boards/nrf52dk/include/board.h | 14 +++++++++----- boards/nrf52dk/include/gpio_params.h | 18 +++++++++--------- boards/nucleo-common/include/board_common.h | 6 +++++- boards/nucleo-common/include/gpio_params.h | 5 +++-- boards/nucleo144-common/include/board_common.h | 6 +++++- boards/nucleo144-common/include/gpio_params.h | 5 +++-- boards/opencm904/include/board.h | 6 +++++- boards/pba-d-01-kw2x/include/board.h | 13 +++++++------ boards/pba-d-01-kw2x/include/gpio_params.h | 8 ++++---- boards/remote-pa/include/board.h | 4 +++- boards/remote-pa/include/gpio_params.h | 6 +++--- boards/remote-reva/include/board.h | 4 +++- boards/remote-reva/include/gpio_params.h | 6 +++--- boards/remote-revb/include/board.h | 4 +++- boards/remote-revb/include/gpio_params.h | 6 +++--- boards/samd21-xpro/board.c | 4 ++-- boards/samd21-xpro/include/board.h | 7 ++++--- boards/samd21-xpro/include/gpio_params.h | 5 +++-- boards/saml21-xpro/include/board.h | 10 ++++++++-- boards/samr21-xpro/include/board.h | 7 ++++--- boards/samr21-xpro/include/gpio_params.h | 5 +++-- boards/stm32f0discovery/include/board.h | 6 +++++- boards/stm32f0discovery/include/gpio_params.h | 5 +++-- boards/stm32f3discovery/include/board.h | 7 ++++++- boards/stm32f3discovery/include/gpio_params.h | 5 +++-- boards/stm32f4discovery/include/board.h | 7 ++++++- boards/stm32f4discovery/include/gpio_params.h | 5 +++-- boards/stm32f7discovery/include/board.h | 7 ++++++- boards/stm32f7discovery/include/gpio_params.h | 5 +++-- boards/z1/include/board.h | 9 +++++---- 39 files changed, 179 insertions(+), 100 deletions(-) diff --git a/boards/calliope-mini/include/board.h b/boards/calliope-mini/include/board.h index 6da549ddb6..10da777c1f 100644 --- a/boards/calliope-mini/include/board.h +++ b/boards/calliope-mini/include/board.h @@ -16,6 +16,7 @@ * @brief Board specific configuration for the Calliope mini * * @author Hauke Petersen + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -61,7 +62,9 @@ extern "C" { * @{ */ #define BTN0_PIN GPIO_PIN(0, 17) +#define BTN0_MODE GPIO_IN #define BTN1_PIN GPIO_PIN(0, 26) +#define BTN1_MODE GPIO_IN /** @} */ /** diff --git a/boards/calliope-mini/include/gpio_params.h b/boards/calliope-mini/include/gpio_params.h index 3446944a81..e0d792caa9 100644 --- a/boards/calliope-mini/include/gpio_params.h +++ b/boards/calliope-mini/include/gpio_params.h @@ -14,6 +14,7 @@ * @brief Board specific configuration of direct mapped GPIOs * * @author Hauke Petersen + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -33,13 +34,13 @@ static const saul_gpio_params_t saul_gpio_params[] = { { .name = "Button A", - .pin = BTN0_PIN, - .mode = GPIO_IN + .pin = BTN0_PIN, + .mode = BTN0_MODE }, { .name = "Button B", - .pin = BTN1_PIN, - .mode = GPIO_IN + .pin = BTN1_PIN, + .mode = BTN1_MODE }, }; diff --git a/boards/cc2650stk/include/board.h b/boards/cc2650stk/include/board.h index a265863f23..d32aa681f0 100644 --- a/boards/cc2650stk/include/board.h +++ b/boards/cc2650stk/include/board.h @@ -16,6 +16,7 @@ * @brief Board configuration for the CC2650STK * * @author Leon M. George + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -38,8 +39,10 @@ extern "C" { * @name On-board button configuration * @{ */ -#define BUTTON1_DIO GPIO_PIN(0, 4) -#define BUTTON2_DIO GPIO_PIN(0, 0) +#define BTN0_PIN GPIO_PIN(0, 4) +#define BTN0_MODE GPIO_IN +#define BTN1_PIN GPIO_PIN(0, 0) +#define BTN1_MODE GPIO_IN /** @} */ /** diff --git a/boards/maple-mini/include/board.h b/boards/maple-mini/include/board.h index 3551c71825..ad8c74f52b 100644 --- a/boards/maple-mini/include/board.h +++ b/boards/maple-mini/include/board.h @@ -16,6 +16,7 @@ * @brief Board specific definitions for the maple-mini board * * @author Frits Kuipers + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -49,8 +50,11 @@ extern "C" { /** * @brief User button + * @{ */ -#define BTN_B1_PIN GPIO_PIN(PORT_B, 8) +#define BTN0_PIN GPIO_PIN(PORT_B, 8) +#define BTN0_MODE GPIO_IN +/** @} */ /** * @brief Use the USART1 for STDIO on this board diff --git a/boards/maple-mini/include/gpio_params.h b/boards/maple-mini/include/gpio_params.h index 7a8b36e291..716a6c17c1 100644 --- a/boards/maple-mini/include/gpio_params.h +++ b/boards/maple-mini/include/gpio_params.h @@ -14,6 +14,7 @@ * @brief Board specific configuration of direct mapped GPIOs * * @author Frits Kuipers + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -38,8 +39,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "BUTTON", - .pin = BTN_B1_PIN, - .mode = GPIO_IN + .pin = BTN0_PIN, + .mode = BTN0_MODE } }; diff --git a/boards/microbit/include/board.h b/boards/microbit/include/board.h index 5ae51646d4..00a407b517 100644 --- a/boards/microbit/include/board.h +++ b/boards/microbit/include/board.h @@ -16,6 +16,7 @@ * @brief Board specific configuration for the BBC micro:bit * * @author Hauke Petersen + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -61,7 +62,9 @@ extern "C" { * @{ */ #define BTN0_PIN GPIO_PIN(0, 17) +#define BTN0_MODE GPIO_IN #define BTN1_PIN GPIO_PIN(0, 26) +#define BTN1_MODE GPIO_IN /** @} */ /** diff --git a/boards/microbit/include/gpio_params.h b/boards/microbit/include/gpio_params.h index 663cea553a..a62f570449 100644 --- a/boards/microbit/include/gpio_params.h +++ b/boards/microbit/include/gpio_params.h @@ -14,6 +14,7 @@ * @brief Board specific configuration of direct mapped GPIOs * * @author Hauke Petersen + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -33,13 +34,13 @@ static const saul_gpio_params_t saul_gpio_params[] = { { .name = "Button A", - .pin = BTN0_PIN, - .mode = GPIO_IN + .pin = BTN0_PIN, + .mode = BTN0_MODE }, { .name = "Button B", - .pin = BTN1_PIN, - .mode = GPIO_IN + .pin = BTN1_PIN, + .mode = BTN1_MODE }, }; diff --git a/boards/nrf52840dk/include/board.h b/boards/nrf52840dk/include/board.h index 544e434a76..ad7411551d 100644 --- a/boards/nrf52840dk/include/board.h +++ b/boards/nrf52840dk/include/board.h @@ -15,7 +15,7 @@ * @brief Board specific configuration for the nRF52840 DK * * @author Hauke Petersen - * + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -63,10 +63,14 @@ extern "C" { * @name Button pin configuration * @{ */ -#define BUTTON1_PIN (GPIO_PIN(0, 11)) -#define BUTTON2_PIN (GPIO_PIN(0, 12)) -#define BUTTON3_PIN (GPIO_PIN(0, 24)) -#define BUTTON4_PIN (GPIO_PIN(0, 25)) +#define BTN0_PIN GPIO_PIN(0, 11) +#define BTN0_MODE GPIO_IN_PU +#define BTN1_PIN GPIO_PIN(0, 12) +#define BTN1_MODE GPIO_IN_PU +#define BTN2_PIN GPIO_PIN(0, 24) +#define BTN2_MODE GPIO_IN_PU +#define BTN3_PIN GPIO_PIN(0, 25) +#define BTN3_MODE GPIO_IN_PU /** @} */ /** diff --git a/boards/nrf52840dk/include/gpio_params.h b/boards/nrf52840dk/include/gpio_params.h index 24395ee9cb..d3b9e58ddb 100644 --- a/boards/nrf52840dk/include/gpio_params.h +++ b/boards/nrf52840dk/include/gpio_params.h @@ -14,7 +14,7 @@ * @brief Configuration of SAUL mapped GPIO pins * * @author Hauke Petersen - * + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -54,23 +54,23 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "Button 1", - .pin = BUTTON1_PIN, - .mode = GPIO_IN_PU + .pin = BTN0_PIN, + .mode = BTN0_MODE }, { .name = "Button 2", - .pin = BUTTON2_PIN, - .mode = GPIO_IN_PU + .pin = BTN1_PIN, + .mode = BTN1_MODE }, { .name = "Button 3", - .pin = BUTTON3_PIN, - .mode = GPIO_IN_PU + .pin = BTN2_PIN, + .mode = BTN2_MODE }, { .name = "Button 4", - .pin = BUTTON4_PIN, - .mode = GPIO_IN_PU + .pin = BTN3_PIN, + .mode = BTN3_MODE } }; diff --git a/boards/nrf52dk/include/board.h b/boards/nrf52dk/include/board.h index 7794dc6e0a..74db1ac1c6 100644 --- a/boards/nrf52dk/include/board.h +++ b/boards/nrf52dk/include/board.h @@ -15,7 +15,7 @@ * @brief Board specific configuaration for the nRF52 DK * * @author Hauke Petersen - * + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -62,10 +62,14 @@ extern "C" { * @name Button pin configuration * @{ */ -#define BUTTON1_PIN (GPIO_PIN(0, 13)) -#define BUTTON2_PIN (GPIO_PIN(0, 14)) -#define BUTTON3_PIN (GPIO_PIN(0, 15)) -#define BUTTON4_PIN (GPIO_PIN(0, 16)) +#define BTN0_PIN GPIO_PIN(0, 13) +#define BTN0_MODE GPIO_IN_PU +#define BTN1_PIN GPIO_PIN(0, 14) +#define BTN1_MODE GPIO_IN_PU +#define BTN2_PIN GPIO_PIN(0, 15) +#define BTN2_MODE GPIO_IN_PU +#define BTN3_PIN GPIO_PIN(0, 16) +#define BTN3_MODE GPIO_IN_PU /** @} */ /** diff --git a/boards/nrf52dk/include/gpio_params.h b/boards/nrf52dk/include/gpio_params.h index bb1846a064..77525b4c87 100644 --- a/boards/nrf52dk/include/gpio_params.h +++ b/boards/nrf52dk/include/gpio_params.h @@ -14,7 +14,7 @@ * @brief Configuration of SAUL mapped GPIO pins * * @author Hauke Petersen - * + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -54,23 +54,23 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "Button 1", - .pin = BUTTON1_PIN, - .mode = GPIO_IN_PU + .pin = BTN0_PIN, + .mode = BTN0_MODE }, { .name = "Button 2", - .pin = BUTTON2_PIN, - .mode = GPIO_IN_PU + .pin = BTN1_PIN, + .mode = BTN1_MODE }, { .name = "Button 3", - .pin = BUTTON3_PIN, - .mode = GPIO_IN_PU + .pin = BTN2_PIN, + .mode = BTN2_MODE }, { .name = "Button 4", - .pin = BUTTON4_PIN, - .mode = GPIO_IN_PU + .pin = BTN3_PIN, + .mode = BTN3_MODE } }; diff --git a/boards/nucleo-common/include/board_common.h b/boards/nucleo-common/include/board_common.h index 2c5b62b3d0..b4315667a7 100644 --- a/boards/nucleo-common/include/board_common.h +++ b/boards/nucleo-common/include/board_common.h @@ -16,6 +16,7 @@ * @brief Common pin definitions and board configuration options * * @author Hauke Petersen + * @author Sebastian Meiling */ #ifndef BOARD_COMMON_H @@ -48,8 +49,11 @@ extern "C" { /** * @brief User button + * @{ */ -#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) +#define BTN0_PIN GPIO_PIN(PORT_C, 13) +#define BTN0_MODE GPIO_IN_PU +/** @} */ /** * @brief Initialize board specific hardware, including clock, LEDs and std-IO diff --git a/boards/nucleo-common/include/gpio_params.h b/boards/nucleo-common/include/gpio_params.h index 21f538cd01..40e4db59bd 100644 --- a/boards/nucleo-common/include/gpio_params.h +++ b/boards/nucleo-common/include/gpio_params.h @@ -14,6 +14,7 @@ * @brief Board specific configuration of direct mapped GPIOs * * @author Alexandre Abadie + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -40,8 +41,8 @@ static const saul_gpio_params_t saul_gpio_params[] = #endif { .name = "Button(B1 User)", - .pin = BTN_B1_PIN, - .mode = GPIO_IN_PU + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/nucleo144-common/include/board_common.h b/boards/nucleo144-common/include/board_common.h index 0d02b61f27..e0ade1b958 100644 --- a/boards/nucleo144-common/include/board_common.h +++ b/boards/nucleo144-common/include/board_common.h @@ -18,6 +18,7 @@ * * @author Alexandre Abadie * @author Vincent Dupont + * @author Sebastian Meiling */ #ifndef BOARD_COMMON_H @@ -56,8 +57,11 @@ extern "C" { /** * @brief User button + * @{ */ -#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) +#define BTN0_PIN GPIO_PIN(PORT_C, 13) +#define BTN0_MODE GPIO_IN_PD +/** @} */ /** * @brief Initialize board specific hardware, including clock, LEDs and std-IO diff --git a/boards/nucleo144-common/include/gpio_params.h b/boards/nucleo144-common/include/gpio_params.h index ead07268f6..b4e07b58ca 100644 --- a/boards/nucleo144-common/include/gpio_params.h +++ b/boards/nucleo144-common/include/gpio_params.h @@ -14,6 +14,7 @@ * @brief Board specific configuration of direct mapped GPIOs * * @author Alexandre Abadie + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -48,8 +49,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "B1(User button)", - .pin = BTN_B1_PIN, - .mode = GPIO_IN_PD + .pin = BTN0_PIN, + .mode = BTN0_MODE } }; diff --git a/boards/opencm904/include/board.h b/boards/opencm904/include/board.h index badeb5bfb7..0a52fd5436 100755 --- a/boards/opencm904/include/board.h +++ b/boards/opencm904/include/board.h @@ -16,6 +16,7 @@ * @brief Board specific definitions for the OpenCM9.04 board * * @author Loïc Dauphin + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -49,8 +50,11 @@ extern "C" { /** * @brief User button + * @{ */ -#define BTN_B1_PIN GPIO_PIN(PORT_C, 15) +#define BTN0_PIN GPIO_PIN(PORT_C, 15) +#define BTN0_MODE GPIO_IN +/** @} */ /** * @brief Pin used to switch RX and TX mode for the Dynamixel TTL bus diff --git a/boards/pba-d-01-kw2x/include/board.h b/boards/pba-d-01-kw2x/include/board.h index 3e727e6cc7..0fae76f959 100644 --- a/boards/pba-d-01-kw2x/include/board.h +++ b/boards/pba-d-01-kw2x/include/board.h @@ -17,6 +17,7 @@ * @brief Board specific definitions for the phyWAVE evaluation board * * @author Johann Fischer + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -59,18 +60,18 @@ extern "C" * @name Macro for button S1/S2. * @{ */ -#define BUTTON_PORT PORTD -#define BUTTON_PIN 1 -#define BUTTON_GPIO GPIO_PIN(PORT_D, BUTTON_PIN) +#define BTN0_PORT PORTD +#define BTN0_PIN GPIO_PIN(PORT_D, 1) +#define BTN0_MODE GPIO_IN_PU /** @} */ /** * @name Macro for capacitive sensor button. * @{ */ -#define CS_BUTTON_PORT PORTC -#define CS_BUTTON_PIN 6 -#define CS_BUTTON_GPIO GPIO_PIN(PORT_C, CS_BUTTON_PIN) +#define BTN1_PORT PORTC +#define BTN1_PIN GPIO_PIN(PORT_C, 6) +#define BTN1_MODE GPIO_IN /** @} */ /** diff --git a/boards/pba-d-01-kw2x/include/gpio_params.h b/boards/pba-d-01-kw2x/include/gpio_params.h index 28832d0bfb..dd67086216 100644 --- a/boards/pba-d-01-kw2x/include/gpio_params.h +++ b/boards/pba-d-01-kw2x/include/gpio_params.h @@ -48,13 +48,13 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "Button(SW0)", - .pin = BUTTON_GPIO, - .mode = GPIO_IN_PU + .pin = BTN0_PIN, + .mode = BTN0_MODE }, { .name = "Button(CS0)", - .pin = CS_BUTTON_GPIO, - .mode = GPIO_IN + .pin = BTN1_PIN, + .mode = BTN1_MODE }, }; diff --git a/boards/remote-pa/include/board.h b/boards/remote-pa/include/board.h index c5543aa129..c4588f651c 100644 --- a/boards/remote-pa/include/board.h +++ b/boards/remote-pa/include/board.h @@ -17,7 +17,8 @@ * @brief Board specific definitions for the Re-Mote board prototype A * * @author Hauke Petersen - * Antonio Lignan + * @author Antonio Lignan + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -60,6 +61,7 @@ * @{ */ #define BTN0_PIN GPIO_PIN(0, 3) +#define BTN0_MODE GPIO_IN_PU /** @} */ /** diff --git a/boards/remote-pa/include/gpio_params.h b/boards/remote-pa/include/gpio_params.h index a98d7d9bc5..f1487ccec3 100644 --- a/boards/remote-pa/include/gpio_params.h +++ b/boards/remote-pa/include/gpio_params.h @@ -13,7 +13,7 @@ * @file * @brief Board specific configuration of direct mapped GPIOs * - * @author smlng + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -48,8 +48,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "Button(User)", - .pin = BTN0_PIN, - .mode = GPIO_IN_PU + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/remote-reva/include/board.h b/boards/remote-reva/include/board.h index ba9e1a5a5e..3ac3609457 100644 --- a/boards/remote-reva/include/board.h +++ b/boards/remote-reva/include/board.h @@ -17,7 +17,8 @@ * @brief Board specific definitions for the RE-Mote board Revision A * * @author Hauke Petersen - * Antonio Lignan + * @author Antonio Lignan + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -60,6 +61,7 @@ * @{ */ #define BTN0_PIN GPIO_PIN(0, 3) +#define BTN0_MODE GPIO_IN_PU /** @} */ /** diff --git a/boards/remote-reva/include/gpio_params.h b/boards/remote-reva/include/gpio_params.h index 9a079e3dcd..ab2591a464 100644 --- a/boards/remote-reva/include/gpio_params.h +++ b/boards/remote-reva/include/gpio_params.h @@ -13,7 +13,7 @@ * @file * @brief Board specific configuration of direct mapped GPIOs * - * @author smlng + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -48,8 +48,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "Button(User)", - .pin = BTN0_PIN, - .mode = GPIO_IN_PU + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/remote-revb/include/board.h b/boards/remote-revb/include/board.h index 44b8535c9f..31605708fa 100644 --- a/boards/remote-revb/include/board.h +++ b/boards/remote-revb/include/board.h @@ -17,7 +17,8 @@ * @brief Board specific definitions for the RE-Mote board Revision B * * @author Hauke Petersen - * Antonio Lignan + * @author Antonio Lignan + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -60,6 +61,7 @@ * @{ */ #define BTN0_PIN GPIO_PIN(0, 3) +#define BTN0_MODE GPIO_IN_PU /** @} */ /** diff --git a/boards/remote-revb/include/gpio_params.h b/boards/remote-revb/include/gpio_params.h index 30d787c108..7179dd585e 100644 --- a/boards/remote-revb/include/gpio_params.h +++ b/boards/remote-revb/include/gpio_params.h @@ -13,7 +13,7 @@ * @file * @brief Board specific configuration of direct mapped GPIOs * - * @author smlng + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -48,8 +48,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "Button(User)", - .pin = BTN0_PIN, - .mode = GPIO_IN_PU + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/samd21-xpro/board.c b/boards/samd21-xpro/board.c index d783e6338d..6bc1d2f114 100644 --- a/boards/samd21-xpro/board.c +++ b/boards/samd21-xpro/board.c @@ -17,7 +17,7 @@ * * @author Travis Griggs * @author Dan Evans - * + * @author Sebastian Meiling * @} */ @@ -30,7 +30,7 @@ void board_init(void) gpio_init(LED0_PIN, GPIO_OUT); /* initialize the on-board button */ - gpio_init(BUTTON_GPIO, GPIO_IN_PU); + gpio_init(BTN0_PIN, BTN0_MODE); /* initialize the CPU */ cpu_init(); diff --git a/boards/samd21-xpro/include/board.h b/boards/samd21-xpro/include/board.h index bb900df619..6e76969210 100644 --- a/boards/samd21-xpro/include/board.h +++ b/boards/samd21-xpro/include/board.h @@ -19,6 +19,7 @@ * * @author Travis Griggs * @author Dan Evans + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -58,9 +59,9 @@ extern "C" { * @name SW0 (Button) pin definitions * @{ */ -#define BUTTON_PORT PORT->Group[PA] -#define BUTTON_PIN (15) -#define BUTTON_GPIO GPIO_PIN(PA, BUTTON_PIN) +#define BTN0_PORT PORT->Group[PA] +#define BTN0_PIN GPIO_PIN(PA, 15) +#define BTN0_MODE GPIO_IN_PU /** @} */ /** diff --git a/boards/samd21-xpro/include/gpio_params.h b/boards/samd21-xpro/include/gpio_params.h index 9617a99e7b..c23fae9b71 100644 --- a/boards/samd21-xpro/include/gpio_params.h +++ b/boards/samd21-xpro/include/gpio_params.h @@ -16,6 +16,7 @@ * * @author Travis Griggs * @author Dan Evans + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -40,8 +41,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "Button(SW0)", - .pin = BUTTON_GPIO, - .mode = GPIO_IN_PU + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/saml21-xpro/include/board.h b/boards/saml21-xpro/include/board.h index 8e60c2ed7e..1a86db913d 100644 --- a/boards/saml21-xpro/include/board.h +++ b/boards/saml21-xpro/include/board.h @@ -16,6 +16,7 @@ * @brief Board specific definitions for the Atmel SAM L21 Xplained Pro board. * * @author Thomas Eichinger + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -42,9 +43,14 @@ extern "C" { /** @} */ /** - * @brief User button pin + * @name SW0 (Button) pin definitions + * @{ */ -#define SW0_PIN GPIO_PIN(PA, 2) +#define BTN0_PORT PORT->Group[PA] +#define BTN0_PIN GPIO_PIN(PA, 2) +#define BTN0_MODE GPIO_IN_PU +/** @} */ + /** * @brief Initialize board specific hardware, including clock, LEDs and std-IO diff --git a/boards/samr21-xpro/include/board.h b/boards/samr21-xpro/include/board.h index fbb71133a9..1d579c6701 100644 --- a/boards/samr21-xpro/include/board.h +++ b/boards/samr21-xpro/include/board.h @@ -17,6 +17,7 @@ * board * * @author Thomas Eichinger + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -68,9 +69,9 @@ extern "C" { * @name SW0 (Button) pin definitions * @{ */ -#define BUTTON_PORT PORT->Group[0] -#define BUTTON_PIN (28) -#define BUTTON_GPIO GPIO_PIN(0, BUTTON_PIN) +#define BTN0_PORT PORT->Group[0] +#define BTN0_PIN GPIO_PIN(0, 28) +#define BTN0_MODE GPIO_IN_PU /** @} */ /** diff --git a/boards/samr21-xpro/include/gpio_params.h b/boards/samr21-xpro/include/gpio_params.h index 6adf9f9744..30ba529089 100644 --- a/boards/samr21-xpro/include/gpio_params.h +++ b/boards/samr21-xpro/include/gpio_params.h @@ -16,6 +16,7 @@ * * @author Hauke Petersen * @author Kaspar Schleiser + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -40,8 +41,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "Button(SW0)", - .pin = BUTTON_GPIO, - .mode = GPIO_IN_PU + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/stm32f0discovery/include/board.h b/boards/stm32f0discovery/include/board.h index 0ee41267a6..9a772889aa 100644 --- a/boards/stm32f0discovery/include/board.h +++ b/boards/stm32f0discovery/include/board.h @@ -16,6 +16,7 @@ * @brief Board specific definitions for the STM32F0Discovery evaluation board. * * @author Hauke Petersen + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -49,8 +50,11 @@ extern "C" { /** * @brief User button + * @{ */ -#define BTN_B1_PIN GPIO_PIN(PORT_A, 0) +#define BTN0_PIN GPIO_PIN(PORT_A, 0) +#define BTN0_MODE GPIO_IN +/** @} */ /** * @brief Initialize board specific hardware, including clock, LEDs and std-IO diff --git a/boards/stm32f0discovery/include/gpio_params.h b/boards/stm32f0discovery/include/gpio_params.h index 93d1dd8a83..4000d384bd 100644 --- a/boards/stm32f0discovery/include/gpio_params.h +++ b/boards/stm32f0discovery/include/gpio_params.h @@ -16,6 +16,7 @@ * * @author Hauke Petersen * @author Alexandre Abadie + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -45,8 +46,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "BTN USER", - .pin = BTN_B1_PIN, - .mode = GPIO_IN + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/stm32f3discovery/include/board.h b/boards/stm32f3discovery/include/board.h index 13168e6b3b..4f5566706e 100644 --- a/boards/stm32f3discovery/include/board.h +++ b/boards/stm32f3discovery/include/board.h @@ -16,6 +16,7 @@ * @brief Board specific definitions for the STM32F3Discovery evaluation board * * @author Hauke Petersen + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -85,8 +86,12 @@ extern "C" { /** * @brief User button + * @{ */ -#define BTN_B1_PIN GPIO_PIN(PORT_A, 0) +#define BTN0_PIN GPIO_PIN(PORT_A, 0) +#define BTN0_MODE GPIO_IN +/** @} */ + /** * @brief Initialize board specific hardware, including clock, LEDs and std-IO diff --git a/boards/stm32f3discovery/include/gpio_params.h b/boards/stm32f3discovery/include/gpio_params.h index 954d6a9655..72d1296ff4 100644 --- a/boards/stm32f3discovery/include/gpio_params.h +++ b/boards/stm32f3discovery/include/gpio_params.h @@ -14,6 +14,7 @@ * @brief Board specific configuration of direct mapped GPIOs * * @author Hauke Petersen + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -73,8 +74,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "BTN USER", - .pin = BTN_B1_PIN, - .mode = GPIO_IN + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/stm32f4discovery/include/board.h b/boards/stm32f4discovery/include/board.h index 1a48beae8b..be294a14d6 100644 --- a/boards/stm32f4discovery/include/board.h +++ b/boards/stm32f4discovery/include/board.h @@ -16,6 +16,7 @@ * @brief Board specific definitions for the STM32F4Discovery evaluation board * * @author Hauke Petersen + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -78,8 +79,12 @@ extern "C" { /** * @brief User button + * @{ */ -#define BTN_B1_PIN GPIO_PIN(PORT_A, 0) +#define BTN0_PIN GPIO_PIN(PORT_A, 0) +#define BTN0_MODE GPIO_IN +/** @} */ + /** * @brief Initialize board specific hardware, including clock, LEDs and std-IO diff --git a/boards/stm32f4discovery/include/gpio_params.h b/boards/stm32f4discovery/include/gpio_params.h index c33bacb114..54149f2ec7 100644 --- a/boards/stm32f4discovery/include/gpio_params.h +++ b/boards/stm32f4discovery/include/gpio_params.h @@ -16,6 +16,7 @@ * * @author Hauke Petersen * @author Alexandre Abadie + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -55,8 +56,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "BTN USER", - .pin = BTN_B1_PIN, - .mode = GPIO_IN + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/stm32f7discovery/include/board.h b/boards/stm32f7discovery/include/board.h index a7992746ba..8444f0600f 100644 --- a/boards/stm32f7discovery/include/board.h +++ b/boards/stm32f7discovery/include/board.h @@ -16,6 +16,7 @@ * @brief Board specific definitions for the stm32f769 Discovery board * * @author Vincent Dupont + * @author Sebastian Meiling */ #ifndef BOARD_H @@ -65,8 +66,12 @@ extern "C" { /** * @brief User button + * @{ */ -#define BTN_B1_PIN GPIO_PIN(PORT_A, 0) +#define BTN0_PIN GPIO_PIN(PORT_A, 0) +#define BTN0_MODE GPIO_IN +/** @} */ + /** * @brief Initialize board specific hardware, including clock, LEDs and std-IO diff --git a/boards/stm32f7discovery/include/gpio_params.h b/boards/stm32f7discovery/include/gpio_params.h index e4448a329b..face78a11e 100644 --- a/boards/stm32f7discovery/include/gpio_params.h +++ b/boards/stm32f7discovery/include/gpio_params.h @@ -14,6 +14,7 @@ * @brief Board specific configuration of direct mapped GPIOs * * @author Vincent Dupont + * @author Sebastian Meiling */ #ifndef GPIO_PARAMS_H @@ -53,8 +54,8 @@ static const saul_gpio_params_t saul_gpio_params[] = }, { .name = "BTN USER", - .pin = BTN_B1_PIN, - .mode = GPIO_IN + .pin = BTN0_PIN, + .mode = BTN0_MODE }, }; diff --git a/boards/z1/include/board.h b/boards/z1/include/board.h index 9b1dc254a0..ba4943b111 100644 --- a/boards/z1/include/board.h +++ b/boards/z1/include/board.h @@ -98,11 +98,12 @@ extern "C" { * @name User button configuration * @{ */ -#define USER_BTN_PxIN P2IN -#define USER_BTN_MASK 0x20 +#define BTN0_PIN P2IN +#define BTN0_MASK (0x20) +#define BTN0_MODE GPIO_IN -#define USER_BTN_PRESSED ((USER_BTN_PxIN & USER_BTN_MASK) == 0) -#define USER_BTN_RELEASED ((USER_BTN_PxIN & USER_BTN_MASK) != 0) +#define BTN0_PRESSED ((BTN0_PIN & BTN0_MASK) == 0) +#define BTN0_RELEASED ((BTN0_PIN & BTN0_MASK) != 0) /** @} */ /**