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; +}