Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LEDs.h 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2014.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2014 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  9. Permission to use, copy, modify, distribute, and sell this
  10. software and its documentation for any purpose is hereby granted
  11. without fee, provided that the above copyright notice appear in
  12. all copies and that both that the copyright notice and this
  13. permission notice and warranty disclaimer appear in supporting
  14. documentation, and that the name of the author not be used in
  15. advertising or publicity pertaining to distribution of the
  16. software without specific, written prior permission.
  17. The author disclaims all warranties with regard to this
  18. software, including all implied warranties of merchantability
  19. and fitness. In no event shall the author be liable for any
  20. special, indirect or consequential damages or any damages
  21. whatsoever resulting from loss of use, data or profits, whether
  22. in an action of contract, negligence or other tortious action,
  23. arising out of or in connection with the use or performance of
  24. this software.
  25. */
  26. /** \file
  27. * \brief Board specific LED driver header for the Xevelabs USB2AX.
  28. * \copydetails Group_LEDs_USB2AX
  29. *
  30. * \note This file should not be included directly. It is automatically included as needed by the LEDs driver
  31. * dispatch header located in LUFA/Drivers/Board/LEDs.h.
  32. */
  33. /** \ingroup Group_LEDs
  34. * \defgroup Group_LEDs_USB2AX_V31 USB2AX_V31
  35. * \brief Board specific LED driver header for the Xevelabs USB2AX revision 3.1.
  36. *
  37. * See \ref Group_LEDs_USB2AX for more details.
  38. */
  39. /** \ingroup Group_LEDs
  40. * \defgroup Group_LEDs_USB2AX_V3 USB2AX_V3
  41. * \brief Board specific LED driver header for the Xevelabs USB2AX revision 3.
  42. *
  43. * See \ref Group_LEDs_USB2AX for more details.
  44. */
  45. /** \ingroup Group_LEDs
  46. * \defgroup Group_LEDs_USB2AX USB2AX
  47. * \brief Board specific LED driver header for the Xevelabs USB2AX revisions 1 and 2.
  48. *
  49. * \note For version 3 USB2AX boards, compile with <code>BOARD = USB2AX_V3</code> and for version 3.1, with <code>BOARD = USB2AX_V31</code>.
  50. *
  51. * Board specific LED driver header for the Xevelabs USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX).
  52. *
  53. * <b>USB2AX</b>:
  54. * <table>
  55. * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  56. * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTC.6</td></tr>
  57. * </table>
  58. *
  59. * <b>USB2AX_V3</b>:
  60. * <table>
  61. * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  62. * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.1</td></tr>
  63. * </table>
  64. *
  65. * <b>USB2AX_V31</b>:
  66. * <table>
  67. * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  68. * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.5</td></tr>
  69. * <tr><td>LEDS_LED2</td><td>Red</td><td>General Indicator</td><td>High</td><td>PORTD.6</td></tr>
  70. * </table>
  71. *
  72. * @{
  73. */
  74. #ifndef __LEDS_USB2AX_H__
  75. #define __LEDS_USB2AX_H__
  76. /* Includes: */
  77. #include "../../../../Common/Common.h"
  78. /* Enable C linkage for C++ Compilers: */
  79. #if defined(__cplusplus)
  80. extern "C" {
  81. #endif
  82. /* Preprocessor Checks: */
  83. #if !defined(__INCLUDE_FROM_LEDS_H)
  84. #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
  85. #endif
  86. /* Private Interface - For use in library only: */
  87. #if !defined(__DOXYGEN__)
  88. /* Macros: */
  89. #if (BOARD == BOARD_USB2AX_V31)
  90. #define USB2AX_LEDS_LED1 (1 << 5)
  91. #define USB2AX_LEDS_LED2 (1 << 6)
  92. #elif (BOARD == BOARD_USB2AX_V3)
  93. #define USB2AX_LEDS_LED1 (1 << 1)
  94. #define USB2AX_LEDS_LED2 0
  95. #else
  96. #define USB2AX_LEDS_LED1 (1 << 6)
  97. #define USB2AX_LEDS_LED2 0
  98. #endif
  99. #endif
  100. /* Public Interface - May be used in end-application: */
  101. /* Macros: */
  102. /** LED mask for the first LED on the board. */
  103. #define LEDS_LED1 USB2AX_LEDS_LED1
  104. /** LED mask for the second LED on the board. */
  105. #define LEDS_LED2 USB2AX_LEDS_LED2
  106. /** LED mask for all the LEDs on the board. */
  107. #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)
  108. /** LED mask for none of the board LEDs. */
  109. #define LEDS_NO_LEDS 0
  110. /* Inline Functions: */
  111. #if !defined(__DOXYGEN__)
  112. static inline void LEDs_Init(void)
  113. {
  114. #if (BOARD == BOARD_USB2AX)
  115. DDRC |= LEDS_ALL_LEDS;
  116. PORTC &= ~LEDS_ALL_LEDS;
  117. #else
  118. DDRD |= LEDS_ALL_LEDS;
  119. PORTD &= ~LEDS_ALL_LEDS;
  120. #endif
  121. }
  122. static inline void LEDs_Disable(void)
  123. {
  124. #if (BOARD == BOARD_USB2AX)
  125. DDRC &= ~LEDS_ALL_LEDS;
  126. PORTC &= ~LEDS_ALL_LEDS;
  127. #else
  128. DDRD &= ~LEDS_ALL_LEDS;
  129. PORTD &= ~LEDS_ALL_LEDS;
  130. #endif
  131. }
  132. static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
  133. {
  134. #if (BOARD == BOARD_USB2AX)
  135. PORTC |= LEDMask;
  136. #else
  137. PORTD |= LEDMask;
  138. #endif
  139. }
  140. static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
  141. {
  142. #if (BOARD == BOARD_USB2AX)
  143. PORTC &= ~LEDMask;
  144. #else
  145. PORTD &= ~LEDMask;
  146. #endif
  147. }
  148. static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
  149. {
  150. #if (BOARD == BOARD_USB2AX)
  151. PORTC = ((PORTC & ~LEDS_ALL_LEDS) | LEDMask);
  152. #else
  153. PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);
  154. #endif
  155. }
  156. static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
  157. const uint8_t ActiveMask)
  158. {
  159. #if (BOARD == BOARD_USB2AX)
  160. PORTC = ((PORTC & ~LEDMask) | ActiveMask);
  161. #else
  162. PORTD = ((PORTD & ~LEDMask) | ActiveMask);
  163. #endif
  164. }
  165. static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
  166. {
  167. #if (BOARD == BOARD_USB2AX)
  168. PINC = LEDMask;
  169. #else
  170. PIND = LEDMask;
  171. #endif
  172. }
  173. static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
  174. static inline uint8_t LEDs_GetLEDs(void)
  175. {
  176. #if (BOARD == BOARD_USB2AX)
  177. return (PORTC & LEDS_ALL_LEDS);
  178. #else
  179. return (PORTD & LEDS_ALL_LEDS);
  180. #endif
  181. }
  182. #endif
  183. /* Disable C linkage for C++ Compilers: */
  184. #if defined(__cplusplus)
  185. }
  186. #endif
  187. #endif
  188. /** @} */