2011-02-20 03:46:02 -05:00
|
|
|
/* PS/2 to USB keyboard converter
|
|
|
|
* 2011/02/20
|
|
|
|
* Copyright (c) 2011 tmk
|
|
|
|
*/
|
2011-01-28 10:44:05 -05:00
|
|
|
/* Name: main.c
|
|
|
|
* Project: hid-mouse, a very simple HID example
|
|
|
|
* Author: Christian Starkjohann
|
|
|
|
* Creation Date: 2008-04-07
|
|
|
|
* Tabsize: 4
|
|
|
|
* Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
|
|
|
|
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
|
|
|
* This Revision: $Id: main.c 790 2010-05-30 21:00:26Z cs $
|
|
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <avr/wdt.h>
|
2011-02-20 03:46:02 -05:00
|
|
|
#include <avr/interrupt.h>
|
|
|
|
#include <util/delay.h>
|
2011-01-28 10:44:05 -05:00
|
|
|
#include "usbdrv.h"
|
2011-02-20 03:46:02 -05:00
|
|
|
#include "oddebug.h"
|
2011-02-02 23:26:44 -05:00
|
|
|
#include "host_vusb.h"
|
2011-02-10 01:51:30 -05:00
|
|
|
#include "keyboard.h"
|
2011-01-28 10:44:05 -05:00
|
|
|
|
2011-02-20 03:46:02 -05:00
|
|
|
|
|
|
|
#if 0
|
2011-02-07 00:59:07 -05:00
|
|
|
#define DEBUGP_INIT() do { DDRC = 0xFF; } while (0)
|
|
|
|
#define DEBUGP(x) do { PORTC = x; } while (0)
|
2011-02-20 03:46:02 -05:00
|
|
|
#else
|
|
|
|
#define DEBUGP_INIT()
|
|
|
|
#define DEBUGP(x)
|
|
|
|
#endif
|
|
|
|
|
2011-01-28 10:44:05 -05:00
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2011-02-07 00:59:07 -05:00
|
|
|
DEBUGP_INIT();
|
2011-01-28 10:44:05 -05:00
|
|
|
wdt_enable(WDTO_1S);
|
|
|
|
odDebugInit();
|
|
|
|
usbInit();
|
2011-02-02 23:26:44 -05:00
|
|
|
|
|
|
|
/* enforce re-enumeration, do this while interrupts are disabled! */
|
|
|
|
usbDeviceDisconnect();
|
|
|
|
uint8_t i = 0;
|
2011-02-20 03:46:02 -05:00
|
|
|
/* fake USB disconnect for > 250 ms */
|
|
|
|
while(--i){
|
2011-01-28 10:44:05 -05:00
|
|
|
wdt_reset();
|
|
|
|
_delay_ms(1);
|
|
|
|
}
|
|
|
|
usbDeviceConnect();
|
|
|
|
|
2011-02-20 03:46:02 -05:00
|
|
|
keyboard_init();
|
|
|
|
|
2011-02-21 01:43:17 -05:00
|
|
|
sei();
|
2011-02-20 03:46:02 -05:00
|
|
|
while (1) {
|
|
|
|
DEBUGP(0x1);
|
2011-01-28 10:44:05 -05:00
|
|
|
wdt_reset();
|
|
|
|
usbPoll();
|
2011-02-20 03:46:02 -05:00
|
|
|
DEBUGP(0x2);
|
2011-02-10 01:51:30 -05:00
|
|
|
keyboard_proc();
|
2011-02-20 03:46:02 -05:00
|
|
|
DEBUGP(0x3);
|
2011-02-15 07:14:55 -05:00
|
|
|
host_vusb_keyboard_send();
|
2011-01-28 10:44:05 -05:00
|
|
|
}
|
|
|
|
}
|