]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/protocol/chibios/usb_main.h
Use a single endpoint for HID reports (#3951)
[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  * Shared EP header
70  * ---------------
71  */
72
73 /* shared IN request callback handler */
74 void shared_in_cb(USBDriver *usbp, usbep_t ep);
75
76 /* ---------------
77  * Extrakey header
78  * ---------------
79  */
80
81 #ifdef EXTRAKEY_ENABLE
82
83 /* extra report structure */
84 typedef struct {
85   uint8_t report_id;
86   uint16_t usage;
87 } __attribute__ ((packed)) report_extra_t;
88 #endif /* EXTRAKEY_ENABLE */
89
90 /* --------------
91  * Console header
92  * --------------
93  */
94
95 #ifdef CONSOLE_ENABLE
96
97 /* Putchar over the USB console */
98 int8_t sendchar(uint8_t c);
99
100 /* Flush output (send everything immediately) */
101 void console_flush_output(void);
102
103 #endif /* CONSOLE_ENABLE */
104
105 void sendchar_pf(void *p, char c);
106
107 #endif /* _USB_MAIN_H_ */