Keyboard firmwares for Atmel AVR and Cortex-M
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

Buttons.h 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 Buttons driver header for the Micropendous series boards.
  28. * \copydetails Group_Buttons_MICROPENDOUS_32U2
  29. *
  30. * \note This file should not be included directly. It is automatically included as needed by the Buttons driver
  31. * dispatch header located in LUFA/Drivers/Board/Buttons.h.
  32. */
  33. /** \ingroup Group_Buttons
  34. * \defgroup Group_Buttons_MICROPENDOUS_A MICROPENDOUS_A
  35. * \brief Board specific Button driver header for the Micropendous A (https://code.google.com/p/micropendous/wiki/MicropendousA).
  36. *
  37. * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
  38. */
  39. /** \ingroup Group_Buttons
  40. * \defgroup Group_Buttons_MICROPENDOUS_1 MICROPENDOUS_1
  41. * \brief Board specific Button driver header for the Micropendous 1 (https://code.google.com/p/micropendous/wiki/Micropendous1).
  42. *
  43. * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
  44. */
  45. /** \ingroup Group_Buttons
  46. * \defgroup Group_Buttons_MICROPENDOUS_2 MICROPENDOUS_2
  47. * \brief Board specific Button driver header for the Micropendous 2 (https://code.google.com/p/micropendous/wiki/Micropendous2).
  48. *
  49. * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
  50. */
  51. /** \ingroup Group_Buttons
  52. * \defgroup Group_Buttons_MICROPENDOUS_3 MICROPENDOUS_3
  53. * \brief Board specific Button driver header for the Micropendous 3 (https://code.google.com/p/micropendous/wiki/Micropendous3).
  54. *
  55. * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
  56. */
  57. /** \ingroup Group_Buttons
  58. * \defgroup Group_Buttons_MICROPENDOUS_4 MICROPENDOUS_4
  59. * \brief Board specific Button driver header for the Micropendous 4 (https://code.google.com/p/micropendous/wiki/Micropendous4).
  60. *
  61. * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
  62. */
  63. /** \ingroup Group_Buttons
  64. * \defgroup Group_Buttons_MICROPENDOUS_DIP MICROPENDOUS_DIP
  65. * \brief Board specific Button driver header for the Micropendous DIP (https://code.google.com/p/micropendous/wiki/MicropendousDIP).
  66. *
  67. * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
  68. */
  69. /** \ingroup Group_Buttons
  70. * \defgroup Group_Buttons_MICROPENDOUS_REV1 MICROPENDOUS_REV1
  71. * \brief Board specific Button driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous).
  72. *
  73. * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
  74. */
  75. /** \ingroup Group_Buttons
  76. * \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2
  77. * \brief Board specific Button driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous).
  78. *
  79. * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.
  80. */
  81. /** \ingroup Group_Buttons
  82. * \defgroup Group_Buttons_MICROPENDOUS_32U2 MICROPENDOUS_32U2
  83. * \brief Board specific Buttons driver header for the Micropendous 32U2.
  84. *
  85. * \note There are multiple supported Micropendous boards, compile with <code>BOARD = MICROPENDOUS_{VERSION}</code>.
  86. *
  87. * Board specific Buttons driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2).
  88. *
  89. * <b>BOARD_MICROPENDOUS_1 and BOARD_MICROPENDOUS_32U2</b>:
  90. * <table>
  91. * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  92. * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>
  93. * </table>
  94. *
  95. * <b>Other Revisions</b>:
  96. * <table>
  97. * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  98. * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>
  99. * </table>
  100. *
  101. * @{
  102. */
  103. #ifndef __BUTTONS_MICROPENDOUS_H__
  104. #define __BUTTONS_MICROPENDOUS_H__
  105. /* Includes: */
  106. #include "../../../../Common/Common.h"
  107. /* Enable C linkage for C++ Compilers: */
  108. #if defined(__cplusplus)
  109. extern "C" {
  110. #endif
  111. /* Preprocessor Checks: */
  112. #if !defined(__INCLUDE_FROM_BUTTONS_H)
  113. #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
  114. #endif
  115. /* Private Interface - For use in library only: */
  116. #if !defined(__DOXYGEN__)
  117. #if (BOARD == BOARD_MICROPENDOUS_32U2)
  118. #define _BOARD_BUTTON1_MASK (1 << 7)
  119. #define _BOARD_BUTTON_PORTLETTER D
  120. #elif (BOARD == BOARD_MICROPENDOUS_A)
  121. #define _BOARD_BUTTON1_MASK (1 << 2)
  122. #define _BOARD_BUTTON_PORTLETTER E
  123. #elif (BOARD == BOARD_MICROPENDOUS_1)
  124. #define _BOARD_BUTTON1_MASK (1 << 7)
  125. #define _BOARD_BUTTON_PORTLETTER D
  126. #elif (BOARD == BOARD_MICROPENDOUS_2)
  127. #define _BOARD_BUTTON1_MASK (1 << 2)
  128. #define _BOARD_BUTTON_PORTLETTER E
  129. #elif (BOARD == BOARD_MICROPENDOUS_3)
  130. #define _BOARD_BUTTON1_MASK (1 << 2)
  131. #define _BOARD_BUTTON_PORTLETTER E
  132. #elif (BOARD == BOARD_MICROPENDOUS_4)
  133. #define _BOARD_BUTTON1_MASK (1 << 2)
  134. #define _BOARD_BUTTON_PORTLETTER E
  135. #elif (BOARD == BOARD_MICROPENDOUS_DIP)
  136. #define _BOARD_BUTTON1_MASK (1 << 2)
  137. #define _BOARD_BUTTON_PORTLETTER E
  138. #elif (BOARD == BOARD_MICROPENDOUS_REV1)
  139. #define _BOARD_BUTTON1_MASK (1 << 2)
  140. #define _BOARD_BUTTON_PORTLETTER E
  141. #elif (BOARD == BOARD_MICROPENDOUS_REV2)
  142. #define _BOARD_BUTTON1_MASK (1 << 2)
  143. #define _BOARD_BUTTON_PORTLETTER E
  144. #endif
  145. #define _BOARD_BUTTON_CONCAT2(Reg, Letter) Reg ## Letter
  146. #define _BOARD_BUTTON_CONCAT(Reg, Letter) _BOARD_BUTTON_CONCAT2(Reg, Letter)
  147. #define _BOARD_BUTTON_PORT _BOARD_BUTTON_CONCAT(PORT, _BOARD_BUTTON_PORTLETTER)
  148. #define _BOARD_BUTTON_PIN _BOARD_BUTTON_CONCAT(PIN, _BOARD_BUTTON_PORTLETTER)
  149. #define _BOARD_BUTTON_DDR _BOARD_BUTTON_CONCAT(DDR, _BOARD_BUTTON_PORTLETTER)
  150. #endif
  151. /* Public Interface - May be used in end-application: */
  152. /* Macros: */
  153. /** Button mask for the first button on the board. */
  154. #define BUTTONS_BUTTON1 _BOARD_BUTTON1_MASK
  155. /* Inline Functions: */
  156. #if !defined(__DOXYGEN__)
  157. static inline void Buttons_Init(void)
  158. {
  159. _BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;
  160. _BOARD_BUTTON_PORT |= BUTTONS_BUTTON1;
  161. }
  162. static inline void Buttons_Disable(void)
  163. {
  164. _BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;
  165. _BOARD_BUTTON_PORT &= ~BUTTONS_BUTTON1;
  166. }
  167. static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
  168. static inline uint8_t Buttons_GetStatus(void)
  169. {
  170. return ((_BOARD_BUTTON_PIN & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
  171. }
  172. #endif
  173. /* Disable C linkage for C++ Compilers: */
  174. #if defined(__cplusplus)
  175. }
  176. #endif
  177. #endif
  178. /** @} */