logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

usb_main.c (20352B)


  1. // Copyright 2023 Stefan Kerkmann
  2. // Copyright 2020-2021 Ryan (@fauxpark)
  3. // Copyright 2020 Nick Brassel (@tzarc)
  4. // Copyright 2020 a-chol
  5. // Copyright 2020 xyzz
  6. // Copyright 2020 Joel Challis (@zvecr)
  7. // Copyright 2020 George (@goshdarnharris)
  8. // Copyright 2018 James Laird-Wah
  9. // Copyright 2018 Drashna Jaelre (@drashna)
  10. // Copyright 2016 Fredizzimo
  11. // Copyright 2016 Giovanni Di Sirio
  12. // SPDX-License-Identifier: GPL-3.0-or-later OR Apache-2.0
  13. #include <ch.h>
  14. #include <hal.h>
  15. #include <string.h>
  16. #include "usb_main.h"
  17. #include "usb_report_handling.h"
  18. #include "host.h"
  19. #include "suspend.h"
  20. #include "timer.h"
  21. #ifdef SLEEP_LED_ENABLE
  22. # include "sleep_led.h"
  23. # include "led.h"
  24. #endif
  25. #include "wait.h"
  26. #include "usb_endpoints.h"
  27. #include "usb_device_state.h"
  28. #include "usb_descriptor.h"
  29. #include "usb_driver.h"
  30. #include "usb_types.h"
  31. #ifdef RAW_ENABLE
  32. # include "raw_hid.h"
  33. #endif
  34. #ifdef NKRO_ENABLE
  35. # include "keycode_config.h"
  36. extern keymap_config_t keymap_config;
  37. #endif
  38. /* ---------------------------------------------------------
  39. * Global interface variables and declarations
  40. * ---------------------------------------------------------
  41. */
  42. #ifndef usb_lld_connect_bus
  43. # define usb_lld_connect_bus(usbp)
  44. #endif
  45. #ifndef usb_lld_disconnect_bus
  46. # define usb_lld_disconnect_bus(usbp)
  47. #endif
  48. extern usb_endpoint_in_t usb_endpoints_in[USB_ENDPOINT_IN_COUNT];
  49. extern usb_endpoint_out_t usb_endpoints_out[USB_ENDPOINT_OUT_COUNT];
  50. static bool __attribute__((__unused__)) send_report_buffered(usb_endpoint_in_lut_t endpoint, void *report, size_t size);
  51. static void __attribute__((__unused__)) flush_report_buffered(usb_endpoint_in_lut_t endpoint, bool padded);
  52. static bool __attribute__((__unused__)) receive_report(usb_endpoint_out_lut_t endpoint, void *report, size_t size);
  53. /* ---------------------------------------------------------
  54. * Descriptors and USB driver objects
  55. * ---------------------------------------------------------
  56. */
  57. /* USB Low Level driver specific endpoint fields */
  58. #if !defined(usb_lld_endpoint_fields)
  59. # define usb_lld_endpoint_fields \
  60. 2, /* IN multiplier */ \
  61. NULL, /* SETUP buffer (not a SETUP endpoint) */
  62. #endif
  63. /*
  64. * Handles the GET_DESCRIPTOR callback
  65. *
  66. * Returns the proper descriptor
  67. */
  68. static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype, uint8_t dindex, uint16_t wIndex) {
  69. usb_control_request_t *setup = (usb_control_request_t *)usbp->setup;
  70. static USBDescriptor descriptor;
  71. descriptor.ud_string = NULL;
  72. descriptor.ud_size = get_usb_descriptor(setup->wValue.word, setup->wIndex, setup->wLength, (const void **const) & descriptor.ud_string);
  73. if (descriptor.ud_string == NULL) {
  74. return NULL;
  75. }
  76. return &descriptor;
  77. }
  78. /* ---------------------------------------------------------
  79. * USB driver functions
  80. * ---------------------------------------------------------
  81. */
  82. #define USB_EVENT_QUEUE_SIZE 16
  83. usbevent_t event_queue[USB_EVENT_QUEUE_SIZE];
  84. uint8_t event_queue_head;
  85. uint8_t event_queue_tail;
  86. void usb_event_queue_init(void) {
  87. // Initialise the event queue
  88. memset(&event_queue, 0, sizeof(event_queue));
  89. event_queue_head = 0;
  90. event_queue_tail = 0;
  91. }
  92. static inline bool usb_event_queue_enqueue(usbevent_t event) {
  93. uint8_t next = (event_queue_head + 1) % USB_EVENT_QUEUE_SIZE;
  94. if (next == event_queue_tail) {
  95. return false;
  96. }
  97. event_queue[event_queue_head] = event;
  98. event_queue_head = next;
  99. return true;
  100. }
  101. static inline bool usb_event_queue_dequeue(usbevent_t *event) {
  102. if (event_queue_head == event_queue_tail) {
  103. return false;
  104. }
  105. *event = event_queue[event_queue_tail];
  106. event_queue_tail = (event_queue_tail + 1) % USB_EVENT_QUEUE_SIZE;
  107. return true;
  108. }
  109. static inline void usb_event_suspend_handler(void) {
  110. usb_device_state_set_suspend(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
  111. #ifdef SLEEP_LED_ENABLE
  112. sleep_led_enable();
  113. #endif /* SLEEP_LED_ENABLE */
  114. }
  115. static inline void usb_event_wakeup_handler(void) {
  116. suspend_wakeup_init();
  117. usb_device_state_set_resume(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
  118. #ifdef SLEEP_LED_ENABLE
  119. sleep_led_disable();
  120. // NOTE: converters may not accept this
  121. led_set(host_keyboard_leds());
  122. #endif /* SLEEP_LED_ENABLE */
  123. }
  124. bool last_suspend_state = false;
  125. void usb_event_queue_task(void) {
  126. usbevent_t event;
  127. while (usb_event_queue_dequeue(&event)) {
  128. switch (event) {
  129. case USB_EVENT_SUSPEND:
  130. last_suspend_state = true;
  131. usb_event_suspend_handler();
  132. break;
  133. case USB_EVENT_WAKEUP:
  134. last_suspend_state = false;
  135. usb_event_wakeup_handler();
  136. break;
  137. case USB_EVENT_CONFIGURED:
  138. usb_device_state_set_configuration(USB_DRIVER.configuration != 0, USB_DRIVER.configuration);
  139. break;
  140. case USB_EVENT_UNCONFIGURED:
  141. usb_device_state_set_configuration(false, 0);
  142. break;
  143. case USB_EVENT_RESET:
  144. usb_device_state_set_reset();
  145. usb_device_state_set_protocol(USB_PROTOCOL_REPORT);
  146. break;
  147. default:
  148. // Nothing to do, we don't handle it.
  149. break;
  150. }
  151. }
  152. }
  153. /* Handles the USB driver global events. */
  154. static void usb_event_cb(USBDriver *usbp, usbevent_t event) {
  155. switch (event) {
  156. case USB_EVENT_ADDRESS:
  157. return;
  158. case USB_EVENT_CONFIGURED:
  159. osalSysLockFromISR();
  160. for (int i = 0; i < USB_ENDPOINT_IN_COUNT; i++) {
  161. usb_endpoint_in_configure_cb(&usb_endpoints_in[i]);
  162. }
  163. for (int i = 0; i < USB_ENDPOINT_OUT_COUNT; i++) {
  164. usb_endpoint_out_configure_cb(&usb_endpoints_out[i]);
  165. }
  166. osalSysUnlockFromISR();
  167. if (last_suspend_state) {
  168. usb_event_queue_enqueue(USB_EVENT_WAKEUP);
  169. }
  170. usb_event_queue_enqueue(USB_EVENT_CONFIGURED);
  171. return;
  172. case USB_EVENT_SUSPEND:
  173. /* Falls into.*/
  174. case USB_EVENT_UNCONFIGURED:
  175. /* Falls into.*/
  176. case USB_EVENT_RESET:
  177. usb_event_queue_enqueue(event);
  178. chSysLockFromISR();
  179. for (int i = 0; i < USB_ENDPOINT_IN_COUNT; i++) {
  180. usb_endpoint_in_suspend_cb(&usb_endpoints_in[i]);
  181. }
  182. for (int i = 0; i < USB_ENDPOINT_OUT_COUNT; i++) {
  183. usb_endpoint_out_suspend_cb(&usb_endpoints_out[i]);
  184. }
  185. chSysUnlockFromISR();
  186. return;
  187. case USB_EVENT_WAKEUP:
  188. chSysLockFromISR();
  189. for (int i = 0; i < USB_ENDPOINT_IN_COUNT; i++) {
  190. usb_endpoint_in_wakeup_cb(&usb_endpoints_in[i]);
  191. }
  192. for (int i = 0; i < USB_ENDPOINT_OUT_COUNT; i++) {
  193. usb_endpoint_out_wakeup_cb(&usb_endpoints_out[i]);
  194. }
  195. chSysUnlockFromISR();
  196. usb_event_queue_enqueue(USB_EVENT_WAKEUP);
  197. return;
  198. case USB_EVENT_STALLED:
  199. return;
  200. }
  201. }
  202. /*
  203. * Appendix G: HID Request Support Requirements
  204. *
  205. * The following table enumerates the requests that need to be supported by various types of HID class devices.
  206. * Device type GetReport SetReport GetIdle SetIdle GetProtocol SetProtocol
  207. * ------------------------------------------------------------------------------------------
  208. * Boot Mouse Required Optional Optional Optional Required Required
  209. * Non-Boot Mouse Required Optional Optional Optional Optional Optional
  210. * Boot Keyboard Required Optional Required Required Required Required
  211. * Non-Boot Keybrd Required Optional Required Required Optional Optional
  212. * Other Device Required Optional Optional Optional Optional Optional
  213. */
  214. static uint8_t _Alignas(4) set_report_buf[2];
  215. static void set_led_transfer_cb(USBDriver *usbp) {
  216. usb_control_request_t *setup = (usb_control_request_t *)usbp->setup;
  217. if (setup->wLength == 2) {
  218. uint8_t report_id = set_report_buf[0];
  219. if ((report_id == REPORT_ID_KEYBOARD) || (report_id == REPORT_ID_NKRO)) {
  220. usb_device_state_set_leds(set_report_buf[1]);
  221. }
  222. } else {
  223. usb_device_state_set_leds(set_report_buf[0]);
  224. }
  225. }
  226. static bool usb_requests_hook_cb(USBDriver *usbp) {
  227. usb_control_request_t *setup = (usb_control_request_t *)usbp->setup;
  228. /* Handle HID class specific requests */
  229. if ((setup->bmRequestType & (USB_RTYPE_TYPE_MASK | USB_RTYPE_RECIPIENT_MASK)) == (USB_RTYPE_TYPE_CLASS | USB_RTYPE_RECIPIENT_INTERFACE)) {
  230. switch (setup->bmRequestType & USB_RTYPE_DIR_MASK) {
  231. case USB_RTYPE_DIR_DEV2HOST:
  232. switch (setup->bRequest) {
  233. case HID_REQ_GetReport:
  234. return usb_get_report_cb(usbp);
  235. case HID_REQ_GetProtocol:
  236. if (setup->wIndex == KEYBOARD_INTERFACE) {
  237. static uint8_t keyboard_protocol;
  238. keyboard_protocol = usb_device_state_get_protocol();
  239. usbSetupTransfer(usbp, &keyboard_protocol, sizeof(keyboard_protocol), NULL);
  240. return true;
  241. }
  242. break;
  243. case HID_REQ_GetIdle:
  244. return usb_get_idle_cb(usbp);
  245. }
  246. case USB_RTYPE_DIR_HOST2DEV:
  247. switch (setup->bRequest) {
  248. case HID_REQ_SetReport:
  249. switch (setup->wIndex) {
  250. case KEYBOARD_INTERFACE:
  251. #if defined(SHARED_EP_ENABLE) && !defined(KEYBOARD_SHARED_EP)
  252. case SHARED_INTERFACE:
  253. #endif
  254. usbSetupTransfer(usbp, set_report_buf, sizeof(set_report_buf), set_led_transfer_cb);
  255. return true;
  256. }
  257. break;
  258. case HID_REQ_SetProtocol:
  259. if (setup->wIndex == KEYBOARD_INTERFACE) {
  260. usb_device_state_set_protocol(setup->wValue.lbyte);
  261. }
  262. usbSetupTransfer(usbp, NULL, 0, NULL);
  263. return true;
  264. case HID_REQ_SetIdle:
  265. usb_device_state_set_idle_rate(setup->wValue.hbyte);
  266. return usb_set_idle_cb(usbp);
  267. }
  268. break;
  269. }
  270. }
  271. /* Handle the Get_Descriptor Request for HID class, which is not handled by
  272. * the ChibiOS USB driver */
  273. if (((setup->bmRequestType & (USB_RTYPE_DIR_MASK | USB_RTYPE_RECIPIENT_MASK)) == (USB_RTYPE_DIR_DEV2HOST | USB_RTYPE_RECIPIENT_INTERFACE)) && (setup->bRequest == USB_REQ_GET_DESCRIPTOR)) {
  274. const USBDescriptor *descriptor = usbp->config->get_descriptor_cb(usbp, setup->wValue.lbyte, setup->wValue.hbyte, setup->wIndex);
  275. if (descriptor == NULL) {
  276. return false;
  277. }
  278. usbSetupTransfer(usbp, (uint8_t *)descriptor->ud_string, descriptor->ud_size, NULL);
  279. return true;
  280. }
  281. for (int i = 0; i < USB_ENDPOINT_IN_COUNT; i++) {
  282. if (usb_endpoints_in[i].usb_requests_cb != NULL) {
  283. if (usb_endpoints_in[i].usb_requests_cb(usbp)) {
  284. return true;
  285. }
  286. }
  287. }
  288. return false;
  289. }
  290. static const USBConfig usbcfg = {
  291. usb_event_cb, /* USB events callback */
  292. usb_get_descriptor_cb, /* Device GET_DESCRIPTOR request callback */
  293. usb_requests_hook_cb, /* Requests hook callback */
  294. };
  295. void init_usb_driver(USBDriver *usbp) {
  296. for (int i = 0; i < USB_ENDPOINT_IN_COUNT; i++) {
  297. usb_endpoint_in_init(&usb_endpoints_in[i]);
  298. usb_endpoint_in_start(&usb_endpoints_in[i]);
  299. }
  300. for (int i = 0; i < USB_ENDPOINT_OUT_COUNT; i++) {
  301. usb_endpoint_out_init(&usb_endpoints_out[i]);
  302. usb_endpoint_out_start(&usb_endpoints_out[i]);
  303. }
  304. /*
  305. * Activates the USB driver and then the USB bus pull-up on D+.
  306. * Note, a delay is inserted in order to not have to disconnect the cable
  307. * after a reset.
  308. */
  309. usbDisconnectBus(usbp);
  310. usbStop(usbp);
  311. wait_ms(50);
  312. usbStart(usbp, &usbcfg);
  313. usbConnectBus(usbp);
  314. }
  315. __attribute__((weak)) void restart_usb_driver(USBDriver *usbp) {
  316. usbDisconnectBus(usbp);
  317. usbStop(usbp);
  318. for (int i = 0; i < USB_ENDPOINT_IN_COUNT; i++) {
  319. usb_endpoint_in_stop(&usb_endpoints_in[i]);
  320. }
  321. for (int i = 0; i < USB_ENDPOINT_OUT_COUNT; i++) {
  322. usb_endpoint_out_stop(&usb_endpoints_out[i]);
  323. }
  324. wait_ms(50);
  325. for (int i = 0; i < USB_ENDPOINT_IN_COUNT; i++) {
  326. usb_endpoint_in_init(&usb_endpoints_in[i]);
  327. usb_endpoint_in_start(&usb_endpoints_in[i]);
  328. }
  329. for (int i = 0; i < USB_ENDPOINT_OUT_COUNT; i++) {
  330. usb_endpoint_out_init(&usb_endpoints_out[i]);
  331. usb_endpoint_out_start(&usb_endpoints_out[i]);
  332. }
  333. usbStart(usbp, &usbcfg);
  334. usbConnectBus(usbp);
  335. }
  336. /* ---------------------------------------------------------
  337. * Keyboard functions
  338. * ---------------------------------------------------------
  339. */
  340. /**
  341. * @brief Send a report to the host, the report is enqueued into an output
  342. * queue and send once the USB endpoint becomes empty.
  343. *
  344. * @param endpoint USB IN endpoint to send the report from
  345. * @param report pointer to the report
  346. * @param size size of the report
  347. * @return true Success
  348. * @return false Failure
  349. */
  350. bool send_report(usb_endpoint_in_lut_t endpoint, void *report, size_t size) {
  351. return usb_endpoint_in_send(&usb_endpoints_in[endpoint], (uint8_t *)report, size, TIME_MS2I(100), false);
  352. }
  353. /**
  354. * @brief Send a report to the host, but delay the sending until the size of
  355. * endpoint report is reached or the incompletely filled buffer is flushed with
  356. * a call to `flush_report_buffered`. This is useful if the report is being
  357. * updated frequently. The complete report is then enqueued into an output
  358. * queue and send once the USB endpoint becomes empty.
  359. *
  360. * @param endpoint USB IN endpoint to send the report from
  361. * @param report pointer to the report
  362. * @param size size of the report
  363. * @return true Success
  364. * @return false Failure
  365. */
  366. static bool send_report_buffered(usb_endpoint_in_lut_t endpoint, void *report, size_t size) {
  367. return usb_endpoint_in_send(&usb_endpoints_in[endpoint], (uint8_t *)report, size, TIME_MS2I(100), true);
  368. }
  369. /** @brief Flush all buffered reports which were enqueued with a call to
  370. * `send_report_buffered` that haven't been send. If necessary the buffered
  371. * report can be padded with zeros up to the endpoints maximum size.
  372. *
  373. * @param endpoint USB IN endpoint to flush the reports from
  374. * @param padded Pad the buffered report with zeros up to the endpoints maximum size
  375. */
  376. static void flush_report_buffered(usb_endpoint_in_lut_t endpoint, bool padded) {
  377. usb_endpoint_in_flush(&usb_endpoints_in[endpoint], padded);
  378. }
  379. /**
  380. * @brief Receive a report from the host.
  381. *
  382. * @param endpoint USB OUT endpoint to receive the report from
  383. * @param report pointer to the report
  384. * @param size size of the report
  385. * @return true Success
  386. * @return false Failure
  387. */
  388. static bool receive_report(usb_endpoint_out_lut_t endpoint, void *report, size_t size) {
  389. return usb_endpoint_out_receive(&usb_endpoints_out[endpoint], (uint8_t *)report, size, TIME_IMMEDIATE);
  390. }
  391. void send_keyboard(report_keyboard_t *report) {
  392. /* If we're in Boot Protocol, don't send any report ID or other funky fields */
  393. if (usb_device_state_get_protocol() == USB_PROTOCOL_BOOT) {
  394. send_report(USB_ENDPOINT_IN_KEYBOARD, &report->mods, 8);
  395. } else {
  396. send_report(USB_ENDPOINT_IN_KEYBOARD, report, KEYBOARD_REPORT_SIZE);
  397. }
  398. }
  399. void send_nkro(report_nkro_t *report) {
  400. #ifdef NKRO_ENABLE
  401. send_report(USB_ENDPOINT_IN_SHARED, report, sizeof(report_nkro_t));
  402. #endif
  403. }
  404. /* ---------------------------------------------------------
  405. * Mouse functions
  406. * ---------------------------------------------------------
  407. */
  408. void send_mouse(report_mouse_t *report) {
  409. #ifdef MOUSE_ENABLE
  410. send_report(USB_ENDPOINT_IN_MOUSE, report, sizeof(report_mouse_t));
  411. #endif
  412. }
  413. /* ---------------------------------------------------------
  414. * Extrakey functions
  415. * ---------------------------------------------------------
  416. */
  417. void send_extra(report_extra_t *report) {
  418. #ifdef EXTRAKEY_ENABLE
  419. send_report(USB_ENDPOINT_IN_SHARED, report, sizeof(report_extra_t));
  420. #endif
  421. }
  422. void send_programmable_button(report_programmable_button_t *report) {
  423. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  424. send_report(USB_ENDPOINT_IN_SHARED, report, sizeof(report_programmable_button_t));
  425. #endif
  426. }
  427. void send_joystick(report_joystick_t *report) {
  428. #ifdef JOYSTICK_ENABLE
  429. send_report(USB_ENDPOINT_IN_JOYSTICK, report, sizeof(report_joystick_t));
  430. #endif
  431. }
  432. void send_digitizer(report_digitizer_t *report) {
  433. #ifdef DIGITIZER_ENABLE
  434. send_report(USB_ENDPOINT_IN_DIGITIZER, report, sizeof(report_digitizer_t));
  435. #endif
  436. }
  437. /* ---------------------------------------------------------
  438. * Console functions
  439. * ---------------------------------------------------------
  440. */
  441. #ifdef CONSOLE_ENABLE
  442. int8_t sendchar(uint8_t c) {
  443. return (int8_t)send_report_buffered(USB_ENDPOINT_IN_CONSOLE, &c, sizeof(uint8_t));
  444. }
  445. void console_task(void) {
  446. flush_report_buffered(USB_ENDPOINT_IN_CONSOLE, true);
  447. }
  448. #endif /* CONSOLE_ENABLE */
  449. #ifdef RAW_ENABLE
  450. void send_raw_hid(uint8_t *data, uint8_t length) {
  451. if (length != RAW_EPSIZE) {
  452. return;
  453. }
  454. send_report(USB_ENDPOINT_IN_RAW, data, length);
  455. }
  456. void raw_hid_task(void) {
  457. uint8_t buffer[RAW_EPSIZE];
  458. while (receive_report(USB_ENDPOINT_OUT_RAW, buffer, sizeof(buffer))) {
  459. raw_hid_receive(buffer, sizeof(buffer));
  460. }
  461. }
  462. #endif
  463. #ifdef MIDI_ENABLE
  464. void send_midi_packet(MIDI_EventPacket_t *event) {
  465. send_report(USB_ENDPOINT_IN_MIDI, (uint8_t *)event, sizeof(MIDI_EventPacket_t));
  466. }
  467. bool recv_midi_packet(MIDI_EventPacket_t *const event) {
  468. return receive_report(USB_ENDPOINT_OUT_MIDI, (uint8_t *)event, sizeof(MIDI_EventPacket_t));
  469. }
  470. #endif
  471. #ifdef VIRTSER_ENABLE
  472. # include "hal_usb_cdc.h"
  473. /**
  474. * @brief CDC serial driver configuration structure. Set to 9600 baud, 1 stop bit, no parity, 8 data bits.
  475. */
  476. static cdc_linecoding_t linecoding = {{0x00, 0x96, 0x00, 0x00}, LC_STOP_1, LC_PARITY_NONE, 8};
  477. bool virtser_usb_request_cb(USBDriver *usbp) {
  478. if ((usbp->setup[0] & USB_RTYPE_TYPE_MASK) == USB_RTYPE_TYPE_CLASS) { /* bmRequestType */
  479. if (usbp->setup[4] == CCI_INTERFACE) { /* wIndex (LSB) */
  480. switch (usbp->setup[1]) { /* bRequest */
  481. case CDC_GET_LINE_CODING:
  482. usbSetupTransfer(usbp, (uint8_t *)&linecoding, sizeof(linecoding), NULL);
  483. return true;
  484. case CDC_SET_LINE_CODING:
  485. usbSetupTransfer(usbp, (uint8_t *)&linecoding, sizeof(linecoding), NULL);
  486. return true;
  487. case CDC_SET_CONTROL_LINE_STATE:
  488. /* Nothing to do, there are no control lines.*/
  489. usbSetupTransfer(usbp, NULL, 0, NULL);
  490. return true;
  491. default:
  492. return false;
  493. }
  494. }
  495. }
  496. return false;
  497. }
  498. void virtser_init(void) {}
  499. void virtser_send(const uint8_t byte) {
  500. send_report_buffered(USB_ENDPOINT_IN_CDC_DATA, (void *)&byte, sizeof(byte));
  501. }
  502. __attribute__((weak)) void virtser_recv(uint8_t c) {
  503. // Ignore by default
  504. }
  505. void virtser_task(void) {
  506. uint8_t buffer[CDC_EPSIZE];
  507. while (receive_report(USB_ENDPOINT_OUT_CDC_DATA, buffer, sizeof(buffer))) {
  508. for (int i = 0; i < sizeof(buffer); i++) {
  509. virtser_recv(buffer[i]);
  510. }
  511. }
  512. flush_report_buffered(USB_ENDPOINT_IN_CDC_DATA, false);
  513. }
  514. #endif