4 #include <util/delay.h>
15 /* LED ping configuration */
17 //#define LEONARDO_LED
19 // For TMK converter and Teensy
20 #define LED_TX_INIT (DDRD |= (1<<6))
21 #define LED_TX_ON (PORTD |= (1<<6))
22 #define LED_TX_OFF (PORTD &= ~(1<<6))
23 #define LED_TX_TOGGLE (PORTD ^= (1<<6))
24 #elif defined(LEONARDO_LED)
25 // For Leonardo(TX LED)
26 #define LED_TX_INIT (DDRD |= (1<<5))
27 #define LED_TX_ON (PORTD &= ~(1<<5))
28 #define LED_TX_OFF (PORTD |= (1<<5))
29 #define LED_TX_TOGGLE (PORTD ^= (1<<5))
38 static void LUFA_setup(void)
40 /* Disable watchdog if enabled by bootloader/fuses */
41 MCUSR &= ~(1 << WDRF);
44 /* Disable clock division */
45 #if (F_CPU == 8000000)
46 clock_prescale_set(clock_div_2); // 16MHz crystal divided by 2
48 clock_prescale_set(clock_div_1);
51 // Leonardo needs. Without this USB device is not recognized.
57 USB_Device_EnableSOFEvents();
58 print_set_sendchar(sendchar);
70 debug_keyboard = true;
72 host_set_driver(&lufa_driver);
77 /* NOTE: Don't insert time consuming job here.
78 * It'll cause unclear initialization failure when DFU reset(worm start).
82 /* Some keyboards bootup quickly and cannot be initialized with this startup wait.
83 // wait for startup of sendchar routine
84 while (USB_DeviceState != DEVICE_STATE_Configured) ;
90 debug("init: done\n");
95 #if !defined(INTERRUPT_CONTROL_ENDPOINT)
96 // LUFA Task for control request