]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - converter/usb_usb/main.cpp
xt_usb: Fix scan code print for debug
[max/tmk_keyboard.git] / converter / usb_usb / main.cpp
index 652c80573466b3498d29b41b2dfbef72a35d0c33..76e88922cb41205243ce78da89263033ca48cc0b 100644 (file)
@@ -3,17 +3,9 @@
 #include <avr/power.h>
 #include <util/delay.h>
 
-// USB HID host
-#include "Usb.h"
-#include "usbhub.h"
-#include "hid.h"
-#include "hidboot.h"
-#include "parser.h"
-
 // LUFA
 #include "lufa.h"
 
-#include "timer.h"
 #include "sendchar.h"
 #include "debug.h"
 #include "keyboard.h"
@@ -50,7 +42,11 @@ static void LUFA_setup(void)
     wdt_disable();
 
     /* Disable clock division */
+#if (F_CPU == 8000000)
+    clock_prescale_set(clock_div_2);    // 16MHz crystal divided by 2
+#else
     clock_prescale_set(clock_div_1);
+#endif
 
     // Leonardo needs. Without this USB device is not recognized.
     USB_Disable();
@@ -64,22 +60,6 @@ static void LUFA_setup(void)
 
 
 
-/*
- * USB Host Shield HID keyboard
- */
-USB usb_host;
-USBHub hub1(&usb_host);
-HIDBoot<HID_PROTOCOL_KEYBOARD>    kbd(&usb_host);
-KBDReportParser kbd_parser;
-
-
-void led_set(uint8_t usb_led)
-{
-    kbd.SetReport(0, 0, 2, 0, 1, &usb_led);
-}
-
-
-
 int main(void)
 {
     // LED for debug
@@ -94,34 +74,24 @@ int main(void)
 
     LUFA_setup();
 
-    // USB Host Shield setup
-    usb_host.Init();
-    kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser);
-
     /* NOTE: Don't insert time consuming job here.
      * It'll cause unclear initialization failure when DFU reset(worm start).
      */
     sei();
 
+/* Some keyboards bootup quickly and cannot be initialized with this startup wait.
     // wait for startup of sendchar routine
     while (USB_DeviceState != DEVICE_STATE_Configured) ;
     if (debug_enable) {
         _delay_ms(1000);
     }
+*/
 
     debug("init: done\n");
 
-uint16_t timer;
     for (;;) {
         keyboard_task();
 
-timer = timer_read();
-        usb_host.Task();
-timer = timer_elapsed(timer);
-if (timer > 100) {
-    debug("host.Task: "); debug_hex16(timer);  debug("\n");
-}
-
 #if !defined(INTERRUPT_CONTROL_ENDPOINT)
         // LUFA Task for control request
         USB_USBTask();