diff options
Diffstat (limited to 'tmk_core/protocol/chibios')
-rw-r--r-- | tmk_core/protocol/chibios/chibios.c | 32 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/usb_endpoints.h | 2 | ||||
-rw-r--r-- | tmk_core/protocol/chibios/usb_main.c | 24 |
3 files changed, 21 insertions, 37 deletions
diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index cf948154f9..5720bc3c4c 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -40,9 +40,6 @@ # define EARLY_INIT_PERFORM_BOOTLOADER_JUMP FALSE #endif -#ifdef SLEEP_LED_ENABLE -# include "sleep_led.h" -#endif #ifdef MIDI_ENABLE # include "qmk_midi.h" #endif @@ -66,9 +63,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 +141,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 +151,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 +168,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_endpoints.h b/tmk_core/protocol/chibios/usb_endpoints.h index a4e5ed88fc..9fad83726e 100644 --- a/tmk_core/protocol/chibios/usb_endpoints.h +++ b/tmk_core/protocol/chibios/usb_endpoints.h @@ -121,7 +121,7 @@ typedef enum { #define IS_VALID_USB_ENDPOINT_IN_LUT(i) ((i) >= 0 && (i) < USB_ENDPOINT_IN_COUNT) -usb_endpoint_in_lut_t usb_endpoint_interface_lut[TOTAL_INTERFACES]; +extern usb_endpoint_in_lut_t usb_endpoint_interface_lut[TOTAL_INTERFACES]; typedef enum { #if defined(RAW_ENABLE) diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 5a5354416f..b798a8d1cb 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -21,10 +21,6 @@ #include "host.h" #include "suspend.h" #include "timer.h" -#ifdef SLEEP_LED_ENABLE -# include "sleep_led.h" -# include "led.h" -#endif #include "wait.h" #include "usb_endpoints.h" #include "usb_device_state.h" @@ -32,6 +28,10 @@ #include "usb_driver.h" #include "usb_types.h" +#ifdef RAW_ENABLE +# include "raw_hid.h" +#endif + #ifdef NKRO_ENABLE # include "keycode_config.h" @@ -127,19 +127,11 @@ static inline bool usb_event_queue_dequeue(usbevent_t *event) { static inline void usb_event_suspend_handler(void) { usb_device_state_set_suspend(USB_DRIVER.configuration != 0, USB_DRIVER.configuration); -#ifdef SLEEP_LED_ENABLE - sleep_led_enable(); -#endif /* SLEEP_LED_ENABLE */ } static inline void usb_event_wakeup_handler(void) { suspend_wakeup_init(); usb_device_state_set_resume(USB_DRIVER.configuration != 0, USB_DRIVER.configuration); -#ifdef SLEEP_LED_ENABLE - sleep_led_disable(); - // NOTE: converters may not accept this - led_set(host_keyboard_leds()); -#endif /* SLEEP_LED_ENABLE */ } bool last_suspend_state = false; @@ -515,19 +507,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))) { |