X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;f=tmk.c;h=18a05ffdff4e7292eefa84445fd770d690a1a066;hb=fb8d23c60c757d5d9c2270cb0123a53be2049a28;hp=cd52d318e6342581aaf212609523c77c3b36b382;hpb=06eb50be07ff16e4bfb046e4773185d9bcf048e9;p=max%2Ftmk_keyboard.git diff --git a/tmk.c b/tmk.c index cd52d318..18a05ffd 100644 --- a/tmk.c +++ b/tmk.c @@ -24,36 +24,36 @@ * THE SOFTWARE. */ -// TODO: clean unused headers #include #include -#include #include #include +#include "keyboard.h" #include "usb.h" -#include "usb_keyboard.h" -#include "usb_mouse.h" +#include "matrix.h" #include "print.h" -#include "matrix_skel.h" -#include "keymap.h" +#include "debug.h" +#include "util.h" #include "jump_bootloader.h" +#ifdef PS2_MOUSE_ENABLE +# include "ps2_mouse.h" +#endif -#include "key_process.h" #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) -// TODO: should go to hardware dependent file -// for Teensy/Teensy++ 2.0 -#define LED_CONFIG (DDRD |= (1<<6)) -#define LED_ON (PORTD |= (1<<6)) -#define LED_OFF (PORTD &= ~(1<<6)) - -uint16_t idle_count=0; +bool debug_enable = false; +bool debug_matrix = false; +bool debug_keyboard = false; +bool debug_mouse = false; int main(void) { + DEBUG_LED_CONFIG; + DEBUG_LED_OFF; + // set for 16 MHz clock CPU_PRESCALE(0); @@ -63,41 +63,35 @@ int main(void) usb_init(); while (!usb_configured()) /* wait */ ; - // Wait an extra second for the PC's operating system to load drivers - // and do whatever it does to actually be ready for input - // needs such long time in my PC. - /* wait for debug print. no need for normal use */ - for (int i =0; i < 6; i++) { - LED_CONFIG; - LED_ON; - _delay_ms(500); - LED_OFF; - _delay_ms(500); + 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); + jump_bootloader(); // not return } - - // 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<