4 #include <util/delay.h>
22 /* LED ping configuration */
24 //#define LEONARDO_LED
26 // For TMK converter and Teensy
27 #define LED_TX_INIT (DDRD |= (1<<6))
28 #define LED_TX_ON (PORTD |= (1<<6))
29 #define LED_TX_OFF (PORTD &= ~(1<<6))
30 #define LED_TX_TOGGLE (PORTD ^= (1<<6))
31 #elif defined(LEONARDO_LED)
32 // For Leonardo(TX LED)
33 #define LED_TX_INIT (DDRD |= (1<<5))
34 #define LED_TX_ON (PORTD &= ~(1<<5))
35 #define LED_TX_OFF (PORTD |= (1<<5))
36 #define LED_TX_TOGGLE (PORTD ^= (1<<5))
46 static HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&usb_host);
47 static KBDReportParser kbd_parser;
48 static USBHub hub1(&usb_host); // one hub is enough for HHKB pro2
49 /* may be needed for other device with more hub
50 static USBHub hub2(&usb_host);
51 static USBHub hub3(&usb_host);
52 static USBHub hub4(&usb_host);
53 static USBHub hub5(&usb_host);
54 static USBHub hub6(&usb_host);
55 static USBHub hub7(&usb_host);
58 static void LUFA_setup(void)
60 /* Disable watchdog if enabled by bootloader/fuses */
61 MCUSR &= ~(1 << WDRF);
64 /* Disable clock division */
65 clock_prescale_set(clock_div_1);
67 // Leonardo needs. Without this USB device is not recognized.
73 USB_Device_EnableSOFEvents();
74 print_set_sendchar(sendchar);
77 static void HID_setup()
79 if (usb_host.Init() == -1) {
85 kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser);
96 host_set_driver(&lufa_driver);
101 /* NOTE: Don't insert time consuming job here.
102 * It'll cause unclear initialization failure when DFU reset(worm start).
106 // wait for startup of sendchar routine
107 while (USB_DeviceState != DEVICE_STATE_Configured) ;
112 debug("init: done\n");
118 timer = timer_read();
120 timer = timer_elapsed(timer);
122 debug("host.Task: "); debug_hex16(timer); debug("\n");
125 #if !defined(INTERRUPT_CONTROL_ENDPOINT)
126 // LUFA Task for control request