]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - tmk.c
support 12KRO
[max/tmk_keyboard.git] / tmk.c
diff --git a/tmk.c b/tmk.c
index ae138623bc2378cff0dcb438b1b8e86921145c2e..f7042bd6fbe2754267d8d48e0c41c72f4c7be1b1 100644 (file)
--- a/tmk.c
+++ b/tmk.c
 #include "debug.h"
 #include "util.h"
 #include "controller.h"
+#include "timer.h"
+#include "jump_bootloader.h"
 
 
 #define CPU_PRESCALE(n)    (CLKPR = 0x80, CLKPR = (n))
 
+
 bool debug_enable = false;
 bool debug_matrix = false;
 bool debug_keyboard = false;
 bool debug_mouse = false;
 
-uint16_t idle_count=0;
-
 
 int main(void)
 {
+    DEBUG_LED_CONFIG;
+    DEBUG_LED_OFF;
+
     // set for 16 MHz clock
     CPU_PRESCALE(0);
 
@@ -58,25 +62,12 @@ int main(void)
     usb_init();
     while (!usb_configured()) /* wait */ ;
 
-    // Configure timer 0 to generate a timer overflow interrupt every
-    // 256*1024 clock cycles, or approx 61 Hz when using 16 MHz clock
-    // This demonstrates how to use interrupts to implement a simple
-    // inactivity timeout.
-    TCCR0A = 0x00;
-    TCCR0B = 0x05;
-    TIMSK0 = (1<<TOIE0);
-
+    timer_init();
 
     matrix_init();
     matrix_scan();
-    // debug on by pressing down any 4 or more keys during boot time.
+    // bootloader comes up when any 4 or more keys are pressed at startup
     if (matrix_key_count() >= 4) {
-        print_enable = true;
-        debug_enable = true;
-    }
-
-    /* wait for debug pipe ready */
-    if (print_enable) {
 #ifdef DEBUG_LED
         for (int i = 0; i < 6; i++) {
             DEBUG_LED_CONFIG;
@@ -86,24 +77,16 @@ int main(void)
             _delay_ms(500);
         }
 #else
-            _delay_ms(6000);
+        _delay_ms(5000);
 #endif
+        print_enable = true;
+        print("jump to bootloader...\n");
+        _delay_ms(1000);
+        jump_bootloader(); // not return
     }
-    // print description
-    print(STR(DESCRIPTION) "\n");
 
     while (1) {
        proc_matrix(); 
         _delay_ms(2);
     }
 }
-
-
-// This interrupt routine is run approx 61 times per second.
-// A very simple inactivity timeout is implemented, where we
-// will send a space character and print a message to the
-// hid_listen debug message window.
-ISR(TIMER0_OVF_vect)
-{
-    idle_count++;
-}