usb_main.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. // TESTING
  19. // extern uint8_t blinkLed;
  20. #include <ch.h>
  21. #include <hal.h>
  22. /* -------------------------
  23. * General USB driver header
  24. * -------------------------
  25. */
  26. /* The USB driver to use */
  27. #define USB_DRIVER USBD1
  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. * Keyboard header
  42. * ---------------
  43. */
  44. /* extern report_keyboard_t keyboard_report_sent; */
  45. /* keyboard IN request callback handler */
  46. void kbd_in_cb(USBDriver *usbp, usbep_t ep);
  47. /* start-of-frame handler */
  48. void kbd_sof_cb(USBDriver *usbp);
  49. #ifdef NKRO_ENABLE
  50. /* nkro IN callback hander */
  51. void nkro_in_cb(USBDriver *usbp, usbep_t ep);
  52. #endif /* NKRO_ENABLE */
  53. /* ------------
  54. * Mouse header
  55. * ------------
  56. */
  57. #ifdef MOUSE_ENABLE
  58. /* mouse IN request callback handler */
  59. void mouse_in_cb(USBDriver *usbp, usbep_t ep);
  60. #endif /* MOUSE_ENABLE */
  61. /* ---------------
  62. * Shared EP header
  63. * ---------------
  64. */
  65. /* shared IN request callback handler */
  66. void shared_in_cb(USBDriver *usbp, usbep_t ep);
  67. /* --------------
  68. * Console header
  69. * --------------
  70. */
  71. #ifdef CONSOLE_ENABLE
  72. /* Putchar over the USB console */
  73. int8_t sendchar(uint8_t c);
  74. /* Flush output (send everything immediately) */
  75. void console_flush_output(void);
  76. #endif /* CONSOLE_ENABLE */