Loading...
Searching...
No Matches
led.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
32#ifndef LED_H
33#define LED_H
34
35#include "board.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
45#ifndef LED0_ON
46#define LED0_ON
47#define LED0_OFF
48#define LED0_TOGGLE
49#else
50#define LED0_IS_PRESENT
51#endif
52
53#ifndef LED1_ON
54#define LED1_ON
55#define LED1_OFF
56#define LED1_TOGGLE
57#else
58#define LED1_IS_PRESENT
59#endif
60
61#ifndef LED2_ON
62#define LED2_ON
63#define LED2_OFF
64#define LED2_TOGGLE
65#else
66#define LED2_IS_PRESENT
67#endif
68
69#ifndef LED3_ON
70#define LED3_ON
71#define LED3_OFF
72#define LED3_TOGGLE
73#else
74#define LED3_IS_PRESENT
75#endif
76
77#ifndef LED4_ON
78#define LED4_ON
79#define LED4_OFF
80#define LED4_TOGGLE
81#else
82#define LED4_IS_PRESENT
83#endif
84
85#ifndef LED5_ON
86#define LED5_ON
87#define LED5_OFF
88#define LED5_TOGGLE
89#else
90#define LED5_IS_PRESENT
91#endif
92
93#ifndef LED6_ON
94#define LED6_ON
95#define LED6_OFF
96#define LED6_TOGGLE
97#else
98#define LED6_IS_PRESENT
99#endif
100
101#ifndef LED7_ON
102#define LED7_ON
103#define LED7_OFF
104#define LED7_TOGGLE
105#else
106#define LED7_IS_PRESENT
107#endif
108
112#if defined(LED7_IS_PRESENT)
113#define LED_NUMOF 8
114#elif defined(LED6_IS_PRESENT)
115#define LED_NUMOF 7
116#elif defined(LED5_IS_PRESENT)
117#define LED_NUMOF 6
118#elif defined(LED4_IS_PRESENT)
119#define LED_NUMOF 5
120#elif defined(LED3_IS_PRESENT)
121#define LED_NUMOF 4
122#elif defined(LED2_IS_PRESENT)
123#define LED_NUMOF 3
124#elif defined(LED1_IS_PRESENT)
125#define LED_NUMOF 2
126#elif defined(LED0_IS_PRESENT)
127#define LED_NUMOF 1
128#else
129#define LED_NUMOF 0
130#endif
131
138#define LED_ON(id) LED ## id ##_ON
139#define LED_OFF(id) LED ## id ## _OFF
140#define LED_TOGGLE(id) LED ## id ##_TOGGLE
149static inline void led_on(unsigned id)
150{
151 switch (id) {
152 case 0: LED0_ON; break;
153 case 1: LED1_ON; break;
154 case 2: LED2_ON; break;
155 case 3: LED3_ON; break;
156 case 4: LED4_ON; break;
157 case 5: LED5_ON; break;
158 case 6: LED6_ON; break;
159 case 7: LED7_ON; break;
160 }
161}
162
170static inline void led_off(unsigned id)
171{
172 switch (id) {
173 case 0: LED0_OFF; break;
174 case 1: LED1_OFF; break;
175 case 2: LED2_OFF; break;
176 case 3: LED3_OFF; break;
177 case 4: LED4_OFF; break;
178 case 5: LED5_OFF; break;
179 case 6: LED6_OFF; break;
180 case 7: LED7_OFF; break;
181 }
182}
183
191static inline void led_toggle(unsigned id)
192{
193 switch (id) {
194 case 0: LED0_TOGGLE; break;
195 case 1: LED1_TOGGLE; break;
196 case 2: LED2_TOGGLE; break;
197 case 3: LED3_TOGGLE; break;
198 case 4: LED4_TOGGLE; break;
199 case 5: LED5_TOGGLE; break;
200 case 6: LED6_TOGGLE; break;
201 case 7: LED7_TOGGLE; break;
202 }
203}
204
207#ifdef __cplusplus
208}
209#endif
210
211#endif /* LED_H */
#define LED3_TOGGLE
defined empty
Definition led.h:72
#define LED3_OFF
defined empty
Definition led.h:71
#define LED4_ON
defined empty
Definition led.h:78
static void led_on(unsigned id)
Turn on an LED.
Definition led.h:149
#define LED0_ON
defined empty
Definition led.h:46
#define LED1_TOGGLE
defined empty
Definition led.h:56
#define LED7_TOGGLE
defined empty
Definition led.h:104
#define LED1_OFF
defined empty
Definition led.h:55
#define LED7_OFF
defined empty
Definition led.h:103
#define LED4_OFF
defined empty
Definition led.h:79
#define LED5_TOGGLE
defined empty
Definition led.h:88
#define LED6_OFF
defined empty
Definition led.h:95
#define LED6_ON
defined empty
Definition led.h:94
#define LED4_TOGGLE
defined empty
Definition led.h:80
static void led_off(unsigned id)
Turn off an LED.
Definition led.h:170
#define LED5_OFF
defined empty
Definition led.h:87
#define LED1_ON
defined empty
Definition led.h:54
#define LED2_ON
defined empty
Definition led.h:62
#define LED2_OFF
defined empty
Definition led.h:63
#define LED3_ON
defined empty
Definition led.h:70
#define LED2_TOGGLE
defined empty
Definition led.h:64
#define LED7_ON
defined empty
Definition led.h:102
#define LED0_TOGGLE
defined empty
Definition led.h:48
static void led_toggle(unsigned id)
Toggle an LED.
Definition led.h:191
#define LED0_OFF
defined empty
Definition led.h:47
#define LED5_ON
defined empty
Definition led.h:86
#define LED6_TOGGLE
defined empty
Definition led.h:96