diff --git a/boards/seeeduino_arch-pro/Makefile.dep b/boards/seeeduino_arch-pro/Makefile.dep new file mode 100644 index 0000000000..5472bf8b8d --- /dev/null +++ b/boards/seeeduino_arch-pro/Makefile.dep @@ -0,0 +1,3 @@ +ifneq (,$(filter saul_default,$(USEMODULE))) + USEMODULE += saul_gpio +endif diff --git a/boards/seeeduino_arch-pro/Makefile.features b/boards/seeeduino_arch-pro/Makefile.features index 624b6ae2cb..777b500b0d 100644 --- a/boards/seeeduino_arch-pro/Makefile.features +++ b/boards/seeeduino_arch-pro/Makefile.features @@ -1,4 +1,5 @@ # Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart diff --git a/boards/seeeduino_arch-pro/board.c b/boards/seeeduino_arch-pro/board.c index 61826aeb33..aa4a2412b9 100644 --- a/boards/seeeduino_arch-pro/board.c +++ b/boards/seeeduino_arch-pro/board.c @@ -21,9 +21,26 @@ #include "board.h" -static void leds_init(void); +#include "periph/gpio.h" + extern void SystemInit(void); +/** + * @brief Initialize the on-board LEDs. + */ +static void leds_init(void) +{ + gpio_init(LED0_PIN, GPIO_OUT); + gpio_init(LED1_PIN, GPIO_OUT); + gpio_init(LED2_PIN, GPIO_OUT); + gpio_init(LED3_PIN, GPIO_OUT); + + LED0_OFF; + LED1_OFF; + LED2_OFF; + LED3_OFF; +} + void board_init(void) { /* initialize core clocks via CMSIS function */ @@ -33,26 +50,3 @@ void board_init(void) /* initialize the boards LEDs */ leds_init(); } - -/** - * @brief Initialize the boards on-board LEDs (LED1 to LED4) - * - * 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 LEDs are connected to the following pins: - * - LED1: P1.18 - * - LED2: P1.20 - * - LED3: P1.21 - * - LED4: P1.23 - * - * The LEDs are active-low (current-sink). - */ -static void leds_init(void) -{ - /* configure LED pins as output */ - LED_PORT->FIODIR |= (LED0_MASK | LED1_MASK | LED2_MASK | LED3_MASK); - - /* turn off all LEDs */ - LED_PORT->FIOSET = (LED0_MASK | LED1_MASK | LED2_MASK | LED3_MASK); -} diff --git a/boards/seeeduino_arch-pro/include/board.h b/boards/seeeduino_arch-pro/include/board.h index 8aa7d4bb1a..ad5ad60957 100644 --- a/boards/seeeduino_arch-pro/include/board.h +++ b/boards/seeeduino_arch-pro/include/board.h @@ -24,10 +24,9 @@ #ifndef BOARD_H #define BOARD_H -#include - -#include "bitarithm.h" #include "cpu.h" +#include "periph_conf.h" +#include "periph/gpio.h" #ifdef __cplusplus extern "C" { @@ -42,24 +41,18 @@ extern "C" { #define LED2_PIN GPIO_PIN(1, 21) #define LED3_PIN GPIO_PIN(1, 23) -#define LED_PORT (LPC_GPIO1) -#define LED0_MASK (BIT18) -#define LED1_MASK (BIT20) -#define LED2_MASK (BIT21) -#define LED3_MASK (BIT23) - -#define LED0_ON (LED_PORT->FIOCLR = LED0_MASK) -#define LED0_OFF (LED_PORT->FIOSET = LED0_MASK) -#define LED0_TOGGLE (LED_PORT->FIOPIN ^= LED0_MASK) -#define LED1_ON (LED_PORT->FIOCLR = LED1_MASK) -#define LED1_OFF (LED_PORT->FIOSET = LED1_MASK) -#define LED1_TOGGLE (LED_PORT->FIOPIN ^= LED1_MASK) -#define LED2_ON (LED_PORT->FIOCLR = LED2_MASK) -#define LED2_OFF (LED_PORT->FIOSET = LED2_MASK) -#define LED2_TOGGLE (LED_PORT->FIOPIN ^= LED2_MASK) -#define LED3_ON (LED_PORT->FIOCLR = LED3_MASK) -#define LED3_OFF (LED_PORT->FIOSET = LED3_MASK) -#define LED3_TOGGLE (LED_PORT->FIOPIN ^= LED3_MASK) +#define LED0_ON gpio_clear(LED0_PIN) +#define LED0_OFF gpio_set(LED0_PIN) +#define LED0_TOGGLE gpio_toggle(LED0_PIN) +#define LED1_ON gpio_clear(LED1_PIN) +#define LED1_OFF gpio_set(LED1_PIN) +#define LED1_TOGGLE gpio_toggle(LED1_PIN) +#define LED2_ON gpio_clear(LED2_PIN) +#define LED2_OFF gpio_set(LED2_PIN) +#define LED2_TOGGLE gpio_toggle(LED2_PIN) +#define LED3_ON gpio_clear(LED3_PIN) +#define LED3_OFF gpio_set(LED3_PIN) +#define LED3_TOGGLE gpio_toggle(LED3_PIN) /** @} */ /** diff --git a/boards/seeeduino_arch-pro/include/gpio_params.h b/boards/seeeduino_arch-pro/include/gpio_params.h new file mode 100644 index 0000000000..d599c7203f --- /dev/null +++ b/boards/seeeduino_arch-pro/include/gpio_params.h @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2017 Bas Stottelaar + * + * 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_seeduino_arch-pro + * @{ + * + * @file + * @brief Board specific configuration of direct mapped GPIOs + * + * @author Bas Stottelaar + */ + +#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 = "LED 0", + .pin = LED0_PIN, + .mode = GPIO_OUT, + .flags = SAUL_GPIO_INVERTED + }, + { + .name = "LED 1", + .pin = LED1_PIN, + .mode = GPIO_OUT, + .flags = SAUL_GPIO_INVERTED + }, + { + .name = "LED 2", + .pin = LED2_PIN, + .mode = GPIO_OUT, + .flags = SAUL_GPIO_INVERTED + }, + { + .name = "LED 3", + .pin = LED3_PIN, + .mode = GPIO_OUT, + .flags = SAUL_GPIO_INVERTED + } +}; + +#ifdef __cplusplus +} +#endif + +#endif /* GPIO_PARAMS_H */ +/** @} */