2011-02-20 08:46:02 +00:00
|
|
|
/* PS/2 to USB keyboard converter
|
|
|
|
* 2011/02/20
|
|
|
|
* Copyright (c) 2011 tmk
|
|
|
|
*/
|
2011-01-28 15:44:05 +00: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 08:46:02 +00:00
|
|
|
#include <avr/interrupt.h>
|
|
|
|
#include <util/delay.h>
|
2011-01-28 15:44:05 +00:00
|
|
|
#include "usbdrv.h"
|
2011-02-20 08:46:02 +00:00
|
|
|
#include "oddebug.h"
|
2011-02-03 04:26:44 +00:00
|
|
|
#include "host_vusb.h"
|
2011-02-10 06:51:30 +00:00
|
|
|
#include "keyboard.h"
|
2011-01-28 15:44:05 +00:00
|
|
|
|
2011-02-20 08:46:02 +00:00
|
|
|
|
|
|
|
#if 0
|
2011-02-07 05:59:07 +00:00
|
|
|
#define DEBUGP_INIT() do { DDRC = 0xFF; } while (0)
|
|
|
|
#define DEBUGP(x) do { PORTC = x; } while (0)
|
2011-02-20 08:46:02 +00:00
|
|
|
#else
|
|
|
|
#define DEBUGP_INIT()
|
|
|
|
#define DEBUGP(x)
|
|
|
|
#endif
|
|
|
|
|
2011-01-28 15:44:05 +00:00
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
2011-02-07 05:59:07 +00:00
|
|
|
DEBUGP_INIT();
|
2011-01-28 15:44:05 +00:00
|
|
|
wdt_enable(WDTO_1S);
|
|
|
|
odDebugInit();
|
|
|
|
usbInit();
|
2011-02-03 04:26:44 +00:00
|
|
|
|
|
|
|
/* enforce re-enumeration, do this while interrupts are disabled! */
|
|
|
|
usbDeviceDisconnect();
|
|
|
|
uint8_t i = 0;
|
2011-02-20 08:46:02 +00:00
|
|
|
/* fake USB disconnect for > 250 ms */
|
|
|
|
while(--i){
|
2011-01-28 15:44:05 +00:00
|
|
|
wdt_reset();
|
|
|
|
_delay_ms(1);
|
|
|
|
}
|
|
|
|
usbDeviceConnect();
|
|
|
|
|
2011-02-20 08:46:02 +00:00
|
|
|
keyboard_init();
|
|
|
|
|
2011-02-21 06:43:17 +00:00
|
|
|
sei();
|
2011-02-20 08:46:02 +00:00
|
|
|
while (1) {
|
|
|
|
DEBUGP(0x1);
|
2011-01-28 15:44:05 +00:00
|
|
|
wdt_reset();
|
|
|
|
usbPoll();
|
2011-02-20 08:46:02 +00:00
|
|
|
DEBUGP(0x2);
|
2011-02-10 06:51:30 +00:00
|
|
|
keyboard_proc();
|
2011-02-20 08:46:02 +00:00
|
|
|
DEBUGP(0x3);
|
2011-02-15 12:14:55 +00:00
|
|
|
host_vusb_keyboard_send();
|
2011-01-28 15:44:05 +00:00
|
|
|
}
|
|
|
|
}
|