From ce57a574dfe3674a16007296f573fa351cff8186 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 29 May 2018 09:33:08 +0200 Subject: [PATCH 1/3] 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 */ From a0f35c9b35eb89fe0652d3c7fd216b99df1414c0 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 29 May 2018 09:33:57 +0200 Subject: [PATCH 2/3] boards/msbiot: Added on-board buttons & LEDs as defalt SAUL devices --- boards/msbiot/Makefile.dep | 4 ++ boards/msbiot/include/gpio_params.h | 71 +++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 boards/msbiot/include/gpio_params.h diff --git a/boards/msbiot/Makefile.dep b/boards/msbiot/Makefile.dep index 33f667abb9..763297ec95 100644 --- a/boards/msbiot/Makefile.dep +++ b/boards/msbiot/Makefile.dep @@ -2,3 +2,7 @@ ifneq (,$(filter netdev_default gnrc_netdev_default,$(USEMODULE))) USEMODULE += cc110x endif +# add support for LEDs and buttons as default saul devices +ifneq (,$(filter saul_default,$(USEMODULE))) + USEMODULE += saul_gpio +endif diff --git a/boards/msbiot/include/gpio_params.h b/boards/msbiot/include/gpio_params.h new file mode 100644 index 0000000000..6694f7cd22 --- /dev/null +++ b/boards/msbiot/include/gpio_params.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2018 Otto-von-Guericke-Universität Magdeburg + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup boards_msbiot + * @{ + * + * @file + * @brief Board specific configuration of direct mapped GPIOs + * + * @author Marian Buschsieweke + */ + +#ifndef GPIO_PARAMS_H +#define GPIO_PARAMS_H + +#include "board.h" +#include "saul/periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief GPIO pin configuration + */ +static const saul_gpio_params_t saul_gpio_params[] = +{ + { + .name = "red LED", + .pin = LED0_PIN, + .mode = GPIO_OUT, + .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR) + }, + { + .name = "yellow LED", + .pin = LED1_PIN, + .mode = GPIO_OUT, + .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR) + }, + { + .name = "green LED", + .pin = LED2_PIN, + .mode = GPIO_OUT, + .flags = (SAUL_GPIO_INVERTED | SAUL_GPIO_INIT_CLEAR) + }, + { + .name = "left button", + .pin = BUTTON0_PIN, + .mode = GPIO_IN, + .flags = 0 + }, + { + .name = "right button", + .pin = BUTTON1_PIN, + .mode = GPIO_IN, + .flags = 0 + }, +}; + +#ifdef __cplusplus +} +#endif + +#endif /* GPIO_PARAMS_H */ +/** @} */ From 7d7bc3fef8b4ac2d65d4a30ab32296a33f1f8a70 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 29 May 2018 09:34:24 +0200 Subject: [PATCH 3/3] boards/msbiot: Added on-board MPU-9150 as defalt SAUL device --- boards/msbiot/Makefile.dep | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/boards/msbiot/Makefile.dep b/boards/msbiot/Makefile.dep index 763297ec95..be08a394e3 100644 --- a/boards/msbiot/Makefile.dep +++ b/boards/msbiot/Makefile.dep @@ -6,3 +6,7 @@ endif ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio endif +# add support for the MPU-9150 as default saul device +ifneq (,$(filter saul_default,$(USEMODULE))) + USEMODULE += mpu9150 +endif