My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

usbuser.cpp 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /*----------------------------------------------------------------------------
  2. * U S B - K e r n e l
  3. *----------------------------------------------------------------------------
  4. * Name: usbuser.c
  5. * Purpose: USB Custom User Module
  6. * Version: V1.20
  7. *----------------------------------------------------------------------------
  8. * This software is supplied "AS IS" without any warranties, express,
  9. * implied or statutory, including but not limited to the implied
  10. * warranties of fitness for purpose, satisfactory quality and
  11. * noninfringement. Keil extends you a royalty-free right to reproduce
  12. * and distribute executable files created using this software for use
  13. * on NXP Semiconductors LPC family microcontroller devices only. Nothing
  14. * else gives you the right to use this software.
  15. *
  16. * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
  17. *---------------------------------------------------------------------------*/
  18. extern "C" {
  19. #include "lpc_types.h"
  20. #include <debug_frmwrk.h>
  21. }
  22. #include "usb.h"
  23. #include "usbcfg.h"
  24. #include "usbhw.h"
  25. #include "usbcore.h"
  26. #include "usbuser.h"
  27. #include "cdcuser.h"
  28. #include "mscuser.h"
  29. /*
  30. * USB Power Event Callback
  31. * Called automatically on USB Power Event
  32. * Parameter: power: On(TRUE)/Off(FALSE)
  33. */
  34. #if USB_POWER_EVENT
  35. void USB_Power_Event (uint32_t power) {
  36. }
  37. #endif
  38. /*
  39. * USB Reset Event Callback
  40. * Called automatically on USB Reset Event
  41. */
  42. #if USB_RESET_EVENT
  43. void USB_Reset_Event (void) {
  44. USB_ResetCore();
  45. }
  46. #endif
  47. /*
  48. * USB Suspend Event Callback
  49. * Called automatically on USB Suspend Event
  50. */
  51. #if USB_SUSPEND_EVENT
  52. void USB_Suspend_Event (void) {
  53. }
  54. #endif
  55. /*
  56. * USB Resume Event Callback
  57. * Called automatically on USB Resume Event
  58. */
  59. #if USB_RESUME_EVENT
  60. void USB_Resume_Event (void) {
  61. }
  62. #endif
  63. /*
  64. * USB Remote Wakeup Event Callback
  65. * Called automatically on USB Remote Wakeup Event
  66. */
  67. #if USB_WAKEUP_EVENT
  68. void USB_WakeUp_Event (void) {
  69. }
  70. #endif
  71. /*
  72. * USB Start of Frame Event Callback
  73. * Called automatically on USB Start of Frame Event
  74. */
  75. #if USB_SOF_EVENT
  76. void USB_SOF_Event (void) {
  77. }
  78. #endif
  79. /*
  80. * USB Error Event Callback
  81. * Called automatically on USB Error Event
  82. * Parameter: error: Error Code
  83. */
  84. #if USB_ERROR_EVENT
  85. void USB_Error_Event (uint32_t error) {
  86. }
  87. #endif
  88. /*
  89. * USB Set Configuration Event Callback
  90. * Called automatically on USB Set Configuration Request
  91. */
  92. #if USB_CONFIGURE_EVENT
  93. void USB_Configure_Event (void) {
  94. if (USB_Configuration) { /* Check if USB is configured */
  95. /* add your code here */
  96. }
  97. }
  98. #endif
  99. /*
  100. * USB Set Interface Event Callback
  101. * Called automatically on USB Set Interface Request
  102. */
  103. #if USB_INTERFACE_EVENT
  104. void USB_Interface_Event (void) {
  105. }
  106. #endif
  107. /*
  108. * USB Set/Clear Feature Event Callback
  109. * Called automatically on USB Set/Clear Feature Request
  110. */
  111. #if USB_FEATURE_EVENT
  112. void USB_Feature_Event (void) {
  113. }
  114. #endif
  115. #define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : nullptr)
  116. /* USB Endpoint Events Callback Pointers */
  117. void (* const USB_P_EP[16]) (uint32_t event) = {
  118. P_EP(0),
  119. P_EP(1),
  120. P_EP(2),
  121. P_EP(3),
  122. P_EP(4),
  123. P_EP(5),
  124. P_EP(6),
  125. P_EP(7),
  126. P_EP(8),
  127. P_EP(9),
  128. P_EP(10),
  129. P_EP(11),
  130. P_EP(12),
  131. P_EP(13),
  132. P_EP(14),
  133. P_EP(15),
  134. };
  135. /*
  136. * USB Endpoint 1 Event Callback
  137. * Called automatically on USB Endpoint 1 Event
  138. * Parameter: event
  139. */
  140. void USB_EndPoint1 (uint32_t event) {
  141. uint16_t temp;
  142. static uint16_t serialState;
  143. switch (event) {
  144. case USB_EVT_IN:
  145. temp = CDC_GetSerialState();
  146. if (serialState != temp) {
  147. serialState = temp;
  148. CDC_NotificationIn(); /* send SERIAL_STATE notification */
  149. }
  150. break;
  151. default:
  152. _DBG("Unhandled EP1 event: ");
  153. _DBH(event);
  154. _DBG("\n");
  155. }
  156. }
  157. /*
  158. * USB Endpoint 2 Event Callback
  159. * Called automatically on USB Endpoint 2 Event
  160. * Parameter: event
  161. */
  162. void USB_EndPoint2 (uint32_t event) {
  163. switch (event) {
  164. case USB_EVT_OUT:
  165. CDC_BulkOut (); /* data received from Host */
  166. break;
  167. case USB_EVT_IN:
  168. CDC_BulkIn (); /* data expected from Host */
  169. break;
  170. }
  171. }
  172. /*
  173. * USB Endpoint 3 Event Callback
  174. * Called automatically on USB Endpoint 3 Event
  175. * Parameter: event
  176. */
  177. void USB_EndPoint3 (uint32_t event) {
  178. }
  179. /*
  180. * USB Endpoint 4 Event Callback
  181. * Called automatically on USB Endpoint 4 Event
  182. * Parameter: event
  183. */
  184. void USB_EndPoint4 (uint32_t event) {
  185. }
  186. /*
  187. * USB Endpoint 5 Event Callback
  188. * Called automatically on USB Endpoint 5 Event
  189. * Parameter: event
  190. */
  191. void USB_EndPoint5 (uint32_t event) {
  192. switch (event) {
  193. case USB_EVT_OUT:
  194. MSC_BulkOut();
  195. break;
  196. case USB_EVT_IN:
  197. MSC_BulkIn();
  198. break;
  199. }
  200. }
  201. /*
  202. * USB Endpoint 6 Event Callback
  203. * Called automatically on USB Endpoint 6 Event
  204. * Parameter: event
  205. */
  206. void USB_EndPoint6 (uint32_t event) {
  207. }
  208. /*
  209. * USB Endpoint 7 Event Callback
  210. * Called automatically on USB Endpoint 7 Event
  211. * Parameter: event
  212. */
  213. void USB_EndPoint7 (uint32_t event) {
  214. }
  215. /*
  216. * USB Endpoint 8 Event Callback
  217. * Called automatically on USB Endpoint 8 Event
  218. * Parameter: event
  219. */
  220. void USB_EndPoint8 (uint32_t event) {
  221. }
  222. /*
  223. * USB Endpoint 9 Event Callback
  224. * Called automatically on USB Endpoint 9 Event
  225. * Parameter: event
  226. */
  227. void USB_EndPoint9 (uint32_t event) {
  228. }
  229. /*
  230. * USB Endpoint 10 Event Callback
  231. * Called automatically on USB Endpoint 10 Event
  232. * Parameter: event
  233. */
  234. void USB_EndPoint10 (uint32_t event) {
  235. }
  236. /*
  237. * USB Endpoint 11 Event Callback
  238. * Called automatically on USB Endpoint 11 Event
  239. * Parameter: event
  240. */
  241. void USB_EndPoint11 (uint32_t event) {
  242. }
  243. /*
  244. * USB Endpoint 12 Event Callback
  245. * Called automatically on USB Endpoint 12 Event
  246. * Parameter: event
  247. */
  248. void USB_EndPoint12 (uint32_t event) {
  249. }
  250. /*
  251. * USB Endpoint 13 Event Callback
  252. * Called automatically on USB Endpoint 13 Event
  253. * Parameter: event
  254. */
  255. void USB_EndPoint13 (uint32_t event) {
  256. }
  257. /*
  258. * USB Endpoint 14 Event Callback
  259. * Called automatically on USB Endpoint 14 Event
  260. * Parameter: event
  261. */
  262. void USB_EndPoint14 (uint32_t event) {
  263. }
  264. /*
  265. * USB Endpoint 15 Event Callback
  266. * Called automatically on USB Endpoint 15 Event
  267. * Parameter: event
  268. */
  269. void USB_EndPoint15 (uint32_t event) {
  270. }