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

Fri, 17 Nov 2017 10:13:31 +0100

author
mdd
date
Fri, 17 Nov 2017 10:13:31 +0100
changeset 3
770b218a4931
parent 2
b373b0288715
permissions
-rw-r--r--

proper configuration, homing and planner optimization

2
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
1 /*
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
2 LUFA Library
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
3 Copyright (C) Dean Camera, 2010.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
4
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
5 dean [at] fourwalledcubicle [dot] com
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
6 www.fourwalledcubicle.com
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
7 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
8
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
9 /*
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
11
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
12 Permission to use, copy, modify, distribute, and sell this
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
13 software and its documentation for any purpose is hereby granted
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
14 without fee, provided that the above copyright notice appear in
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
15 all copies and that both that the copyright notice and this
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
16 permission notice and warranty disclaimer appear in supporting
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
17 documentation, and that the name of the author not be used in
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
18 advertising or publicity pertaining to distribution of the
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
19 software without specific, written prior permission.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
20
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
21 The author disclaim all warranties with regard to this
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
22 software, including all implied warranties of merchantability
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
23 and fitness. In no event shall the author be liable for any
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
24 special, indirect or consequential damages or any damages
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
25 whatsoever resulting from loss of use, data or profits, whether
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
26 in an action of contract, negligence or other tortious action,
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
27 arising out of or in connection with the use or performance of
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
28 this software.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
29 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
30
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
31 /*
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
32 Board LEDs driver for the Benito board, from www.dorkbotpdx.org.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
33 */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
34
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
35 #ifndef __LEDS_ARDUINOUNO_H__
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
36 #define __LEDS_ARDUINOUNO_H__
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
37
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
38 /* Includes: */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
39 #include <avr/io.h>
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
40
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
41 /* Enable C linkage for C++ Compilers: */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
42 #if defined(__cplusplus)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
43 extern "C" {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
44 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
45
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
46 /* Preprocessor Checks: */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
47 #if !defined(INCLUDE_FROM_LEDS_H)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
48 #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
49 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
50
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
51 /* Public Interface - May be used in end-application: */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
52 /* Macros: */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
53 /** LED mask for the first LED on the board. */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
54 #define LEDS_LED1 (1 << 5)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
55
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
56 /** LED mask for the second LED on the board. */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
57 #define LEDS_LED2 (1 << 4)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
58
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
59 /** LED mask for all the LEDs on the board. */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
60 #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
61
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
62 /** LED mask for the none of the board LEDs */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
63 #define LEDS_NO_LEDS 0
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
64
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
65 /* Inline Functions: */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
66 #if !defined(__DOXYGEN__)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
67 static inline void LEDs_Init(void)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
68 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
69 DDRD |= LEDS_ALL_LEDS;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
70 PORTD |= LEDS_ALL_LEDS;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
71 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
72
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
73 static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
74 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
75 PORTD &= ~LEDMask;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
76 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
77
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
78 static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
79 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
80 PORTD |= LEDMask;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
81 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
82
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
83 static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
84 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
85 PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
86 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
87
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
88 static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
89 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
90 PORTD = ((PORTD | ActiveMask) & ~LEDMask);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
91 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
92
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
93 static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
94 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
95 PORTD ^= LEDMask;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
96 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
97
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
98 static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
99 static inline uint8_t LEDs_GetLEDs(void)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
100 {
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
101 return (PORTD & LEDS_ALL_LEDS);
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
102 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
103 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
104
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
105 /* Disable C linkage for C++ Compilers: */
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
106 #if defined(__cplusplus)
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
107 }
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
108 #endif
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
109
b373b0288715 added missing sanguino files
mbayer
parents:
diff changeset
110 #endif

mercurial