2 * (c) 2015 flabberast <s3+flabbergast@sdfeu.org>
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
14 * Since some GPL'd code is used, this work is licensed under
25 /* -------------------------
26 * General USB driver header
27 * -------------------------
30 /* The USB driver to use */
31 #define USB_DRIVER USBD1
33 /* Initialize the USB driver and bus */
34 void init_usb_driver(USBDriver *usbp);
41 /* main keyboard (6kro) */
42 #define KBD_INTERFACE 0
43 #define KBD_ENDPOINT 1
45 #define KBD_REPORT_KEYS (KBD_SIZE - 2)
47 /* secondary keyboard */
49 #define NKRO_INTERFACE 4
50 #define NKRO_ENDPOINT 5
52 #define NKRO_REPORT_KEYS (NKRO_SIZE - 1)
55 /* this defines report_keyboard_t and computes REPORT_SIZE defines */
58 /* extern report_keyboard_t keyboard_report_sent; */
60 /* keyboard IN request callback handler */
61 void kbd_in_cb(USBDriver *usbp, usbep_t ep);
63 /* start-of-frame handler */
64 void kbd_sof_cb(USBDriver *usbp);
67 /* nkro IN callback hander */
68 void nkro_in_cb(USBDriver *usbp, usbep_t ep);
69 #endif /* NKRO_ENABLE */
78 #define MOUSE_INTERFACE 1
79 #define MOUSE_ENDPOINT 2
82 /* mouse IN request callback handler */
83 void mouse_in_cb(USBDriver *usbp, usbep_t ep);
84 #endif /* MOUSE_ENABLE */
91 #ifdef EXTRAKEY_ENABLE
93 #define EXTRA_INTERFACE 3
94 #define EXTRA_ENDPOINT 4
97 /* extrakey IN request callback handler */
98 void extra_in_cb(USBDriver *usbp, usbep_t ep);
100 /* extra report structure */
104 } __attribute__ ((packed)) report_extra_t;
105 #endif /* EXTRAKEY_ENABLE */
112 #ifdef CONSOLE_ENABLE
114 #define CONSOLE_INTERFACE 2
115 #define CONSOLE_ENDPOINT 3
116 #define CONSOLE_SIZE 16
118 /* Number of IN reports that can be stored inside the output queue */
119 #define CONSOLE_QUEUE_CAPACITY 2
120 #define CONSOLE_QUEUE_BUFFER_SIZE (CONSOLE_QUEUE_CAPACITY * CONSOLE_SIZE)
122 /* Console flush time */
123 #define CONSOLE_FLUSH_MS 50
125 /* Putchar over the USB console */
126 int8_t sendchar(uint8_t c);
127 /* wrapper for printf lib */
129 /* Flush output (send everything immediately) */
130 void console_flush_output(void);
132 /* console IN request callback handler */
133 void console_in_cb(USBDriver *usbp, usbep_t ep);
134 #endif /* CONSOLE_ENABLE */
136 void sendchar_pf(void *p, char c);
138 /* ---------------------------
139 * Host driver functions (TMK)
140 * ---------------------------
143 uint8_t keyboard_leds(void);
144 void send_keyboard(report_keyboard_t *report);
145 void send_mouse(report_mouse_t *report);
146 void send_system(uint16_t data);
147 void send_consumer(uint16_t data);
149 #endif /* _USB_MAIN_H_ */