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.

Buttons.h 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 Buttons driver header for the Xevelabs USB2AX.
  28. * \copydetails Group_Buttons_USB2AX
  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_USB2AX_V31 USB2AX_V31
  35. * \brief Board specific Button driver header for the Xevelabs USB2AX revision 3.1.
  36. *
  37. * See \ref Group_Buttons_USB2AX for more details.
  38. */
  39. /** \ingroup Group_Buttons
  40. * \defgroup Group_Buttons_USB2AX_V3 USB2AX_V3
  41. * \brief Board specific Button driver header for the Xevelabs USB2AX revision 3.
  42. *
  43. * See \ref Group_Buttons_USB2AX for more details.
  44. */
  45. /** \ingroup Group_Buttons
  46. * \defgroup Group_Buttons_USB2AX USB2AX
  47. * \brief Board specific Buttons 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 Buttons driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX).
  52. *
  53. * <table>
  54. * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  55. * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>
  56. * </table>
  57. *
  58. * @{
  59. */
  60. #ifndef __BUTTONS_USB2AX_H__
  61. #define __BUTTONS_USB2AX_H__
  62. /* Includes: */
  63. #include "../../../../Common/Common.h"
  64. /* Enable C linkage for C++ Compilers: */
  65. #if defined(__cplusplus)
  66. extern "C" {
  67. #endif
  68. /* Preprocessor Checks: */
  69. #if !defined(__INCLUDE_FROM_BUTTONS_H)
  70. #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
  71. #endif
  72. /* Public Interface - May be used in end-application: */
  73. /* Macros: */
  74. /** Button mask for the first button on the board. */
  75. #define BUTTONS_BUTTON1 (1 << 7)
  76. /* Inline Functions: */
  77. #if !defined(__DOXYGEN__)
  78. static inline void Buttons_Init(void)
  79. {
  80. DDRD &= ~BUTTONS_BUTTON1;
  81. PORTD |= BUTTONS_BUTTON1;
  82. }
  83. static inline void Buttons_Disable(void)
  84. {
  85. DDRD &= ~BUTTONS_BUTTON1;
  86. PORTD &= ~BUTTONS_BUTTON1;
  87. }
  88. static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
  89. static inline uint8_t Buttons_GetStatus(void)
  90. {
  91. return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
  92. }
  93. #endif
  94. /* Disable C linkage for C++ Compilers: */
  95. #if defined(__cplusplus)
  96. }
  97. #endif
  98. #endif
  99. /** @} */