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
23 // extern uint8_t blinkLed;
28 /* -------------------------
29 * General USB driver header
30 * -------------------------
33 /* The USB driver to use */
34 #define USB_DRIVER USBD1
36 /* Initialize the USB driver and bus */
37 void init_usb_driver(USBDriver *usbp);
44 /* main keyboard (6kro) */
45 #define KBD_INTERFACE 0
46 #define KBD_ENDPOINT 1
48 #define KBD_REPORT_KEYS (KBD_EPSIZE - 2)
50 /* secondary keyboard */
52 #define NKRO_INTERFACE 4
53 #define NKRO_ENDPOINT 5
54 #define NKRO_EPSIZE 16
55 #define NKRO_REPORT_KEYS (NKRO_EPSIZE - 1)
58 /* this defines report_keyboard_t and computes REPORT_SIZE defines */
59 // #include "report.h"
61 /* extern report_keyboard_t keyboard_report_sent; */
63 /* keyboard IN request callback handler */
64 void kbd_in_cb(USBDriver *usbp, usbep_t ep);
66 /* start-of-frame handler */
67 void kbd_sof_cb(USBDriver *usbp);
70 /* nkro IN callback hander */
71 void nkro_in_cb(USBDriver *usbp, usbep_t ep);
72 #endif /* NKRO_ENABLE */
81 #define MOUSE_INTERFACE 1
82 #define MOUSE_ENDPOINT 2
83 #define MOUSE_EPSIZE 8
85 /* mouse IN request callback handler */
86 void mouse_in_cb(USBDriver *usbp, usbep_t ep);
87 #endif /* MOUSE_ENABLE */
94 #ifdef EXTRAKEY_ENABLE
96 #define EXTRA_INTERFACE 3
97 #define EXTRA_ENDPOINT 4
98 #define EXTRA_EPSIZE 8
100 /* extrakey IN request callback handler */
101 void extra_in_cb(USBDriver *usbp, usbep_t ep);
103 /* extra report structure */
107 } __attribute__ ((packed)) report_extra_t;
108 #endif /* EXTRAKEY_ENABLE */
115 #ifdef CONSOLE_ENABLE
117 #define CONSOLE_INTERFACE 2
118 #define CONSOLE_ENDPOINT 3
119 #define CONSOLE_EPSIZE 16
121 /* Number of IN reports that can be stored inside the output queue */
122 #define CONSOLE_QUEUE_CAPACITY 2
123 #define CONSOLE_QUEUE_BUFFER_SIZE (CONSOLE_QUEUE_CAPACITY * CONSOLE_EPSIZE)
125 /* Console flush time */
126 #define CONSOLE_FLUSH_MS 50
128 /* Putchar over the USB console */
129 int8_t sendchar(uint8_t c);
130 /* wrapper for printf lib */
132 /* Flush output (send everything immediately) */
133 void console_flush_output(void);
135 /* console IN request callback handler */
136 void console_in_cb(USBDriver *usbp, usbep_t ep);
137 #endif /* CONSOLE_ENABLE */
139 void sendchar_pf(void *p, char c);
141 #endif /* _USB_MAIN_H_ */