X-Git-Url: https://git.friedersdorff.com/?a=blobdiff_plain;ds=inline;f=protocol%2Fpjrc%2Fmain.c;h=4f87a1736458851e980b9839da15e336ed770ce9;hb=c1ac7f159f12626aaef68e6caab0423b6bd00114;hp=15f14920b4b4514b62bda24d19790b142b83bf25;hpb=62d1ebb91c7b381ce3d88aad9ee0b03bea9fce26;p=max%2Ftmk_keyboard.git diff --git a/protocol/pjrc/main.c b/protocol/pjrc/main.c index 15f14920..4f87a173 100644 --- a/protocol/pjrc/main.c +++ b/protocol/pjrc/main.c @@ -24,17 +24,16 @@ #include #include #include +#include #include #include "keyboard.h" #include "usb.h" #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" @@ -42,17 +41,8 @@ #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) -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); @@ -62,36 +52,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(WDTO_120MS); + if (remote_wakeup && suspend_wakeup_condition()) { + usb_remote_wakeup(); + } + } + + keyboard_task(); } }