aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/chibios
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/chibios')
-rw-r--r--tmk_core/protocol/chibios/chibios.c29
-rw-r--r--tmk_core/protocol/chibios/usb_main.c12
2 files changed, 20 insertions, 21 deletions
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c
index cf948154f9..19d8121e34 100644
--- a/tmk_core/protocol/chibios/chibios.c
+++ b/tmk_core/protocol/chibios/chibios.c
@@ -66,9 +66,19 @@ void send_keyboard(report_keyboard_t *report);
void send_nkro(report_nkro_t *report);
void send_mouse(report_mouse_t *report);
void send_extra(report_extra_t *report);
+void send_raw_hid(uint8_t *data, uint8_t length);
/* host struct */
-host_driver_t chibios_driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra};
+host_driver_t chibios_driver = {
+ .keyboard_leds = usb_device_state_get_leds,
+ .send_keyboard = send_keyboard,
+ .send_nkro = send_nkro,
+ .send_mouse = send_mouse,
+ .send_extra = send_extra,
+#ifdef RAW_ENABLE
+ .send_raw_hid = send_raw_hid,
+#endif
+};
#ifdef VIRTSER_ENABLE
void virtser_task(void);
@@ -134,8 +144,6 @@ void protocol_setup(void) {
// chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
}
-static host_driver_t *driver = NULL;
-
void protocol_pre_init(void) {
/* Init USB */
usb_event_queue_init();
@@ -146,18 +154,11 @@ void protocol_pre_init(void) {
#endif
/* Wait until USB is active */
- while (true) {
-#if defined(USB_WAIT_FOR_ENUMERATION)
- if (USB_DRIVER.state == USB_ACTIVE) {
- driver = &chibios_driver;
- break;
- }
-#else
- driver = &chibios_driver;
- break;
-#endif
+#ifdef USB_WAIT_FOR_ENUMERATION
+ while (USB_DRIVER.state != USB_ACTIVE) {
wait_ms(50);
}
+#endif
/* Do need to wait here!
* Otherwise the next print might start a transfer on console EP
@@ -170,7 +171,7 @@ void protocol_pre_init(void) {
}
void protocol_post_init(void) {
- host_set_driver(driver);
+ host_set_driver(&chibios_driver);
}
void protocol_pre_task(void) {
diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c
index 5a5354416f..f9d7f5c4d6 100644
--- a/tmk_core/protocol/chibios/usb_main.c
+++ b/tmk_core/protocol/chibios/usb_main.c
@@ -32,6 +32,10 @@
#include "usb_driver.h"
#include "usb_types.h"
+#ifdef RAW_ENABLE
+# include "raw_hid.h"
+#endif
+
#ifdef NKRO_ENABLE
# include "keycode_config.h"
@@ -515,19 +519,13 @@ void console_task(void) {
#endif /* CONSOLE_ENABLE */
#ifdef RAW_ENABLE
-void raw_hid_send(uint8_t *data, uint8_t length) {
+void send_raw_hid(uint8_t *data, uint8_t length) {
if (length != RAW_EPSIZE) {
return;
}
send_report(USB_ENDPOINT_IN_RAW, data, length);
}
-__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) {
- // Users should #include "raw_hid.h" in their own code
- // and implement this function there. Leave this as weak linkage
- // so users can opt to not handle data coming in.
-}
-
void raw_hid_task(void) {
uint8_t buffer[RAW_EPSIZE];
while (receive_report(USB_ENDPOINT_OUT_RAW, buffer, sizeof(buffer))) {