sanguino/firmwares/arduino-usbserial/Board/LEDs.h

changeset 2
b373b0288715
equal deleted inserted replaced
1:b584642d4f58 2:b373b0288715
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 /*
32 Board LEDs driver for the Benito board, from www.dorkbotpdx.org.
33 */
34
35 #ifndef __LEDS_ARDUINOUNO_H__
36 #define __LEDS_ARDUINOUNO_H__
37
38 /* Includes: */
39 #include <avr/io.h>
40
41 /* Enable C linkage for C++ Compilers: */
42 #if defined(__cplusplus)
43 extern "C" {
44 #endif
45
46 /* Preprocessor Checks: */
47 #if !defined(INCLUDE_FROM_LEDS_H)
48 #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
49 #endif
50
51 /* Public Interface - May be used in end-application: */
52 /* Macros: */
53 /** LED mask for the first LED on the board. */
54 #define LEDS_LED1 (1 << 5)
55
56 /** LED mask for the second LED on the board. */
57 #define LEDS_LED2 (1 << 4)
58
59 /** LED mask for all the LEDs on the board. */
60 #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)
61
62 /** LED mask for the none of the board LEDs */
63 #define LEDS_NO_LEDS 0
64
65 /* Inline Functions: */
66 #if !defined(__DOXYGEN__)
67 static inline void LEDs_Init(void)
68 {
69 DDRD |= LEDS_ALL_LEDS;
70 PORTD |= LEDS_ALL_LEDS;
71 }
72
73 static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
74 {
75 PORTD &= ~LEDMask;
76 }
77
78 static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
79 {
80 PORTD |= LEDMask;
81 }
82
83 static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
84 {
85 PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask);
86 }
87
88 static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
89 {
90 PORTD = ((PORTD | ActiveMask) & ~LEDMask);
91 }
92
93 static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
94 {
95 PORTD ^= LEDMask;
96 }
97
98 static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
99 static inline uint8_t LEDs_GetLEDs(void)
100 {
101 return (PORTD & LEDS_ALL_LEDS);
102 }
103 #endif
104
105 /* Disable C linkage for C++ Compilers: */
106 #if defined(__cplusplus)
107 }
108 #endif
109
110 #endif

mercurial