usb_main.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. * Keyboard header
  34. * ---------------
  35. */
  36. /* extern report_keyboard_t keyboard_report_sent; */
  37. /* keyboard IN request callback handler */
  38. void kbd_in_cb(USBDriver *usbp, usbep_t ep);
  39. /* start-of-frame handler */
  40. void kbd_sof_cb(USBDriver *usbp);
  41. #ifdef NKRO_ENABLE
  42. /* nkro IN callback hander */
  43. void nkro_in_cb(USBDriver *usbp, usbep_t ep);
  44. #endif /* NKRO_ENABLE */
  45. /* ------------
  46. * Mouse header
  47. * ------------
  48. */
  49. #ifdef MOUSE_ENABLE
  50. /* mouse IN request callback handler */
  51. void mouse_in_cb(USBDriver *usbp, usbep_t ep);
  52. #endif /* MOUSE_ENABLE */
  53. /* ---------------
  54. * Shared EP header
  55. * ---------------
  56. */
  57. /* shared IN request callback handler */
  58. void shared_in_cb(USBDriver *usbp, usbep_t ep);
  59. /* --------------
  60. * Console header
  61. * --------------
  62. */
  63. #ifdef CONSOLE_ENABLE
  64. /* Putchar over the USB console */
  65. int8_t sendchar(uint8_t c);
  66. /* Flush output (send everything immediately) */
  67. void console_flush_output(void);
  68. #endif /* CONSOLE_ENABLE */