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.

123 lines
4.0 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 joystick driver header for the Fletchtronics BUMBLEB.
  28. * \copydetails Group_Joystick_BUMBLEB
  29. *
  30. * \note This file should not be included directly. It is automatically included as needed by the joystick driver
  31. * dispatch header located in LUFA/Drivers/Board/Joystick.h.
  32. */
  33. /** \ingroup Group_Joystick
  34. * \defgroup Group_Joystick_BUMBLEB BUMBLEB
  35. * \brief Board specific joystick driver header for the Fletchtronics BUMBLEB.
  36. *
  37. * Board specific joystick driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). The BUMBLEB
  38. * third-party board does not include any on-board peripherals, but does have an officially recommended external peripheral
  39. * layout for buttons, LEDs and a Joystick.
  40. *
  41. * <table>
  42. * <tr><th>Left Port Pin</th><th>Up Port Pin</th><th>Right Port Pin</th><th>Down Port Pin</th><th>Press Port Pin</th></tr>
  43. * <tr><td>PORTD.2</td><td>PORTD.3</td><td>PORTD.0</td><td>PORTD.1</td><td>PORTD.4</td></tr>
  44. * </table>
  45. *
  46. * @{
  47. */
  48. #ifndef __JOYSTICK_BUMBLEB_H__
  49. #define __JOYSTICK_BUMBLEB_H__
  50. /* Includes: */
  51. #include "../../../../Common/Common.h"
  52. /* Enable C linkage for C++ Compilers: */
  53. #if defined(__cplusplus)
  54. extern "C" {
  55. #endif
  56. /* Preprocessor Checks: */
  57. #if !defined(__INCLUDE_FROM_JOYSTICK_H)
  58. #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.
  59. #endif
  60. /* Private Interface - For use in library only: */
  61. #if !defined(__DOXYGEN__)
  62. /* Macros: */
  63. #define JOY_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4))
  64. #endif
  65. /* Public Interface - May be used in end-application: */
  66. /* Macros: */
  67. /** Mask for the joystick being pushed in the left direction. */
  68. #define JOY_LEFT (1 << 2)
  69. /** Mask for the joystick being pushed in the upward direction. */
  70. #define JOY_UP (1 << 3)
  71. /** Mask for the joystick being pushed in the right direction. */
  72. #define JOY_RIGHT (1 << 0)
  73. /** Mask for the joystick being pushed in the downward direction. */
  74. #define JOY_DOWN (1 << 1)
  75. /** Mask for the joystick being pushed inward. */
  76. #define JOY_PRESS (1 << 4)
  77. /* Inline Functions: */
  78. #if !defined(__DOXYGEN__)
  79. static inline void Joystick_Init(void)
  80. {
  81. DDRD &= ~JOY_MASK;
  82. PORTD |= JOY_MASK;
  83. }
  84. static inline void Joystick_Disable(void)
  85. {
  86. DDRD &= ~JOY_MASK;
  87. PORTD &= ~JOY_MASK;
  88. }
  89. static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
  90. static inline uint8_t Joystick_GetStatus(void)
  91. {
  92. return (uint8_t)(~PIND & JOY_MASK);
  93. }
  94. #endif
  95. /* Disable C linkage for C++ Compilers: */
  96. #if defined(__cplusplus)
  97. }
  98. #endif
  99. #endif
  100. /** @} */