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.

177 lines
5.9 KiB

  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 Micropendous-32U2.
  28. * \copydetails Group_LEDs_MICROPENDOUS_32U2
  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_MICROPENDOUS_REV1 MICROPENDOUS_REV1
  35. * \brief Board specific LED driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous).
  36. *
  37. * See \ref Group_LEDs_MICROPENDOUS_32U2 for more details.
  38. */
  39. /** \ingroup Group_LEDs
  40. * \defgroup Group_LEDs_MICROPENDOUS_REV2 MICROPENDOUS_REV2
  41. * \brief Board specific LED driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous).
  42. *
  43. * See \ref Group_LEDs_MICROPENDOUS_32U2 for more details.
  44. */
  45. /** \ingroup Group_LEDs
  46. * \defgroup Group_LEDs_MICROPENDOUS_32U2 MICROPENDOUS_32U2
  47. * \brief Board specific LED driver header for the Micropendous-32U2.
  48. *
  49. * Board specific LED driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2).
  50. *
  51. * <b>BOARD_MICROPENDOUS_32U2</b>:
  52. * <table>
  53. * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  54. * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.6</td></tr>
  55. * </table>
  56. *
  57. * <b>Other Revisions</b>:
  58. * <table>
  59. * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  60. * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTB.1</td></tr>
  61. * </table>
  62. *
  63. * @{
  64. */
  65. #ifndef __LEDS_MICROPENDOUS_H__
  66. #define __LEDS_MICROPENDOUS_H__
  67. /* Includes: */
  68. #include "../../../../Common/Common.h"
  69. /* Enable C linkage for C++ Compilers: */
  70. #if defined(__cplusplus)
  71. extern "C" {
  72. #endif
  73. /* Preprocessor Checks: */
  74. #if !defined(__INCLUDE_FROM_LEDS_H)
  75. #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
  76. #endif
  77. /* Private Interface - For use in library only: */
  78. #if !defined(__DOXYGEN__)
  79. #if (BOARD == BOARD_MICROPENDOUS_32U2)
  80. #define _BOARD_LED1_MASK (1 << 6)
  81. #define _BOARD_LED_PORTLETTER D
  82. #elif (BOARD == BOARD_MICROPENDOUS_REV1)
  83. #define _BOARD_LED1_MASK (1 << 1)
  84. #define _BOARD_LED_PORTLETTER B
  85. #elif (BOARD == BOARD_MICROPENDOUS_REV2)
  86. #define _BOARD_LED1_MASK (1 << 1)
  87. #define _BOARD_LED_PORTLETTER B
  88. #endif
  89. #define _BOARD_LED_CONCAT2(Reg, Letter) Reg ## Letter
  90. #define _BOARD_LED_CONCAT(Reg, Letter) _BOARD_LED_CONCAT2(Reg, Letter)
  91. #define _BOARD_LED_PORT _BOARD_LED_CONCAT(PORT, _BOARD_LED_PORTLETTER)
  92. #define _BOARD_LED_PIN _BOARD_LED_CONCAT(PIN, _BOARD_LED_PORTLETTER)
  93. #define _BOARD_LED_DDR _BOARD_LED_CONCAT(DDR, _BOARD_LED_PORTLETTER)
  94. #endif
  95. /* Public Interface - May be used in end-application: */
  96. /* Macros: */
  97. /** LED mask for the first LED on the board. */
  98. #define LEDS_LED1 _BOARD_LED1_MASK
  99. /** LED mask for all the LEDs on the board. */
  100. #define LEDS_ALL_LEDS LEDS_LED1
  101. /** LED mask for the none of the board LEDs. */
  102. #define LEDS_NO_LEDS 0
  103. /* Inline Functions: */
  104. #if !defined(__DOXYGEN__)
  105. static inline void LEDs_Init(void)
  106. {
  107. _BOARD_LED_DDR |= LEDS_ALL_LEDS;
  108. _BOARD_LED_PORT &= ~LEDS_ALL_LEDS;
  109. }
  110. static inline void LEDs_Disable(void)
  111. {
  112. _BOARD_LED_DDR &= ~LEDS_ALL_LEDS;
  113. _BOARD_LED_PORT &= ~LEDS_ALL_LEDS;
  114. }
  115. static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
  116. {
  117. _BOARD_LED_PORT |= LEDMask;
  118. }
  119. static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
  120. {
  121. _BOARD_LED_PORT &= ~LEDMask;
  122. }
  123. static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
  124. {
  125. _BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDS_ALL_LEDS) | LEDMask);
  126. }
  127. static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,
  128. const uint8_t ActiveMask)
  129. {
  130. _BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDMask) | ActiveMask);
  131. }
  132. static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
  133. {
  134. _BOARD_LED_PIN = LEDMask;
  135. }
  136. static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
  137. static inline uint8_t LEDs_GetLEDs(void)
  138. {
  139. return (_BOARD_LED_PORT & LEDS_ALL_LEDS);
  140. }
  141. #endif
  142. /* Disable C linkage for C++ Compilers: */
  143. #if defined(__cplusplus)
  144. }
  145. #endif
  146. #endif
  147. /** @} */