]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/chibios/usb_main.h
1f7eb12f8db5c5e0e2a7c84d29eea8c0e351479f
[qmk_firmware.git] / tmk_core / protocol / chibios / usb_main.h
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
18
19 #ifndef _USB_MAIN_H_
20 #define _USB_MAIN_H_
21
22 // TESTING
23 // extern uint8_t blinkLed;
24
25 #include "ch.h"
26 #include "hal.h"
27
28 /* -------------------------
29  * General USB driver header
30  * -------------------------
31  */
32
33 /* The USB driver to use */
34 #define USB_DRIVER USBD1
35
36 /* Initialize the USB driver and bus */
37 void init_usb_driver(USBDriver *usbp);
38
39 /* ---------------
40  * Keyboard header
41  * ---------------
42  */
43
44 /* extern report_keyboard_t keyboard_report_sent; */
45
46 /* keyboard IN request callback handler */
47 void kbd_in_cb(USBDriver *usbp, usbep_t ep);
48
49 /* start-of-frame handler */
50 void kbd_sof_cb(USBDriver *usbp);
51
52 #ifdef NKRO_ENABLE
53 /* nkro IN callback hander */
54 void nkro_in_cb(USBDriver *usbp, usbep_t ep);
55 #endif /* NKRO_ENABLE */
56
57 /* ------------
58  * Mouse header
59  * ------------
60  */
61
62 #ifdef MOUSE_ENABLE
63
64 /* mouse IN request callback handler */
65 void mouse_in_cb(USBDriver *usbp, usbep_t ep);
66 #endif /* MOUSE_ENABLE */
67
68 /* ---------------
69  * Extrakey header
70  * ---------------
71  */
72
73 #ifdef EXTRAKEY_ENABLE
74
75 /* extrakey IN request callback handler */
76 void extra_in_cb(USBDriver *usbp, usbep_t ep);
77
78 /* extra report structure */
79 typedef struct {
80   uint8_t report_id;
81   uint16_t usage;
82 } __attribute__ ((packed)) report_extra_t;
83 #endif /* EXTRAKEY_ENABLE */
84
85 /* --------------
86  * Console header
87  * --------------
88  */
89
90 #ifdef CONSOLE_ENABLE
91
92 /* Putchar over the USB console */
93 int8_t sendchar(uint8_t c);
94
95 /* Flush output (send everything immediately) */
96 void console_flush_output(void);
97
98 #endif /* CONSOLE_ENABLE */
99
100 void sendchar_pf(void *p, char c);
101
102 #endif /* _USB_MAIN_H_ */