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