]> git.donarmstrong.com Git - tmk_firmware.git/blobdiff - protocol/pjrc/main.c
USB initialize when plug-in during battery powered
[tmk_firmware.git] / protocol / pjrc / main.c
index 0b0a44028e9f57a5f9a1d1840344aaa4e99c4ebf..1ef87f8651c8a2ee415e7d72590156b20db8c5b8 100644 (file)
 #include "matrix.h"
 #include "print.h"
 #include "debug.h"
+#include "sendchar.h"
 #include "util.h"
-#include "bootloader.h"
-#ifdef PS2_MOUSE_ENABLE
-#   include "ps2_mouse.h"
-#endif
+#include "suspend.h"
 #include "host.h"
 #include "pjrc.h"
 
@@ -44,9 +42,6 @@
 
 int main(void)
 {
-    DEBUG_LED_CONFIG;
-    DEBUG_LED_OFF;
-
     // set for 16 MHz clock
     CPU_PRESCALE(0);
 
@@ -56,36 +51,21 @@ int main(void)
     usb_init();
     while (!usb_configured()) /* wait */ ;
 
-    keyboard_init();
-    matrix_scan();
-    if (matrix_key_count() >= 3) {
-#ifdef DEBUG_LED
-        for (int i = 0; i < 6; i++) {
-            DEBUG_LED_CONFIG;
-            DEBUG_LED_ON;
-            _delay_ms(500);
-            DEBUG_LED_OFF;
-            _delay_ms(500);
-        }
-#else
-        _delay_ms(5000);
-#endif
-        print_enable = true;
-        debug_enable = true;
-        debug_matrix = true;
-        debug_keyboard = true;
-        debug_mouse = true;
-        print("debug enabled.\n");
-    }
-    if (matrix_key_count() >= 4) {
-        print("jump to bootloader...\n");
-        _delay_ms(1000);
-        bootloader_jump(); // not return
-    }
-
+    print_set_sendchar(sendchar);
 
+    keyboard_init();
     host_set_driver(pjrc_driver());
+#ifdef SLEEP_LED_ENABLE
+    sleep_led_init();
+#endif
     while (1) {
-       keyboard_proc(); 
+        while (suspend) {
+            suspend_power_down();
+            if (remote_wakeup && suspend_wakeup_condition()) {
+                usb_remote_wakeup();
+            }
+        }
+
+        keyboard_task(); 
     }
 }