Keyboard firmwares for Atmel AVR and Cortex-M
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. LUFA Library
  3. Copyright (C) Dean Camera, 2012.
  4. dean [at] fourwalledcubicle [dot] com
  5. www.lufa-lib.org
  6. */
  7. /*
  8. Copyright 2012 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 disclaim 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 Olimex AVR-USB-32U4.
  28. * \copydetails Group_LEDs_OLIMEX32U4
  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_OLIMEX32U4 OLIMEX32U4
  35. * \brief Board specific LED driver header for the Olimex AVR-USB-32U4.
  36. *
  37. * Board specific LED driver header for the Olimex AVR-USB-32U4 (http://www.olimex.com/dev/olimexino-32u4.html).
  38. *
  39. * <table>
  40. * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  41. * <tr><td>LEDS_LED1</td><td>Green</td><td>TX</td><td>High</td><td>PORTD.5</td></tr>
  42. * <tr><td>LEDS_LED2</td><td>Yellow</td><td>RX</td><td>High</td><td>PORTB.0</td></tr>
  43. * <tr><td>LEDS_LED3</td><td>Green</td><td>General Indicator (Default Unconnected)</td><td>High</td><td>PORTE.6</td></tr>
  44. * <tr><td>LEDS_LED4</td><td>Yellow</td><td>General Indicator (Default Unconnected)</td><td>High</td><td>PORTB.5</td></tr>
  45. * </table>
  46. *
  47. * @{
  48. */
  49. #ifndef __LEDS_OLIMEX32U4_H__
  50. #define __LEDS_OLIMEX32U4_H__
  51. /* Includes: */
  52. #include "../../../../Common/Common.h"
  53. /* Enable C linkage for C++ Compilers: */
  54. #if defined(__cplusplus)
  55. extern "C" {
  56. #endif
  57. /* Preprocessor Checks: */
  58. #if !defined(__INCLUDE_FROM_LEDS_H)
  59. #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
  60. #endif
  61. /* Private Interface - For use in library only: */
  62. #if !defined(__DOXYGEN__)
  63. /* Macros: */
  64. #define LEDS_PORTB_LEDS (LEDS_LED2 | LEDS_LED4)
  65. #define LEDS_PORTD_LEDS (LEDS_LED1)
  66. #define LEDS_PORTE_LEDS (LEDS_LED3)
  67. #define LEDS_PORTD_MASK_SHIFT 1
  68. #endif
  69. /* Public Interface - May be used in end-application: */
  70. /* Macros: */
  71. /** LED mask for the first LED on the board. */
  72. #define LEDS_LED1 ((1 << 5) >> LEDS_PORTD_MASK_SHIFT)
  73. /** LED mask for the second LED on the board. */
  74. #define LEDS_LED2 (1 << 0)
  75. /** LED mask for the third LED on the board. */
  76. #define LEDS_LED3 (1 << 5)
  77. /** LED mask for the fourth LED on the board. */
  78. #define LEDS_LED4 (1 << 6)
  79. /** LED mask for all the LEDs on the board. */
  80. #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)
  81. /** LED mask for none of the board LEDs. */
  82. #define LEDS_NO_LEDS 0
  83. /* Inline Functions: */
  84. #if !defined(__DOXYGEN__)
  85. static inline void LEDs_Init(void)
  86. {
  87. DDRB |= LEDS_PORTB_LEDS;
  88. PORTB &= ~LEDS_PORTB_LEDS;
  89. DDRD |= (LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);
  90. PORTD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);
  91. DDRE |= LEDS_PORTE_LEDS;
  92. PORTE &= ~LEDS_PORTE_LEDS;
  93. }
  94. static inline void LEDs_Disable(void)
  95. {
  96. DDRB &= ~LEDS_PORTB_LEDS;
  97. PORTB &= ~LEDS_PORTB_LEDS;
  98. DDRD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);
  99. PORTD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);
  100. DDRE &= ~LEDS_PORTE_LEDS;
  101. PORTE &= ~LEDS_PORTE_LEDS;
  102. }
  103. static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
  104. {
  105. PORTB |= (LEDMask & LEDS_PORTB_LEDS);
  106. PORTD |= ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);
  107. PORTE |= (LEDMask & LEDS_PORTE_LEDS);
  108. }
  109. static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
  110. {
  111. PORTB &= ~(LEDMask & LEDS_PORTB_LEDS);
  112. PORTD &= ~((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);
  113. PORTE &= ~(LEDMask & LEDS_PORTE_LEDS);
  114. }
  115. static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
  116. {
  117. PORTB = ((PORTB & ~LEDS_PORTB_LEDS) | (LEDMask & LEDS_PORTB_LEDS));
  118. PORTD = ((PORTD & ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT)) |
  119. ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT));
  120. PORTE = ((PORTE & ~LEDS_PORTE_LEDS) | (LEDMask & LEDS_PORTE_LEDS));
  121. }
  122. static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
  123. const uint8_t ActiveMask)
  124. {
  125. PORTB = ((PORTB & ~(LEDMask & LEDS_PORTB_LEDS)) | (ActiveMask & LEDS_PORTB_LEDS));
  126. PORTD = ((PORTD & ~((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT)) |
  127. ((ActiveMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT));
  128. PORTE = ((PORTE & ~(LEDMask & LEDS_PORTE_LEDS)) | (ActiveMask & LEDS_PORTE_LEDS));
  129. }
  130. static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
  131. {
  132. PINB = (LEDMask & LEDS_PORTB_LEDS);
  133. PIND = ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);
  134. PINE = (LEDMask & LEDS_PORTE_LEDS);
  135. }
  136. static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
  137. static inline uint8_t LEDs_GetLEDs(void)
  138. {
  139. return ((PORTB & LEDS_PORTB_LEDS) |
  140. ((PORTD & (LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT)) >> LEDS_PORTD_MASK_SHIFT) |
  141. (PORTE & LEDS_PORTE_LEDS));
  142. }
  143. #endif
  144. /* Disable C linkage for C++ Compilers: */
  145. #if defined(__cplusplus)
  146. }
  147. #endif
  148. #endif
  149. /** @} */