aboutsummaryrefslogtreecommitdiff
path: root/protocol/usb_hid/main.cpp
diff options
context:
space:
mode:
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}