diff options
Diffstat (limited to 'protocol/lufa/lufa.c')
-rw-r--r-- | protocol/lufa/lufa.c | 96 |
1 files changed, 52 insertions, 44 deletions
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index b7ecb8488..81409ce9e 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c | |||
@@ -59,7 +59,7 @@ static void send_keyboard(report_keyboard_t *report); | |||
59 | static void send_mouse(report_mouse_t *report); | 59 | static void send_mouse(report_mouse_t *report); |
60 | static void send_system(uint16_t data); | 60 | static void send_system(uint16_t data); |
61 | static void send_consumer(uint16_t data); | 61 | static void send_consumer(uint16_t data); |
62 | static host_driver_t lufa_driver = { | 62 | host_driver_t lufa_driver = { |
63 | keyboard_leds, | 63 | keyboard_leds, |
64 | send_keyboard, | 64 | send_keyboard, |
65 | send_mouse, | 65 | send_mouse, |
@@ -68,49 +68,9 @@ static host_driver_t lufa_driver = { | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | 70 | ||
71 | static void SetupHardware(void); | 71 | /******************************************************************************* |
72 | static void Console_Task(void); | 72 | * Console |
73 | 73 | ******************************************************************************/ | |
74 | int main(void) | ||
75 | { | ||
76 | SetupHardware(); | ||
77 | sei(); | ||
78 | |||
79 | print_enable = true; | ||
80 | debug_enable = true; | ||
81 | debug_matrix = true; | ||
82 | debug_keyboard = true; | ||
83 | debug_mouse = true; | ||
84 | |||
85 | // TODO: can't print here | ||
86 | debug("LUFA init\n"); | ||
87 | |||
88 | keyboard_init(); | ||
89 | host_set_driver(&lufa_driver); | ||
90 | while (1) { | ||
91 | keyboard_proc(); | ||
92 | |||
93 | #if !defined(INTERRUPT_CONTROL_ENDPOINT) | ||
94 | USB_USBTask(); | ||
95 | #endif | ||
96 | } | ||
97 | } | ||
98 | |||
99 | void SetupHardware(void) | ||
100 | { | ||
101 | /* Disable watchdog if enabled by bootloader/fuses */ | ||
102 | MCUSR &= ~(1 << WDRF); | ||
103 | wdt_disable(); | ||
104 | |||
105 | /* Disable clock division */ | ||
106 | clock_prescale_set(clock_div_1); | ||
107 | |||
108 | USB_Init(); | ||
109 | |||
110 | // for Console_Task | ||
111 | USB_Device_EnableSOFEvents(); | ||
112 | } | ||
113 | |||
114 | #ifdef CONSOLE_ENABLE | 74 | #ifdef CONSOLE_ENABLE |
115 | static void Console_Task(void) | 75 | static void Console_Task(void) |
116 | { | 76 | { |
@@ -446,3 +406,51 @@ int8_t sendchar(uint8_t c) | |||
446 | return 0; | 406 | return 0; |
447 | } | 407 | } |
448 | #endif | 408 | #endif |
409 | |||
410 | |||
411 | /******************************************************************************* | ||
412 | * main | ||
413 | ******************************************************************************/ | ||
414 | static void SetupHardware(void) | ||
415 | { | ||
416 | /* Disable watchdog if enabled by bootloader/fuses */ | ||
417 | MCUSR &= ~(1 << WDRF); | ||
418 | wdt_disable(); | ||
419 | |||
420 | /* Disable clock division */ | ||
421 | clock_prescale_set(clock_div_1); | ||
422 | |||
423 | // Leonardo needs. Without this USB device is not recognized. | ||
424 | USB_Disable(); | ||
425 | |||
426 | USB_Init(); | ||
427 | |||
428 | // for Console_Task | ||
429 | USB_Device_EnableSOFEvents(); | ||
430 | } | ||
431 | |||
432 | int main(void) __attribute__ ((weak)); | ||
433 | int main(void) | ||
434 | { | ||
435 | SetupHardware(); | ||
436 | sei(); | ||
437 | |||
438 | print_enable = true; | ||
439 | debug_enable = true; | ||
440 | debug_matrix = true; | ||
441 | debug_keyboard = true; | ||
442 | debug_mouse = true; | ||
443 | |||
444 | // TODO: can't print here | ||
445 | debug("LUFA init\n"); | ||
446 | |||
447 | keyboard_init(); | ||
448 | host_set_driver(&lufa_driver); | ||
449 | while (1) { | ||
450 | keyboard_proc(); | ||
451 | |||
452 | #if !defined(INTERRUPT_CONTROL_ENDPOINT) | ||
453 | USB_USBTask(); | ||
454 | #endif | ||
455 | } | ||
456 | } | ||