From 95893a56537a7054e2d84653aeeb79ab2bb19195 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Thu, 18 Feb 2016 17:04:33 +0100 Subject: [PATCH 1/4] tests: added test for on-board LED macros --- tests/leds/Makefile | 6 +++++ tests/leds/README.md | 12 +++++++++ tests/leds/main.c | 59 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 tests/leds/Makefile create mode 100644 tests/leds/README.md create mode 100644 tests/leds/main.c diff --git a/tests/leds/Makefile b/tests/leds/Makefile new file mode 100644 index 0000000000..1bccb9df11 --- /dev/null +++ b/tests/leds/Makefile @@ -0,0 +1,6 @@ +export APPLICATION = leds +include ../Makefile.tests_common + +USEMODULE += xtimer + +include $(RIOTBASE)/Makefile.include diff --git a/tests/leds/README.md b/tests/leds/README.md new file mode 100644 index 0000000000..a03c6386f5 --- /dev/null +++ b/tests/leds/README.md @@ -0,0 +1,12 @@ +Expected result +=============== +The 'red' and the 'green' LEDs of the board should light up alternating with a +500ms interval. If your board has only one LED (probably defined as LED_RED), +you will see only this LED blink at 1Hz. If your board has no on-board LED, you +will see nothing. + +Background +========== +All boards in RIOT define at least two macros for accessing two selected +on-board LEDs directly. These are called LED_RED and LED_GREEN, independent if +the actual color of those LED is red or green. diff --git a/tests/leds/main.c b/tests/leds/main.c new file mode 100644 index 0000000000..42669c956c --- /dev/null +++ b/tests/leds/main.c @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2016 Freie Universität Berlin + * + * 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 tests + * @{ + * + * @file + * @brief Test for the on-board LED macros + * + * @author Hauke Petersen + * + * @} + */ + +#include + +#include "board.h" +#include "xtimer.h" + +#define WAIT_INTERVAL (500 * MS_IN_USEC) + +int main(void) +{ + puts("On-board LED test\n"); + puts("You should now see the 'red' and the 'green' LED lighting up in a\n" + "500ms interval, alternating of each other."); + + /* turn off all LEDs */ + LED_RED_OFF; + LED_GREEN_OFF; + + while (1) { + LED_RED_ON; + puts("LED_RED_ON"); + xtimer_usleep(WAIT_INTERVAL); + LED_RED_OFF; + LED_GREEN_ON; + puts("LED_GREEN_ON"); + xtimer_usleep(WAIT_INTERVAL); + LED_GREEN_OFF; + + LED_RED_TOGGLE; + puts("LED_RED_TOGGLE"); + xtimer_usleep(WAIT_INTERVAL); + LED_RED_TOGGLE; + LED_GREEN_TOGGLE; + puts("LED_GREEN_TOGGLE"); + xtimer_usleep(WAIT_INTERVAL); + LED_GREEN_TOGGLE; + } + + return 0; +} From 6dc4f0d00712e02268a43a38a97f06cdb3444447 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Thu, 18 Feb 2016 17:16:24 +0100 Subject: [PATCH 2/4] boards/msb-430(h): added LED_GREEN_x macros --- boards/msb-430/include/board.h | 9 ++++++++- boards/msb-430h/include/board.h | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/boards/msb-430/include/board.h b/boards/msb-430/include/board.h index 3d93516dfd..36eca6aa57 100644 --- a/boards/msb-430/include/board.h +++ b/boards/msb-430/include/board.h @@ -55,7 +55,10 @@ extern "C" { #define MSP430_HAS_DCOR 1 #define MSP430_HAS_EXTERNAL_CRYSTAL 0 -/* LEDs ports MSB430 */ +/** + * @brief LED definitions + * @{ + */ #define LEDS_PxDIR P5DIR #define LEDS_PxOUT P5OUT #define LEDS_CONF_RED 0x80 @@ -65,6 +68,10 @@ extern "C" { #define LED_RED_ON LEDS_PxOUT &=~LEDS_CONF_RED #define LED_RED_OFF LEDS_PxOUT |= LEDS_CONF_RED #define LED_RED_TOGGLE LEDS_PxOUT ^= LEDS_CONF_RED +#define LED_GREEN_ON /* not present */ +#define LED_GREEN_OFF /* not present */ +#define LED_GREEN_TOGGLE /* not present */ +/** @} */ #ifdef __cplusplus } diff --git a/boards/msb-430h/include/board.h b/boards/msb-430h/include/board.h index cc3b456929..68badc21c7 100644 --- a/boards/msb-430h/include/board.h +++ b/boards/msb-430h/include/board.h @@ -49,7 +49,10 @@ extern "C" { #define MSP430_HAS_DCOR 1 #define MSP430_HAS_EXTERNAL_CRYSTAL 1 -/* LEDs ports MSB430 */ +/** + * @brief LED definitions + * @{ + */ #define LEDS_PxDIR P5DIR #define LEDS_PxOUT P5OUT #define LEDS_CONF_RED 0x80 @@ -59,6 +62,10 @@ extern "C" { #define LED_RED_ON LEDS_PxOUT &=~LEDS_CONF_RED #define LED_RED_OFF LEDS_PxOUT |= LEDS_CONF_RED #define LED_RED_TOGGLE LEDS_PxOUT ^= LEDS_CONF_RED +#define LED_GREEN_ON /* not present */ +#define LED_GREEN_OFF /* not present */ +#define LED_GREEN_TOGGLE /* not present */ +/** @} */ #ifdef __cplusplus } From 08d1e8de91dc2bfb2ada5cb07ff9e0500c0e75ea Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 24 Feb 2016 15:59:14 +0100 Subject: [PATCH 3/4] boards/msb-430(h): style fixed in board.h fixed indention and parens for LED defines --- boards/msb-430/include/board.h | 22 +++++++++++----------- boards/msb-430h/include/board.h | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/boards/msb-430/include/board.h b/boards/msb-430/include/board.h index 36eca6aa57..070acfe6d9 100644 --- a/boards/msb-430/include/board.h +++ b/boards/msb-430/include/board.h @@ -59,18 +59,18 @@ extern "C" { * @brief LED definitions * @{ */ -#define LEDS_PxDIR P5DIR -#define LEDS_PxOUT P5OUT -#define LEDS_CONF_RED 0x80 -#define LEDS_CONF_GREEN 0x00 -#define LEDS_CONF_YELLOW 0x00 +#define LEDS_PxDIR (P5DIR) +#define LEDS_PxOUT (P5OUT) +#define LEDS_CONF_RED (0x80) +#define LEDS_CONF_GREEN (0x00) +#define LEDS_CONF_YELLOW (0x00) -#define LED_RED_ON LEDS_PxOUT &=~LEDS_CONF_RED -#define LED_RED_OFF LEDS_PxOUT |= LEDS_CONF_RED -#define LED_RED_TOGGLE LEDS_PxOUT ^= LEDS_CONF_RED -#define LED_GREEN_ON /* not present */ -#define LED_GREEN_OFF /* not present */ -#define LED_GREEN_TOGGLE /* not present */ +#define LED_RED_ON (LEDS_PxOUT &=~LEDS_CONF_RED) +#define LED_RED_OFF (LEDS_PxOUT |= LEDS_CONF_RED) +#define LED_RED_TOGGLE (LEDS_PxOUT ^= LEDS_CONF_RED) +#define LED_GREEN_ON /* not present */ +#define LED_GREEN_OFF /* not present */ +#define LED_GREEN_TOGGLE /* not present */ /** @} */ #ifdef __cplusplus diff --git a/boards/msb-430h/include/board.h b/boards/msb-430h/include/board.h index 68badc21c7..18ff7dd3ee 100644 --- a/boards/msb-430h/include/board.h +++ b/boards/msb-430h/include/board.h @@ -53,18 +53,18 @@ extern "C" { * @brief LED definitions * @{ */ -#define LEDS_PxDIR P5DIR -#define LEDS_PxOUT P5OUT -#define LEDS_CONF_RED 0x80 -#define LEDS_CONF_GREEN 0x00 -#define LEDS_CONF_YELLOW 0x00 +#define LEDS_PxDIR (P5DIR) +#define LEDS_PxOUT (P5OUT) +#define LEDS_CONF_RED (0x80) +#define LEDS_CONF_GREEN (0x00) +#define LEDS_CONF_YELLOW (0x00) -#define LED_RED_ON LEDS_PxOUT &=~LEDS_CONF_RED -#define LED_RED_OFF LEDS_PxOUT |= LEDS_CONF_RED -#define LED_RED_TOGGLE LEDS_PxOUT ^= LEDS_CONF_RED -#define LED_GREEN_ON /* not present */ -#define LED_GREEN_OFF /* not present */ -#define LED_GREEN_TOGGLE /* not present */ +#define LED_RED_ON (LEDS_PxOUT &=~LEDS_CONF_RED) +#define LED_RED_OFF (LEDS_PxOUT |= LEDS_CONF_RED) +#define LED_RED_TOGGLE (LEDS_PxOUT ^= LEDS_CONF_RED) +#define LED_GREEN_ON /* not present */ +#define LED_GREEN_OFF /* not present */ +#define LED_GREEN_TOGGLE /* not present */ /** @} */ #ifdef __cplusplus From 285f4a39ba7923b16e699ea609c6236af430a8e5 Mon Sep 17 00:00:00 2001 From: Hauke Petersen Date: Wed, 2 Mar 2016 12:46:34 +0100 Subject: [PATCH 4/4] boards/chronos: added missing LED defines + cleanup --- boards/chronos/include/board.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/boards/chronos/include/board.h b/boards/chronos/include/board.h index e58ea63f1b..01cd0a8c0a 100644 --- a/boards/chronos/include/board.h +++ b/boards/chronos/include/board.h @@ -27,7 +27,7 @@ extern "C" { #endif -// for correct inclusion of +/* for correct inclusion of */ #ifndef __CC430F6137__ #define __CC430F6137__ #endif @@ -42,11 +42,28 @@ extern "C" { #define XTIMER_SHIFT_ON_COMPARE (4) /** @} */ +/** + * @brief MSP430 core configuration + * @{ + */ #define MSP430_INITIAL_CPU_SPEED 7372800uL #define F_CPU MSP430_INITIAL_CPU_SPEED #define F_RC_OSCILLATOR 32768 #define MSP430_HAS_DCOR 1 #define MSP430_HAS_EXTERNAL_CRYSTAL 1 +/** @} */ + +/** + * @brief LED defines for compatibility + * @{ + */ +#define LED_RED_ON /* not present */ +#define LED_RED_OFF /* not present */ +#define LED_RED_TOGGLE /* not present */ +#define LED_GREEN_ON /* not present */ +#define LED_GREEN_OFF /* not present */ +#define LED_GREEN_TOGGLE /* not present */ +/** @} */ #ifdef __cplusplus }