usb_main.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. #ifndef _USB_MAIN_H_
  18. #define _USB_MAIN_H_
  19. // TESTING
  20. // extern uint8_t blinkLed;
  21. #include "ch.h"
  22. #include "hal.h"
  23. /* -------------------------
  24. * General USB driver header
  25. * -------------------------
  26. */
  27. /* The USB driver to use */
  28. #define USB_DRIVER USBD1
  29. /* Initialize the USB driver and bus */
  30. void init_usb_driver(USBDriver *usbp);
  31. /* ---------------
  32. * Keyboard header
  33. * ---------------
  34. */
  35. /* extern report_keyboard_t keyboard_report_sent; */
  36. /* keyboard IN request callback handler */
  37. void kbd_in_cb(USBDriver *usbp, usbep_t ep);
  38. /* start-of-frame handler */
  39. void kbd_sof_cb(USBDriver *usbp);
  40. #ifdef NKRO_ENABLE
  41. /* nkro IN callback hander */
  42. void nkro_in_cb(USBDriver *usbp, usbep_t ep);
  43. #endif /* NKRO_ENABLE */
  44. /* ------------
  45. * Mouse header
  46. * ------------
  47. */
  48. #ifdef MOUSE_ENABLE
  49. /* mouse IN request callback handler */
  50. void mouse_in_cb(USBDriver *usbp, usbep_t ep);
  51. #endif /* MOUSE_ENABLE */
  52. /* ---------------
  53. * Extrakey header
  54. * ---------------
  55. */
  56. #ifdef EXTRAKEY_ENABLE
  57. /* extrakey IN request callback handler */
  58. void extra_in_cb(USBDriver *usbp, usbep_t ep);
  59. /* extra report structure */
  60. typedef struct {
  61. uint8_t report_id;
  62. uint16_t usage;
  63. } __attribute__ ((packed)) report_extra_t;
  64. #endif /* EXTRAKEY_ENABLE */
  65. /* --------------
  66. * Console header
  67. * --------------
  68. */
  69. #ifdef CONSOLE_ENABLE
  70. /* Putchar over the USB console */
  71. int8_t sendchar(uint8_t c);
  72. /* Flush output (send everything immediately) */
  73. void console_flush_output(void);
  74. #endif /* CONSOLE_ENABLE */
  75. void sendchar_pf(void *p, char c);
  76. #endif /* _USB_MAIN_H_ */