Keyboard firmwares for Atmel AVR and Cortex-M
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

USBInterrupt_XMEGA.h 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 USB Controller Interrupt definitions for the AVR XMEGA microcontrollers.
  28. *
  29. * This file contains definitions required for the correct handling of low level USB service routine interrupts
  30. * from the USB controller.
  31. *
  32. * \note This file should not be included directly. It is automatically included as needed by the USB driver
  33. * dispatch header located in LUFA/Drivers/USB/USB.h.
  34. */
  35. #ifndef __USBINTERRUPT_XMEGA_H__
  36. #define __USBINTERRUPT_XMEGA_H__
  37. /* Includes: */
  38. #include "../../../../Common/Common.h"
  39. /* Enable C linkage for C++ Compilers: */
  40. #if defined(__cplusplus)
  41. extern "C" {
  42. #endif
  43. /* Preprocessor Checks: */
  44. #if !defined(__INCLUDE_FROM_USB_DRIVER)
  45. #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
  46. #endif
  47. /* Private Interface - For use in library only: */
  48. #if !defined(__DOXYGEN__)
  49. /* Enums: */
  50. enum USB_Interrupts_t
  51. {
  52. USB_INT_BUSEVENTI = 1,
  53. USB_INT_BUSEVENTI_Suspend = 2,
  54. USB_INT_BUSEVENTI_Resume = 3,
  55. USB_INT_BUSEVENTI_Reset = 4,
  56. USB_INT_SOFI = 5,
  57. };
  58. /* Inline Functions: */
  59. static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
  60. static inline void USB_INT_Enable(const uint8_t Interrupt)
  61. {
  62. switch (Interrupt)
  63. {
  64. case USB_INT_BUSEVENTI:
  65. USB.INTCTRLA |= USB_BUSEVIE_bm;
  66. break;
  67. case USB_INT_SOFI:
  68. USB.INTCTRLA |= USB_SOFIE_bm;
  69. break;
  70. default:
  71. break;
  72. }
  73. }
  74. static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
  75. static inline void USB_INT_Disable(const uint8_t Interrupt)
  76. {
  77. switch (Interrupt)
  78. {
  79. case USB_INT_BUSEVENTI:
  80. USB.INTCTRLA &= ~USB_BUSEVIE_bm;
  81. break;
  82. case USB_INT_SOFI:
  83. USB.INTCTRLA &= ~USB_SOFIE_bm;
  84. break;
  85. default:
  86. break;
  87. }
  88. }
  89. static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
  90. static inline void USB_INT_Clear(const uint8_t Interrupt)
  91. {
  92. switch (Interrupt)
  93. {
  94. case USB_INT_BUSEVENTI_Suspend:
  95. USB.INTFLAGSACLR = USB_SUSPENDIF_bm;
  96. break;
  97. case USB_INT_BUSEVENTI_Resume:
  98. USB.INTFLAGSACLR = USB_RESUMEIF_bm;
  99. break;
  100. case USB_INT_BUSEVENTI_Reset:
  101. USB.INTFLAGSACLR = USB_RSTIF_bm;
  102. break;
  103. case USB_INT_SOFI:
  104. USB.INTFLAGSACLR = USB_SOFIF_bm;
  105. break;
  106. default:
  107. break;
  108. }
  109. }
  110. static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
  111. static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)
  112. {
  113. switch (Interrupt)
  114. {
  115. case USB_INT_BUSEVENTI:
  116. return ((USB.INTCTRLA & USB_BUSEVIE_bm) ? true : false);
  117. case USB_INT_SOFI:
  118. return ((USB.INTCTRLA & USB_SOFIE_bm) ? true : false);
  119. default:
  120. return false;
  121. }
  122. }
  123. static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
  124. static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)
  125. {
  126. switch (Interrupt)
  127. {
  128. case USB_INT_BUSEVENTI_Suspend:
  129. return ((USB.INTFLAGSACLR & USB_SUSPENDIF_bm) ? true : false);
  130. case USB_INT_BUSEVENTI_Resume:
  131. return ((USB.INTFLAGSACLR & USB_RESUMEIF_bm) ? true : false);
  132. case USB_INT_BUSEVENTI_Reset:
  133. return ((USB.INTFLAGSACLR & USB_RSTIF_bm) ? true : false);
  134. case USB_INT_SOFI:
  135. return ((USB.INTFLAGSACLR & USB_SOFIF_bm) ? true : false);
  136. default:
  137. return false;
  138. }
  139. }
  140. /* Includes: */
  141. #include "../USBMode.h"
  142. #include "../Events.h"
  143. #include "../USBController.h"
  144. /* Function Prototypes: */
  145. void USB_INT_ClearAllInterrupts(void);
  146. void USB_INT_DisableAllInterrupts(void);
  147. #endif
  148. /* Disable C linkage for C++ Compilers: */
  149. #if defined(__cplusplus)
  150. }
  151. #endif
  152. #endif