X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=tmk_core%2Fprotocol%2Fchibios%2Fusb_main.c;h=106ce0879dbbfcd2dc7e316cae1d2120c735d438;hb=3fe8e1c238fc8e15dacda1b03c0c1745a7b8e8e7;hp=d248b447deb1396e18c053dca2615fa0074e8318;hpb=b47a88f4a5c3e054539f4113cdf13cf8d2c65545;p=max%2Ftmk_keyboard.git diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index d248b447..106ce087 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -27,15 +27,34 @@ #include "sleep_led.h" #include "led.h" #endif +#include "hook.h" + +/* TMK hooks */ +__attribute__((weak)) +void hook_usb_wakeup(void) { +#ifdef SLEEP_LED_ENABLE + sleep_led_disable(); + // NOTE: converters may not accept this + led_set(host_keyboard_leds()); +#endif /* SLEEP_LED_ENABLE */ +} + + __attribute__((weak)) +void hook_usb_suspend_entry(void) { +#ifdef SLEEP_LED_ENABLE + sleep_led_enable(); +#endif /* SLEEP_LED_ENABLE */ +} + /* --------------------------------------------------------- * Global interface variables and declarations * --------------------------------------------------------- */ -uint8_t keyboard_idle = 0; -uint8_t keyboard_protocol = 1; -uint16_t keyboard_led_stats = 0; +uint8_t keyboard_idle __attribute__((aligned(2))) = 0; +uint8_t keyboard_protocol __attribute__((aligned(2))) = 1; +uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0; volatile uint16_t keyboard_idle_count = 0; static virtual_timer_t keyboard_idle_timer; static void keyboard_idle_timer_cb(void *arg); @@ -795,19 +814,13 @@ static void usb_event_cb(USBDriver *usbp, usbevent_t event) { case USB_EVENT_SUSPEND: //TODO: from ISR! print("[S]"); -#ifdef SLEEP_LED_ENABLE - sleep_led_enable(); -#endif /* SLEEP_LED_ENABLE */ + hook_usb_suspend_entry(); return; case USB_EVENT_WAKEUP: //TODO: from ISR! print("[W]"); suspend_wakeup_init(); -#ifdef SLEEP_LED_ENABLE - sleep_led_disable(); - // NOTE: converters may not accept this - led_set(host_keyboard_leds()); -#endif /* SLEEP_LED_ENABLE */ + hook_usb_wakeup(); return; case USB_EVENT_STALLED: @@ -1350,7 +1363,7 @@ int8_t sendchar(uint8_t c) { return 0; } osalSysUnlock(); - /* Timeout after 5us if the queue is full. + /* Timeout after 100us if the queue is full. * Increase this timeout if too much stuff is getting * dropped (i.e. the buffer is getting full too fast * for USB/HIDRAW to dequeue). Another possibility