4 #include <util/delay.h>
20 #include "leonardo_led.h"
24 static HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&usb_host);
25 static KBDReportParser kbd_parser;
27 static void LUFA_setup(void)
29 /* Disable watchdog if enabled by bootloader/fuses */
30 MCUSR &= ~(1 << WDRF);
33 /* Disable clock division */
34 clock_prescale_set(clock_div_1);
36 // Leonardo needs. Without this USB device is not recognized.
42 USB_Device_EnableSOFEvents();
43 print_set_sendchar(sendchar);
46 static void HID_setup()
48 if (usb_host.Init() == -1) {
49 debug("HID init: failed\n");
55 kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser);
66 debug_keyboard = true;
69 host_set_driver(&lufa_driver);
76 // wait for startup of sendchar routine
77 while (USB_DeviceState != DEVICE_STATE_Configured) ;
82 debug("init: start\n");
85 debug("init: done\n");
88 // to see loop pulse with oscillo scope
96 timer = timer_elapsed(timer);
98 debug("host.Task: "); debug_hex16(timer); debug("\n");
101 #if !defined(INTERRUPT_CONTROL_ENDPOINT)
102 // LUFA Task for control request