Friedrich-Alexander-Universität Erlangen-Nürnberg  /   Technische Fakultät  /   Department Informatik

 

led.h
Go to the documentation of this file.
1 #ifndef LED_H
2 #define LED_H
3 
4 #include <stdint.h>
5 #include "check.h"
6 
7 /**
8  * \addtogroup LED LED access
9  *
10  * \brief Interface to the board's 8 LEDs
11  *
12  * @{
13  * \file led.h
14  * \version \$Rev: 7715 $
15  */
16 
17 /**
18  * \brief LED identifiers
19  */
20 typedef enum {
21  RED0 = 0, /**< Upper red led **/
22  YELLOW0 = 1, /**< Upper yellow led **/
23  GREEN0 = 2, /**< Upper green led **/
24  BLUE0 = 3, /**< Upper blue led **/
25  RED1 = 4, /**< Lower red led **/
26  YELLOW1 = 5, /**< Lower yellow led **/
27  GREEN1 = 6, /**< Lower green led **/
28  BLUE1 = 7 /**< Lower blue led **/
29 } __attribute__ ((__packed__)) LED;
30 
32 
33 /**
34  * \brief Activates a specific LED
35  *
36  * \param led LED ID
37  *
38  * \return 0 on success, negative value on error
39  *
40  * \retval 0 success
41  * \retval -1 invalid LED ID
42  */
43 int8_t sb_led_on(LED led);
44 
45 /**
46  * \brief Deactivates a specific LED
47  *
48  * \param led LED ID
49  *
50  * \return 0 on success, negative value on error
51  *
52  * \retval 0 success
53  * \retval -1 invalid LED ID
54  */
55 int8_t sb_led_off(LED led);
56 
57 /**
58  * \brief Toggles a specific LED
59  *
60  * \param led LED ID
61  *
62  * \return 0 on success, negative value on error
63  *
64  * \retval 0 success
65  * \retval -1 invalid LED ID
66  */
67 int8_t sb_led_toggle(LED led);
68 
69 /**
70  * \brief Uses the LED array as a level indicator
71  *
72  * Allows the array of LEDs to be used as a (fill) level, progress
73  * or similar indicator. The 8 LEDs are used to display a ratio of
74  * a max-value<=255 in 9 steps.
75  *
76  * \param level level value
77  * \param max maximum possible value
78  *
79  * \return the number of LEDs turned on on success, negative value on error
80  *
81  * \retval >=0 success
82  * \retval -1 level exceeds max
83  * \retval -2 max is 0
84  */
85 int8_t sb_led_showLevel(uint8_t level, uint8_t max);
86 
87 /**
88  * \brief Sets all LEDs according to a bitfield
89  *
90  * The bitfield contains one bit for each LED. A set bit enables
91  * and a cleared bit disables the corresponding LED.
92  *
93  * \param mask 8-bit bitfield describing the desired LED states
94  */
95 void sb_led_setMask(uint8_t mask);
96 
97 /** @}*/
98 
99 #endif
100 
Definition: led.h:25
#define CHECK_ENUM_SIZE(VAR, LEN)
Definition: check.h:73
Definition: led.h:22
Definition: led.h:26
Definition: led.h:28
Definition: led.h:24
Definition: led.h:21
void sb_led_setMask(uint8_t mask)
Sets all LEDs according to a bitfield.
int8_t sb_led_showLevel(uint8_t level, uint8_t max)
Uses the LED array as a level indicator.
LED
LED identifiers.
Definition: led.h:20
Definition: led.h:27
int8_t sb_led_toggle(LED led)
Toggles a specific LED.
int8_t sb_led_on(LED led)
Activates a specific LED.
int8_t sb_led_off(LED led)
Deactivates a specific LED.
Definition: led.h:23