1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests: added test for on-board LED macros

This commit is contained in:
Hauke Petersen 2016-02-18 17:04:33 +01:00
parent 1fe16507b4
commit 95893a5653
3 changed files with 77 additions and 0 deletions

6
tests/leds/Makefile Normal file
View File

@ -0,0 +1,6 @@
export APPLICATION = leds
include ../Makefile.tests_common
USEMODULE += xtimer
include $(RIOTBASE)/Makefile.include

12
tests/leds/README.md Normal file
View File

@ -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.

59
tests/leds/main.c Normal file
View File

@ -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 <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include <stdio.h>
#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;
}