Be doubly-certain that the incomming CDC class driver's endpoint/pipe is flushed...
[pub/USBasp.git] / LUFA / Drivers / Board / LEDs.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \file
32 *
33 * This file is the master dispatch header file for the board-specific LED driver, for boards containing user
34 * controllable LEDs.
35 *
36 * User code should include this file, which will in turn include the correct LED driver header file for the
37 * currently selected board.
38 *
39 * If the BOARD value is set to BOARD_USER, this will include the /Board/LEDs.h file in the user project
40 * directory.
41 */
42
43 /** \ingroup Group_BoardDrivers
44 * @defgroup Group_LEDs LEDs Driver - LUFA/Drivers/Board/LEDs.h
45 *
46 * \section Sec_Dependencies Module Source Dependencies
47 * The following files must be built with any user project that uses this module:
48 * - None
49 *
50 * \section Module Description
51 * Hardware LEDs driver. This provides an easy to use driver for the hardware LEDs present on many boards. It
52 * provides an interface to configure, test and change the status of all the board LEDs.
53 *
54 * If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project
55 * directory. Otherwise, it will include the appropriate built in board driver header file.
56 *
57 * \note To make code as compatible as possible, it is assumed that all boards carry a minimum of four LEDs. If
58 * a board contains less than four LEDs, the remaining LED masks are defined to 0 so as to have no effect.
59 * If other behaviour is desired, either alias the remaining LED masks to existing LED masks via the -D
60 * switch in the project makefile, or alias them to nothing in the makefile to cause compilation errors when
61 * a non-existing LED is referenced in application code. Note that this means that it is possible to make
62 * compatible code for a board with no LEDs by making a board LED driver (see \ref Page_WritingBoardDrivers)
63 * which contains only stub functions and defines no LEDs.
64 *
65 * @{
66 */
67
68 #ifndef __LEDS_H__
69 #define __LEDS_H__
70
71 /* Macros: */
72 #if !defined(__DOXYGEN__)
73 #define INCLUDE_FROM_LEDS_H
74 #endif
75
76 /* Includes: */
77 #include "../../Common/Common.h"
78
79 #if !defined(BOARD)
80 #error BOARD must be set in makefile to a value specified in BoardTypes.h.
81 #elif (BOARD == BOARD_USBKEY)
82 #include "USBKEY/LEDs.h"
83 #elif (BOARD == BOARD_STK525)
84 #include "STK525/LEDs.h"
85 #elif (BOARD == BOARD_STK526)
86 #include "STK526/LEDs.h"
87 #elif (BOARD == BOARD_RZUSBSTICK)
88 #include "RZUSBSTICK/LEDs.h"
89 #elif (BOARD == BOARD_ATAVRUSBRF01)
90 #include "ATAVRUSBRF01/LEDs.h"
91 #elif (BOARD == BOARD_XPLAIN)
92 #include "XPLAIN/LEDs.h"
93 #elif (BOARD == BOARD_XPLAIN_REV1)
94 #include "XPLAIN/LEDs.h"
95 #elif (BOARD == BOARD_BUMBLEB)
96 #include "BUMBLEB/LEDs.h"
97 #elif (BOARD == BOARD_EVK527)
98 #include "EVK527/LEDs.h"
99 #elif (BOARD == BOARD_USER)
100 #include "Board/LEDs.h"
101 #endif
102
103 #if !defined(LEDS_LED1)
104 #define LEDS_LED1 0
105 #endif
106
107 #if !defined(LEDS_LED2)
108 #define LEDS_LED2 0
109 #endif
110
111 #if !defined(LEDS_LED3)
112 #define LEDS_LED3 0
113 #endif
114
115 #if !defined(LEDS_LED4)
116 #define LEDS_LED4 0
117 #endif
118
119 /* Pseudo-Functions for Doxygen: */
120 #if defined(__DOXYGEN__)
121 /** Initializes the board LED driver so that the LEDs can be controlled. This sets the appropriate port
122 * I/O pins as outputs, and sets the LEDs to default to off.
123 */
124 static inline void LEDs_Init(void);
125
126 /** Turns on the LEDs specified in the given LED mask.
127 *
128 * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
129 */
130 static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask);
131
132 /** Turns off the LEDs specified in the given LED mask.
133 *
134 * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
135 */
136 static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask);
137
138 /** Turns off all LEDs not specified in the given LED mask, and turns on all the LEDs in the given LED
139 * mask.
140 *
141 * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
142 */
143 static inline void LEDs_SetAllLEDs(const uint8_t LEDMask);
144
145 /** Turns off all LEDs in the LED mask that are not set in the active mask, and turns on all the LEDs
146 * specified in both the LED and active masks.
147 *
148 * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
149 * \param[in] ActiveMask Mask of whether the LEDs in the LED mask should be turned on or off
150 */
151 static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask);
152
153 /** Toggles all LEDs in the LED mask, leaving all others in their current states.
154 *
155 * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
156 */
157 static inline void LEDs_ToggleLEDs(const uint8_t LEDMask);
158
159 /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the
160 * corresponding LED is on.
161 *
162 * \return Mask of the board LEDs which are currently turned on
163 */
164 static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
165 #endif
166
167 #endif
168
169 /** @} */