From 593ad5b223c0e85b3aecc49d2665941dd5783cda Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Tue, 1 Mar 2016 16:33:07 +0100 Subject: [PATCH] boards/arduino-due: cleaned up LED handling --- boards/arduino-due/board.c | 38 ++++-------------------------- boards/arduino-due/include/board.h | 21 +++++++++-------- 2 files changed, 15 insertions(+), 44 deletions(-) diff --git a/boards/arduino-due/board.c b/boards/arduino-due/board.c index bc87296236..8d24fddc60 100644 --- a/boards/arduino-due/board.c +++ b/boards/arduino-due/board.c @@ -18,44 +18,14 @@ * @} */ -#include - -#include "board.h" #include "cpu.h" - - -void led_init(void); - +#include "board.h" +#include "periph/gpio.h" void board_init(void) { /* initialize the CPU */ cpu_init(); - - /* initialize the boards LEDs */ - led_init(); -} - - -/** - * @brief Initialize the boards on-board LED (Amber LED "L") - * - * The LED initialization is hard-coded in this function. As the LED is soldered - * onto the board it is fixed to its CPU pins. - * - * The LED is connected to the following pin: - * - LED: PB27 - */ -void led_init(void) -{ - /* enable PIO control of pin PD27 */ - LED_PORT->PIO_PER = LED_PIN; - /* set pin as output */ - LED_PORT->PIO_OER = LED_PIN; - /* enable direct write access to the LED pin */ - LED_PORT->PIO_OWER = LED_PIN; - /* disable pull-up */ - LED_PORT->PIO_PUDR = LED_PIN; - /* clear pin */ - LED_PORT->PIO_CODR = LED_PIN; + /* initialize the on-board Amber "L" LED @ pin PB27 */ + gpio_init(LED_PIN, GPIO_DIR_OUT, GPIO_NOPULL); } diff --git a/boards/arduino-due/include/board.h b/boards/arduino-due/include/board.h index 8a2c825ad8..20453ec6d6 100644 --- a/boards/arduino-due/include/board.h +++ b/boards/arduino-due/include/board.h @@ -33,24 +33,25 @@ extern "C" { * @{ */ #define LED_PORT PIOB -#define LED_PIN PIO_PB27 +#define LED_BIT PIO_PB27 +#define LED_PIN GPIO_PIN(PB, 27) /** @} */ /** * @name Macros for controlling the on-board LEDs. * @{ */ -#define LED_ON (LED_PORT->PIO_ODSR |= LED_PIN) -#define LED_OFF (LED_PORT->PIO_ODSR &= ~LED_PIN) -#define LED_TOGGLE (LED_PORT->PIO_ODSR ^= LED_PIN) +#define LED_ON (LED_PORT->PIO_SODR = LED_BIT) +#define LED_OFF (LED_PORT->PIO_CODR = LED_BIT) +#define LED_TOGGLE (LED_PORT->PIO_ODSR ^= LED_BIT) /* 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_RED_ON LED_ON -#define LED_RED_OFF LED_OFF -#define LED_RED_TOGGLE LED_TOGGLE +#define LED_GREEN_ON LED_ON +#define LED_GREEN_OFF LED_OFF +#define LED_GREEN_TOGGLE LED_TOGGLE +#define LED_RED_ON /* not available */ +#define LED_RED_OFF /* not available */ +#define LED_RED_TOGGLE /* not available */ /** @} */ /**