]> git.friedersdorff.com Git - max/tmk_keyboard.git/blob - main_vusb.c
added copyright and license notice.
[max/tmk_keyboard.git] / main_vusb.c
1 /* Name: main.c
2  * Project: hid-mouse, a very simple HID example
3  * Author: Christian Starkjohann
4  * Creation Date: 2008-04-07
5  * Tabsize: 4
6  * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
7  * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
8  * This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $
9  */
10 #include <stdint.h>
11 #include <avr/wdt.h>
12 #include <avr/interrupt.h>
13 #include <util/delay.h>
14 #include "usbdrv.h"
15 #include "oddebug.h"
16 #include "host_vusb.h"
17 #include "keyboard.h"
18
19
20 #if 0
21 #define DEBUGP_INIT() do { DDRC = 0xFF; } while (0)
22 #define DEBUGP(x) do { PORTC = x; } while (0)
23 #else
24 #define DEBUGP_INIT()
25 #define DEBUGP(x)
26 #endif
27
28
29 int main(void)
30 {
31     DEBUGP_INIT();
32     wdt_enable(WDTO_1S);
33     odDebugInit();
34     usbInit();
35
36     /* enforce re-enumeration, do this while interrupts are disabled! */
37     usbDeviceDisconnect();
38     uint8_t i = 0;
39     /* fake USB disconnect for > 250 ms */
40     while(--i){
41         wdt_reset();
42         _delay_ms(1);
43     }
44     usbDeviceConnect();
45
46     keyboard_init();
47
48     sei();
49     while (1) {
50         DEBUGP(0x1);
51         wdt_reset();
52         usbPoll();
53         DEBUGP(0x2);
54         keyboard_proc();
55         DEBUGP(0x3);
56         host_vusb_keyboard_send();
57     }
58 }