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) {
59 debug("HID init: failed\n");
65 kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser);
77 debug_keyboard = true;
81 host_set_driver(&lufa_driver);
88 // wait for startup of sendchar routine
89 while (USB_DeviceState != DEVICE_STATE_Configured) ;
94 debug("init: start\n");
97 debug("init: done\n");
100 // to see loop pulse with oscillo scope
106 timer = timer_read();
108 timer = timer_elapsed(timer);
110 debug("host.Task: "); debug_hex16(timer); debug("\n");
113 #if !defined(INTERRUPT_CONTROL_ENDPOINT)
114 // LUFA Task for control request