From f0618593bae15601cdf9d1c764bbf35a8900dea9 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Fri, 11 Mar 2016 18:04:26 +0100 Subject: [PATCH] boards/samr21-xpro: unified LED defines --- boards/samr21-xpro/board.c | 11 ++++----- boards/samr21-xpro/include/board.h | 29 ++++++------------------ boards/samr21-xpro/include/gpio_params.h | 2 +- 3 files changed, 12 insertions(+), 30 deletions(-) diff --git a/boards/samr21-xpro/board.c b/boards/samr21-xpro/board.c index 1be170768d..3a492c8d29 100644 --- a/boards/samr21-xpro/board.c +++ b/boards/samr21-xpro/board.c @@ -20,17 +20,14 @@ * @} */ -#include - #include "board.h" -#include "cpu.h" +#include "periph/gpio.h" void board_init(void) { + /* initialize the on-board LED */ + gpio_init(LED0_PIN, GPIO_DIR_OUT, GPIO_NOPULL); + /* initialize the CPU */ cpu_init(); - /* initialize the boards LED at pin PA19 */ - LED_PORT.DIRSET.reg = (1 << LED_PIN); - LED_PORT.OUTSET.reg = (1 << LED_PIN); - LED_PORT.PINCFG[LED_PIN].bit.PULLEN = false; } diff --git a/boards/samr21-xpro/include/board.h b/boards/samr21-xpro/include/board.h index 1ad52c77cc..eb3c4a2afa 100644 --- a/boards/samr21-xpro/include/board.h +++ b/boards/samr21-xpro/include/board.h @@ -49,32 +49,17 @@ extern "C" { .reset_pin = GPIO_PIN(PB, 15)} /** - * @name LED pin definitions + * @brief LED pin definitions and handlers * @{ */ +#define LED0_PIN GPIO_PIN(0, 19) + #define LED_PORT PORT->Group[0] -#define LED_PIN (19) -#define LED_GPIO GPIO_PIN(0, 19) -/** @} */ +#define LED0_MASK (1 << 19) -/** - * @name Macros for controlling the on-board LEDs. - * @{ - */ -#define LED_ON (LED_PORT.OUTCLR.reg = (1 << LED_PIN)) -#define LED_OFF (LED_PORT.OUTSET.reg = (1 << LED_PIN)) -#define LED_TOGGLE (LED_PORT.OUTTGL.reg = (1 << LED_PIN)) - -/* for compatability to other boards */ -#define LED_GREEN_ON /* not available */ -#define LED_GREEN_OFF /* not available */ -#define LED_GREEN_TOGGLE /* not available */ -#define LED_ORANGE_ON /* not available */ -#define LED_ORANGE_OFF /* not available */ -#define LED_ORANGE_TOGGLE /* not available */ -#define LED_RED_ON LED_ON -#define LED_RED_OFF LED_OFF -#define LED_RED_TOGGLE LED_TOGGLE +#define LED0_ON (LED_PORT.OUTCLR.reg = LED0_MASK) +#define LED0_OFF (LED_PORT.OUTSET.reg = LED0_MASK) +#define LED0_TOGGLE (LED_PORT.OUTTGL.reg = LED0_MASK) /** @} */ /** diff --git a/boards/samr21-xpro/include/gpio_params.h b/boards/samr21-xpro/include/gpio_params.h index 2f805cb00b..8551e0d808 100644 --- a/boards/samr21-xpro/include/gpio_params.h +++ b/boards/samr21-xpro/include/gpio_params.h @@ -35,7 +35,7 @@ static const saul_gpio_params_t saul_gpio_params[] = { { .name = "LED(orange)", - .pin = LED_GPIO, + .pin = LED0_PIN, .dir = GPIO_DIR_OUT, .pull = GPIO_NOPULL, },