4 #include <util/delay.h>
21 #include "leonardo_led.h"
25 static HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&usb_host);
26 static KBDReportParser kbd_parser;
27 static USBHub hub1(&usb_host); // one hub is enough for HHKB pro2
28 /* may be needed for other device with more hub
29 static USBHub hub2(&usb_host);
30 static USBHub hub3(&usb_host);
31 static USBHub hub4(&usb_host);
32 static USBHub hub5(&usb_host);
33 static USBHub hub6(&usb_host);
34 static USBHub hub7(&usb_host);
37 static void LUFA_setup(void)
39 /* Disable watchdog if enabled by bootloader/fuses */
40 MCUSR &= ~(1 << WDRF);
43 /* Disable clock division */
44 clock_prescale_set(clock_div_1);
46 // Leonardo needs. Without this USB device is not recognized.
52 USB_Device_EnableSOFEvents();
53 print_set_sendchar(sendchar);
56 static void HID_setup()
58 if (usb_host.Init() == -1) {
64 kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser);
75 host_set_driver(&lufa_driver);
80 /* NOTE: Don't insert time consuming job here.
81 * It'll cause unclear initialization failure when DFU reset(worm start).
85 // wait for startup of sendchar routine
86 while (USB_DeviceState != DEVICE_STATE_Configured) ;
91 debug("init: done\n");
99 timer = timer_elapsed(timer);
101 debug("host.Task: "); debug_hex16(timer); debug("\n");
104 #if !defined(INTERRUPT_CONTROL_ENDPOINT)
105 // LUFA Task for control request