summaryrefslogtreecommitdiff
path: root/protocol/usb_hid/main.cpp
diff options
context:
space:
mode:
authortmk2012-08-14 00:17:31 +0900
committertmk2012-08-28 21:56:15 +0900
commit895cd4dfa29f0f3c623544f4868ac63e619c69d9 (patch)
tree31d05ec85fa1bc1b1e6ef7f12dccfc3531240798 /protocol/usb_hid/main.cpp
parent7350b7c6aa300a234244c264b10d1732803c27df (diff)
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 @@
+#include <util/delay.h>
+#include <Arduino.h>
+#include "Usb.h"
+#include "hid.h"
+#include "hidboot.h"
+#include "parser.h"
+
+
+USB Usb;
+HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&Usb);
+KBDReportParser Prs;
+
+void usb_disable()
+{
+ USBCON &= ~(1<<VBUSTI);
+ UDIEN = 0;
+ USBINT = 0;
+ UDINT = 0;
+ UDCON |= (1<<DETACH);
+ USBCON &= ~(1<<USBE);
+ PLLCSR = 0;
+ UHWCON &= ~(1<<UVREGE);
+ USBCON &= ~(1<<OTGPADE);
+}
+
+void setup()
+{
+ usb_disable();
+
+ // RX LED for debug
+ DDRB |= (1<<0);
+
+ Serial.begin( 115200 );
+ while (!Serial) ;
+
+ delay( 1000 );
+
+ Serial.println("Start");
+
+ if (Usb.Init() == -1) {
+ Serial.println("OSC did not start.");
+ }
+
+ delay( 200 );
+
+ kbd.SetReportParser(0, (HIDReportParser*)&Prs);
+}
+
+void loop()
+{
+ Usb.Task();
+}
+
+int main(void)
+{
+ // arduino/wiring.c(Timer initialize)
+ init();
+
+ setup();
+
+ for (;;) {
+ loop();
+ }
+
+ return 0;
+}