diff options
Diffstat (limited to 'ps2_usb/main_vusb.c')
| -rw-r--r-- | ps2_usb/main_vusb.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/ps2_usb/main_vusb.c b/ps2_usb/main_vusb.c new file mode 100644 index 000000000..ec7c5797a --- /dev/null +++ b/ps2_usb/main_vusb.c | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | /* PS/2 to USB keyboard converter | ||
| 2 | * 2011/02/20 | ||
| 3 | * Copyright (c) 2011 tmk | ||
| 4 | */ | ||
| 5 | /* Name: main.c | ||
| 6 | * Project: hid-mouse, a very simple HID example | ||
| 7 | * Author: Christian Starkjohann | ||
| 8 | * Creation Date: 2008-04-07 | ||
| 9 | * Tabsize: 4 | ||
| 10 | * Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH | ||
| 11 | * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) | ||
| 12 | * This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $ | ||
| 13 | */ | ||
| 14 | #include <stdint.h> | ||
| 15 | #include <avr/wdt.h> | ||
| 16 | #include <avr/interrupt.h> | ||
| 17 | #include <util/delay.h> | ||
| 18 | #include "usbdrv.h" | ||
| 19 | #include "oddebug.h" | ||
| 20 | #include "host_vusb.h" | ||
| 21 | #include "keyboard.h" | ||
| 22 | |||
| 23 | |||
| 24 | #if 0 | ||
| 25 | #define DEBUGP_INIT() do { DDRC = 0xFF; } while (0) | ||
| 26 | #define DEBUGP(x) do { PORTC = x; } while (0) | ||
| 27 | #else | ||
| 28 | #define DEBUGP_INIT() | ||
| 29 | #define DEBUGP(x) | ||
| 30 | #endif | ||
| 31 | |||
| 32 | |||
| 33 | int main(void) | ||
| 34 | { | ||
| 35 | DEBUGP_INIT(); | ||
| 36 | wdt_enable(WDTO_1S); | ||
| 37 | odDebugInit(); | ||
| 38 | usbInit(); | ||
| 39 | |||
| 40 | /* enforce re-enumeration, do this while interrupts are disabled! */ | ||
| 41 | usbDeviceDisconnect(); | ||
| 42 | uint8_t i = 0; | ||
| 43 | /* fake USB disconnect for > 250 ms */ | ||
| 44 | while(--i){ | ||
| 45 | wdt_reset(); | ||
| 46 | _delay_ms(1); | ||
| 47 | } | ||
| 48 | usbDeviceConnect(); | ||
| 49 | |||
| 50 | keyboard_init(); | ||
| 51 | |||
| 52 | sei(); | ||
| 53 | while (1) { | ||
| 54 | DEBUGP(0x1); | ||
| 55 | wdt_reset(); | ||
| 56 | usbPoll(); | ||
| 57 | DEBUGP(0x2); | ||
| 58 | keyboard_proc(); | ||
| 59 | DEBUGP(0x3); | ||
| 60 | host_vusb_keyboard_send(); | ||
| 61 | } | ||
| 62 | } | ||
