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.

LEDs.h 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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 Fletchtronics BUMBLEB.
  28. * \copydetails Group_LEDs_BUMBLEB
  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_BUMBLEB BUMBLEB
  35. * \brief Board specific LED driver header for the Fletchtronics BUMBLEB.
  36. *
  37. * Board specific LED 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
  39. * peripheral layout for buttons, LEDs and a Joystick.
  40. *
  41. * <table>
  42. * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>
  43. * <tr><td>LEDS_LED1</td><td>N/A</td><td>User Supplied</td><td>High</td><td>PORTB.4</td></tr>
  44. * <tr><td>LEDS_LED2</td><td>N/A</td><td>User Supplied</td><td>High</td><td>PORTB.5</td></tr>
  45. * <tr><td>LEDS_LED3</td><td>N/A</td><td>User Supplied</td><td>High</td><td>PORTB.6</td></tr>
  46. * <tr><td>LEDS_LED4</td><td>N/A</td><td>User Supplied</td><td>High</td><td>PORTB.7</td></tr>
  47. * </table>
  48. *
  49. * @{
  50. */
  51. #ifndef __LEDS_BUMBLEB_H__
  52. #define __LEDS_BUMBLEB_H__
  53. /* Includes: */
  54. #include "../../../../Common/Common.h"
  55. /* Enable C linkage for C++ Compilers: */
  56. #if defined(__cplusplus)
  57. extern "C" {
  58. #endif
  59. /* Preprocessor Checks: */
  60. #if !defined(__INCLUDE_FROM_LEDS_H)
  61. #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
  62. #endif
  63. /* Public Interface - May be used in end-application: */
  64. /* Macros: */
  65. /** LED mask for the first LED on the board. */
  66. #define LEDS_LED1 (1 << 4)
  67. /** LED mask for the second LED on the board. */
  68. #define LEDS_LED2 (1 << 5)
  69. /** LED mask for the third LED on the board. */
  70. #define LEDS_LED3 (1 << 6)
  71. /** LED mask for the fourth LED on the board. */
  72. #define LEDS_LED4 (1 << 7)
  73. /** LED mask for all the LEDs on the board. */
  74. #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)
  75. /** LED mask for none of the board LEDs. */
  76. #define LEDS_NO_LEDS 0
  77. /* Inline Functions: */
  78. #if !defined(__DOXYGEN__)
  79. static inline void LEDs_Init(void)
  80. {
  81. DDRB |= LEDS_ALL_LEDS;
  82. PORTB &= ~LEDS_ALL_LEDS;
  83. }
  84. static inline void LEDs_Disable(void)
  85. {
  86. DDRB &= ~LEDS_ALL_LEDS;
  87. PORTB &= ~LEDS_ALL_LEDS;
  88. }
  89. static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)
  90. {
  91. PORTB |= LedMask;
  92. }
  93. static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)
  94. {
  95. PORTB &= ~LedMask;
  96. }
  97. static inline void LEDs_SetAllLEDs(const uint8_t LedMask)
  98. {
  99. PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LedMask);
  100. }
  101. static inline void LEDs_ChangeLEDs(const uint8_t LedMask,
  102. const uint8_t ActiveMask)
  103. {
  104. PORTB = ((PORTB & ~LedMask) | ActiveMask);
  105. }
  106. static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)
  107. {
  108. PINB = LEDMask;
  109. }
  110. static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
  111. static inline uint8_t LEDs_GetLEDs(void)
  112. {
  113. return (PORTB & LEDS_ALL_LEDS);
  114. }
  115. #endif
  116. /* Disable C linkage for C++ Compilers: */
  117. #if defined(__cplusplus)
  118. }
  119. #endif
  120. #endif
  121. /** @} */