4 #include <util/delay.h>
23 /* LED ping configuration */
25 //#define LEONARDO_LED
27 // For TMK converter and Teensy
28 #define LED_TX_INIT (DDRD |= (1<<6))
29 #define LED_TX_ON (PORTD |= (1<<6))
30 #define LED_TX_OFF (PORTD &= ~(1<<6))
31 #define LED_TX_TOGGLE (PORTD ^= (1<<6))
32 #elif defined(LEONARDO_LED)
33 // For Leonardo(TX LED)
34 #define LED_TX_INIT (DDRD |= (1<<5))
35 #define LED_TX_ON (PORTD &= ~(1<<5))
36 #define LED_TX_OFF (PORTD |= (1<<5))
37 #define LED_TX_TOGGLE (PORTD ^= (1<<5))
46 static void LUFA_setup(void)
48 /* Disable watchdog if enabled by bootloader/fuses */
49 MCUSR &= ~(1 << WDRF);
52 /* Disable clock division */
53 clock_prescale_set(clock_div_1);
55 // Leonardo needs. Without this USB device is not recognized.
61 USB_Device_EnableSOFEvents();
62 print_set_sendchar(sendchar);
68 * USB Host Shield HID keyboard
71 USBHub hub1(&usb_host);
72 HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&usb_host);
73 KBDReportParser kbd_parser;
76 void led_set(uint8_t usb_led)
78 kbd.SetReport(0, 0, 2, 0, 1, &usb_led);
90 debug_keyboard = true;
92 host_set_driver(&lufa_driver);
97 // USB Host Shield setup
99 kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser);
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