aboutsummaryrefslogtreecommitdiff
path: root/protocol/usb_hid/main.cpp
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2012-08-14 00:17:31 +0900
committertmk <nobody@nowhere>2012-08-28 21:56:15 +0900
commit895cd4dfa29f0f3c623544f4868ac63e619c69d9 (patch)
tree31d05ec85fa1bc1b1e6ef7f12dccfc3531240798 /protocol/usb_hid/main.cpp
parent7350b7c6aa300a234244c264b10d1732803c27df (diff)
downloadqmk_firmware-895cd4dfa29f0f3c623544f4868ac63e619c69d9.tar.gz
qmk_firmware-895cd4dfa29f0f3c623544f4868ac63e619c69d9.zip
Add USB HID(host) protocol.(not finished)
Diffstat (limited to 'protocol/usb_hid/main.cpp')
-rw-r--r--protocol/usb_hid/main.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/protocol/usb_hid/main.cpp b/protocol/usb_hid/main.cpp
new file mode 100644
index 000000000..c292d458e
--- /dev/null
+++ b/protocol/usb_hid/main.cpp
@@ -0,0 +1,66 @@
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
9USB Usb;
10HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&Usb);
11KBDReportParser Prs;
12
13void 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
26void 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
49void loop()
50{
51 Usb.Task();
52}
53
54int 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}