]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/lufa/LUFA-git/LUFA/Drivers/Board/UC3/UC3A3_XPLAINED/LEDs.h
Merge commit '60b30c036397cb5627fa374bb930794b225daa29' as 'lib/lufa'
[qmk_firmware.git] / tmk_core / protocol / lufa / LUFA-git / LUFA / Drivers / Board / UC3 / UC3A3_XPLAINED / LEDs.h
1 /*
2              LUFA Library
3      Copyright (C) Dean Camera, 2014.
4
5   dean [at] fourwalledcubicle [dot] com
6            www.lufa-lib.org
7 */
8
9 /*
10   Copyright 2014  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 disclaims 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  *  \brief Board specific LED driver header for the Atmel UC3-A3 Xplained.
33  *  \copydetails Group_LEDs_UC3A3_XPLAINED
34  *
35  *  \note This file should not be included directly. It is automatically included as needed by the LEDs driver
36  *        dispatch header located in LUFA/Drivers/Board/LEDs.h.
37  */
38
39 /** \ingroup Group_LEDs
40  *  \defgroup Group_LEDs_UC3A3_XPLAINED UC3A3_XPLAINED
41  *  \brief Board specific LED driver header for the Atmel UC3-A3 Xplained.
42  *
43  *  Board specific LED driver header for the Atmel UC3-A3 Xplained.
44  *
45  *  <table>
46  *    <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
47  *    <tr><td>LEDS_LED1</td><td>Yellow</td><td>LED0 LED</td><td>Low</td><td>GPIO35</td></tr>
48  *    <tr><td>LEDS_LED2</td><td>Yellow</td><td>LED1 LED</td><td>Low</td><td>GPIO73</td></tr>
49  *    <tr><td>LEDS_LED3</td><td>Yellow</td><td>LED2 LED</td><td>Low</td><td>GPIO34</td></tr>
50  *    <tr><td>LEDS_LED4</td><td>Yellow</td><td>LED3 LED</td><td>Low</td><td>GPIO38</td></tr>
51  *    <tr><td>LEDS_LED5</td><td>Green</td><td>Status</td><td>Low</td><td>GPIO50</td></tr>
52  *    <tr><td>LEDS_LED6</td><td>Red</td><td>Power</td><td>High</td><td>GPIO49</td></tr>
53  *  </table>
54  *
55  *  @{
56  */
57
58 #ifndef __LEDS_UC3A3_XPLAINED_H__
59 #define __LEDS_UC3A3_XPLAINED_H__
60
61         /* Includes: */
62                 #include "../../../../Common/Common.h"
63
64         /* Enable C linkage for C++ Compilers: */
65                 #if defined(__cplusplus)
66                         extern "C" {
67                 #endif
68
69         /* Preprocessor Checks: */
70                 #if !defined(__INCLUDE_FROM_LEDS_H)
71                         #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
72                 #endif
73
74         /* Private Interface - For use in library only: */
75         #if !defined(__DOXYGEN__)
76                 /* Macros: */
77                         #define LEDS_LEDMASK1   ((1UL << 3) | (1UL << 2) | (1UL << 6) | (1UL << 18) | (1UL << 17))
78                         #define LEDS_LEDMASK3    (1UL << 9)
79         #endif
80
81         /* Public Interface - May be used in end-application: */
82                 /* Macros: */
83                         /** LED mask for the first LED on the board. */
84                         #define LEDS_LED1        (1UL << 3)
85
86                         /** LED mask for the second LED on the board. */
87                         #define LEDS_LED2        (1UL << 9)
88
89                         /** LED mask for the third LED on the board. */
90                         #define LEDS_LED3        (1UL << 2)
91
92                         /** LED mask for the fourth LED on the board. */
93                         #define LEDS_LED4        (1UL << 6)
94
95                         /** LED mask for the fifth LED on the board. */
96                         #define LEDS_LED5        (1UL << 18)
97
98                         /** LED mask for the sixth LED on the board. */
99                         #define LEDS_LED6        (1UL << 17)
100
101                         /** LED mask for all the LEDs on the board. */
102                         #define LEDS_ALL_LEDS    (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4 | LEDS_LED5 | LEDS_LED6)
103
104                         /** LED mask for the none of the board LEDs */
105                         #define LEDS_NO_LEDS     0
106
107                 /* Inline Functions: */
108                 #if !defined(__DOXYGEN__)
109                         static inline void LEDs_Init(void)
110                         {
111                                 AVR32_GPIO.port[1].gpers = LEDS_LEDMASK1;
112                                 AVR32_GPIO.port[1].oders = LEDS_LEDMASK1;
113                                 AVR32_GPIO.port[1].ovrs  = LEDS_LEDMASK1;
114
115                                 AVR32_GPIO.port[3].gpers = LEDS_LEDMASK3;
116                                 AVR32_GPIO.port[3].oders = LEDS_LEDMASK3;
117                                 AVR32_GPIO.port[3].ovrs  = LEDS_LEDMASK3;
118                         }
119
120                         static inline void LEDs_Disable(void)
121                         {
122                                 AVR32_GPIO.port[1].gperc = LEDS_LEDMASK1;
123                                 AVR32_GPIO.port[1].oderc = LEDS_LEDMASK1;
124                                 AVR32_GPIO.port[1].ovrc  = LEDS_LEDMASK1;
125
126                                 AVR32_GPIO.port[3].gperc = LEDS_LEDMASK3;
127                                 AVR32_GPIO.port[3].oderc = LEDS_LEDMASK3;
128                                 AVR32_GPIO.port[3].ovrc  = LEDS_LEDMASK3;
129                         }
130
131                         static inline void LEDs_TurnOnLEDs(const uint32_t LEDMask)
132                         {
133                                 AVR32_GPIO.port[1].ovrc  = (LEDMask & LEDS_LEDMASK1);
134                                 AVR32_GPIO.port[3].ovrc  = (LEDMask & LEDS_LEDMASK3);
135                         }
136
137                         static inline void LEDs_TurnOffLEDs(const uint32_t LEDMask)
138                         {
139                                 AVR32_GPIO.port[1].ovrs  = (LEDMask & LEDS_LEDMASK1);
140                                 AVR32_GPIO.port[3].ovrs  = (LEDMask & LEDS_LEDMASK3);
141                         }
142
143                         static inline void LEDs_SetAllLEDs(const uint32_t LEDMask)
144                         {
145                                 AVR32_GPIO.port[1].ovrs  = LEDS_LEDMASK1;
146                                 AVR32_GPIO.port[1].ovrc  = (LEDMask & LEDS_LEDMASK1);
147
148                                 AVR32_GPIO.port[3].ovrs  = LEDS_LEDMASK3;
149                                 AVR32_GPIO.port[3].ovrc  = (LEDMask & LEDS_LEDMASK3);
150                         }
151
152                         static inline void LEDs_ChangeLEDs(const uint32_t LEDMask, const uint32_t ActiveMask)
153                         {
154                                 AVR32_GPIO.port[1].ovrs  = (LEDMask    & LEDS_LEDMASK1);
155                                 AVR32_GPIO.port[1].ovrc  = (ActiveMask & LEDS_LEDMASK1);
156
157                                 AVR32_GPIO.port[3].ovrs  = (LEDMask    & LEDS_LEDMASK3);
158                                 AVR32_GPIO.port[3].ovrc  = (ActiveMask & LEDS_LEDMASK3);
159                         }
160
161                         static inline void LEDs_ToggleLEDs(const uint32_t LEDMask)
162                         {
163                                 AVR32_GPIO.port[1].ovrt  = (LEDMask & LEDS_LEDMASK1);
164                                 AVR32_GPIO.port[3].ovrt  = (LEDMask & LEDS_LEDMASK3);
165                         }
166
167                         static inline uint32_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
168                         static inline uint32_t LEDs_GetLEDs(void)
169                         {
170                                 return ((~AVR32_GPIO.port[1].ovr & LEDS_LEDMASK1) | (~AVR32_GPIO.port[3].ovr & LEDS_LEDMASK3));
171                         }
172                 #endif
173
174         /* Disable C linkage for C++ Compilers: */
175                 #if defined(__cplusplus)
176                         }
177                 #endif
178
179 #endif
180
181 /** @} */
182