]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - tmk_core/protocol/lufa/lufa.c
core: lufa: Add delay for console startup
[max/tmk_keyboard.git] / tmk_core / protocol / lufa / lufa.c
index f5fc4cb790935c7678cc17210054c7f341ca4592..60849aea4c935da108839c6e583d596540624719 100644 (file)
@@ -431,7 +431,7 @@ static void send_keyboard(report_keyboard_t *report)
         Endpoint_SelectEndpoint(NKRO_IN_EPNUM);
 
         /* Check if write ready for a polling interval around 1ms */
-        while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(4);
+        while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(8);
         if (!Endpoint_IsReadWriteAllowed()) return;
 
         /* Write Keyboard Report Data */
@@ -482,6 +482,7 @@ static void send_mouse(report_mouse_t *report)
 
 static void send_system(uint16_t data)
 {
+#ifdef EXTRAKEY_ENABLE
     uint8_t timeout = 255;
 
     if (USB_DeviceState != DEVICE_STATE_Configured)
@@ -499,10 +500,12 @@ static void send_system(uint16_t data)
 
     Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
     Endpoint_ClearIN();
+#endif
 }
 
 static void send_consumer(uint16_t data)
 {
+#ifdef EXTRAKEY_ENABLE
     uint8_t timeout = 255;
 
     if (USB_DeviceState != DEVICE_STATE_Configured)
@@ -520,6 +523,7 @@ static void send_consumer(uint16_t data)
 
     Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
     Endpoint_ClearIN();
+#endif
 }
 
 
@@ -647,6 +651,17 @@ int main(void)
         USB_USBTask();
 #endif
     }
+
+    /* wait for Console startup */
+    // TODO: long delay often works anyhoo but proper startup would be better
+    uint16_t delay = 2000;
+    while (delay--) {
+#ifndef INTERRUPT_CONTROL_ENDPOINT
+        USB_USBTask();
+#endif
+        _delay_ms(1);
+    }
+
     print("USB configured.\n");
 
     /* init modules */
@@ -693,7 +708,7 @@ void hook_usb_suspend_entry(void)
     keyboard_led_stats = 0;
     led_set(keyboard_led_stats);
 
-    matrix_init();
+    matrix_clear();
     clear_keyboard();
 #ifdef SLEEP_LED_ENABLE
     sleep_led_enable();