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