]> git.donarmstrong.com Git - tmk_firmware.git/blob - protocol/usb_hid/main.cpp
Add USB_Host_Shield_2.0 and arduino-1.0.1 in usb_hid.
[tmk_firmware.git] / protocol / usb_hid / main.cpp
1 #include <util/delay.h>
2 #include <Arduino.h>
3 #include "Usb.h"
4 #include "hid.h"
5 #include "hidboot.h"
6 #include "parser.h"
7
8
9 USB     Usb;
10 HIDBoot<HID_PROTOCOL_KEYBOARD>    kbd(&Usb);
11 KBDReportParser Prs;
12
13 void usb_disable()
14 {
15     USBCON &= ~(1<<VBUSTI);
16     UDIEN = 0;
17     USBINT = 0;
18     UDINT = 0;
19     UDCON |= (1<<DETACH);
20     USBCON &= ~(1<<USBE);
21     PLLCSR = 0;
22     UHWCON &= ~(1<<UVREGE);
23     USBCON &= ~(1<<OTGPADE);
24 }
25
26 void setup()
27 {
28     usb_disable();
29
30     // RX LED for debug
31     DDRB |= (1<<0);
32
33     Serial.begin( 115200 );
34     while (!Serial) ;
35
36     delay( 1000 );
37
38     Serial.println("Start");
39
40     if (Usb.Init() == -1) {
41         Serial.println("OSC did not start.");
42     }
43       
44     delay( 200 );
45   
46     kbd.SetReportParser(0, (HIDReportParser*)&Prs);
47 }
48
49 void loop()
50 {
51     Usb.Task();
52 }
53
54 int main(void)
55 {
56     // arduino/wiring.c(Timer initialize)
57     init();
58
59     setup();
60     
61     for (;;) {
62         loop();
63     }
64         
65     return 0;
66 }