fancy_leds.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Freie Universität Berlin
3  * Copyright (C) 2015 Zolertia SL
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser General
6  * Public License v2.1. See the file LICENSE in the top level directory for more
7  * details.
8  */
9 
10 #pragma once
11 
22 #include "board_common.h"
23 
24 #ifdef __cplusplus
25  extern "C" {
26 #endif
27 
32 /* Take LED_COLOR as argument, i.e LED0 */
33 #define LED_FADE(led) \
34  volatile int i; \
35  int k, j; \
36  LED_FADE_EXPAND(led)
37 
38 #define LED_FADE_EXPAND(led) \
39  for(k = 0; k < 800; ++k) { \
40  j = k > 400 ? 800 - k : k; \
41  led##_ON; \
42  for(i = 0; i < j; ++i) { \
43  __asm__("nop"); \
44  } \
45  led##_OFF; \
46  for(i = 0; i < 400 - j; ++i) { \
47  __asm__("nop"); \
48  } \
49  }
50 
51 #define LED_RAINBOW() \
52  volatile int i; \
53  int k,j; \
54  LED_FADE_EXPAND(LED3); \
55  LED_FADE_EXPAND(LED0); \
56  LED_FADE_EXPAND(LED4); \
57  LED_FADE_EXPAND(LED2); \
58  LED_FADE_EXPAND(LED1);
61 #ifdef __cplusplus
62 } /* end extern "C" */
63 #endif
Board common definitions for the SODAQ boards.