usb_main.h (1430B)
1 // Copyright 2023 Stefan Kerkmann (@KarlK90) 2 // Copyright 2020 Ryan (@fauxpark) 3 // Copyright 2020 Joel Challis (@zvecr) 4 // Copyright 2018 James Laird-Wah 5 // Copyright 2016 Fredizzimo 6 // Copyright 2016 Giovanni Di Sirio 7 // SPDX-License-Identifier: GPL-3.0-or-later OR Apache-2.0 8 9 #pragma once 10 11 #include <ch.h> 12 #include <hal.h> 13 14 #include "usb_device_state.h" 15 #include "usb_descriptor.h" 16 #include "usb_driver.h" 17 #include "usb_endpoints.h" 18 19 /* ------------------------- 20 * General USB driver header 21 * ------------------------- 22 */ 23 24 /* The USB driver to use */ 25 #ifndef USB_DRIVER 26 # define USB_DRIVER USBD1 27 #endif // USB_DRIVER 28 29 /* Initialize the USB driver and bus */ 30 void init_usb_driver(USBDriver *usbp); 31 32 /* Restart the USB driver and bus */ 33 void restart_usb_driver(USBDriver *usbp); 34 35 bool send_report(usb_endpoint_in_lut_t endpoint, void *report, size_t size); 36 37 /* --------------- 38 * USB Event queue 39 * --------------- 40 */ 41 42 /* Initialisation of the FIFO */ 43 void usb_event_queue_init(void); 44 45 /* Task to dequeue and execute any handlers for the USB events on the main thread */ 46 void usb_event_queue_task(void); 47 48 /* -------------- 49 * Console header 50 * -------------- 51 */ 52 53 #ifdef CONSOLE_ENABLE 54 55 /* Putchar over the USB console */ 56 int8_t sendchar(uint8_t c); 57 58 #endif /* CONSOLE_ENABLE */ 59 60 /* -------------- 61 * Virtser header 62 * -------------- 63 */ 64 65 #if defined(VIRTSER_ENABLE) 66 67 bool virtser_usb_request_cb(USBDriver *usbp); 68 69 #endif