From ce57a574dfe3674a16007296f573fa351cff8186 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke <marian.buschsieweke@ovgu.de> Date: Tue, 29 May 2018 09:33:08 +0200 Subject: [PATCH] boards/msbiot: Added support for on-board buttons --- boards/msbiot/board.c | 16 ++++++++++------ boards/msbiot/include/board.h | 8 ++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/boards/msbiot/board.c b/boards/msbiot/board.c index bd83642ee6..6cfefbb688 100644 --- a/boards/msbiot/board.c +++ b/boards/msbiot/board.c @@ -21,7 +21,7 @@ #include "board.h" #include "periph/gpio.h" -static void leds_init(void); +static void gpios_init(void); void board_init(void) { @@ -29,23 +29,27 @@ void board_init(void) cpu_init(); /* initialize the boards LEDs */ - leds_init(); + gpios_init(); } /** - * @brief Initialize the boards standard LEDs (RED, YELLOW, GREEN) + * @brief Initialize the on board GPIO periphs (3 LEDs, 2 buttons) * - * The LED initialization is hard-coded in this function. As the LEDs are soldered - * onto the board they are fixed to their CPU pins. + * The LED and button initialization is hard-coded in this function. As the LEDs + * and buttons are soldered onto the board they are fixed to their CPU pins. * * The LEDs are connected to the following pins: * - LED RED: PB8 * - LED YELLOW: PB14 * - LED GREEN: PB15 + * - BUTTON T1: PB13 + * - BUTTON T2: PA0 */ -static void leds_init(void) +static void gpios_init(void) { gpio_init(LED0_PIN, GPIO_OUT); gpio_init(LED1_PIN, GPIO_OUT); gpio_init(LED2_PIN, GPIO_OUT); + gpio_init(BUTTON0_PIN, GPIO_IN); + gpio_init(BUTTON1_PIN, GPIO_IN); } diff --git a/boards/msbiot/include/board.h b/boards/msbiot/include/board.h index 9f8017cf79..485c270f59 100644 --- a/boards/msbiot/include/board.h +++ b/boards/msbiot/include/board.h @@ -72,6 +72,14 @@ extern "C" { #define LED2_TOGGLE (LED_PORT->ODR ^= LED2_MASK) /** @} */ +/** + * @name Button pin definitions + * @{ + */ +#define BUTTON0_PIN GPIO_PIN(PORT_B, 13) +#define BUTTON1_PIN GPIO_PIN(PORT_A, 0) +/** @} */ + /** * @brief Initialize board specific hardware, including clock, LEDs and std-IO */ -- GitLab