usb_main.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * (c) 2015 flabberast <s3+flabbergast@sdfeu.org>
  3. *
  4. * Based on the following work:
  5. * - Guillaume Duc's raw hid example (MIT License)
  6. * https://github.com/guiduc/usb-hid-chibios-example
  7. * - PJRC Teensy examples (MIT License)
  8. * https://www.pjrc.com/teensy/usb_keyboard.html
  9. * - hasu's TMK keyboard code (GPL v2 and some code Modified BSD)
  10. * https://github.com/tmk/tmk_keyboard/
  11. * - ChibiOS demo code (Apache 2.0 License)
  12. * http://www.chibios.org
  13. *
  14. * Since some GPL'd code is used, this work is licensed under
  15. * GPL v2 or later.
  16. */
  17. #pragma once
  18. #include <ch.h>
  19. #include <hal.h>
  20. /* -------------------------
  21. * General USB driver header
  22. * -------------------------
  23. */
  24. /* The USB driver to use */
  25. #ifndef USB_DRIVER
  26. # define USB_DRIVER USBD1
  27. #endif // USB_DRIVER
  28. /* Initialize the USB driver and bus */
  29. void init_usb_driver(USBDriver *usbp);
  30. /* Restart the USB driver and bus */
  31. void restart_usb_driver(USBDriver *usbp);
  32. /* ---------------
  33. * USB Event queue
  34. * ---------------
  35. */
  36. /* Initialisation of the FIFO */
  37. void usb_event_queue_init(void);
  38. /* Task to dequeue and execute any handlers for the USB events on the main thread */
  39. void usb_event_queue_task(void);
  40. /* --------------
  41. * Console header
  42. * --------------
  43. */
  44. #ifdef CONSOLE_ENABLE
  45. /* Putchar over the USB console */
  46. int8_t sendchar(uint8_t c);
  47. /* Flush output (send everything immediately) */
  48. void console_flush_output(void);
  49. #endif /* CONSOLE_ENABLE */