usb_main.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #define USB_DRIVER USBD1
  26. /* Initialize the USB driver and bus */
  27. void init_usb_driver(USBDriver *usbp);
  28. /* Restart the USB driver and bus */
  29. void restart_usb_driver(USBDriver *usbp);
  30. /* ---------------
  31. * USB Event queue
  32. * ---------------
  33. */
  34. /* Initialisation of the FIFO */
  35. void usb_event_queue_init(void);
  36. /* Task to dequeue and execute any handlers for the USB events on the main thread */
  37. void usb_event_queue_task(void);
  38. /* --------------
  39. * Console header
  40. * --------------
  41. */
  42. #ifdef CONSOLE_ENABLE
  43. /* Putchar over the USB console */
  44. int8_t sendchar(uint8_t c);
  45. /* Flush output (send everything immediately) */
  46. void console_flush_output(void);
  47. #endif /* CONSOLE_ENABLE */