mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #4849 from haukepetersen/add_test_leds
tests: added test for on-board LED macros
This commit is contained in:
commit
2f0b4c20bf
@ -27,7 +27,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// for correct inclusion of <msp430.h>
|
||||
/* for correct inclusion of <msp430.h> */
|
||||
#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
|
||||
}
|
||||
|
@ -55,16 +55,23 @@ extern "C" {
|
||||
#define MSP430_HAS_DCOR 1
|
||||
#define MSP430_HAS_EXTERNAL_CRYSTAL 0
|
||||
|
||||
/* LEDs ports MSB430 */
|
||||
#define LEDS_PxDIR P5DIR
|
||||
#define LEDS_PxOUT P5OUT
|
||||
#define LEDS_CONF_RED 0x80
|
||||
#define LEDS_CONF_GREEN 0x00
|
||||
#define LEDS_CONF_YELLOW 0x00
|
||||
/**
|
||||
* @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 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_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
|
||||
}
|
||||
|
@ -49,16 +49,23 @@ extern "C" {
|
||||
#define MSP430_HAS_DCOR 1
|
||||
#define MSP430_HAS_EXTERNAL_CRYSTAL 1
|
||||
|
||||
/* LEDs ports MSB430 */
|
||||
#define LEDS_PxDIR P5DIR
|
||||
#define LEDS_PxOUT P5OUT
|
||||
#define LEDS_CONF_RED 0x80
|
||||
#define LEDS_CONF_GREEN 0x00
|
||||
#define LEDS_CONF_YELLOW 0x00
|
||||
/**
|
||||
* @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 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_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
|
||||
}
|
||||
|
6
tests/leds/Makefile
Normal file
6
tests/leds/Makefile
Normal 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
12
tests/leds/README.md
Normal 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
59
tests/leds/main.c
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user