??? 07/16/06 00:35 Read: times |
#120326 - re: autodetect Responding to: ???'s previous message |
Onyau Chan said:
Did anyone know how to auto-detect USB and PS2? I have a project to build a dual interface keyboard using normal 8051 MCU and a Philips SIE, PDIUSBD12. I can use any 2 pin to do the PS2 interface. The first step needs to detect the interface. If it is USB, I will enable the SIE. Otherwise, the SIE will remain disabled. Did anyone know how to detect the USB signal with MCU? First: those little gizmos that come with USB mice and keyboards that let you attach the device to a PS/2 port are passive. They just provide pass-through for the two signal wires and the power and ground wires. When connected to a USB port those signals are called D+ and D-, when connected to a PS/2 port, those signals are called CLK and DATA. Second: the devices that support this feature have micros that allow one to use port pin as regular I/O or as a USB port. Unless your micro has such a feature (I know SiLabs parts don't and I'm too lazy to look up Microchip or anyone else's parts), then you'll need to connect each of the two data pins to two ports on the micro, one being the relevant USB pin (D+ or D-) and the other being a GPIO bit. Anyways: you know that both types of port provide +5V, so when you plug in your device you get power. You should also know that the PS/2 clock line from the computer should start running as soon as the computer is powered up. Contrast that with USB, where D+ and D- from the computer are high-impedance (but pulled down with 15 K resistors) until the device is attached. So it should be pretty easy to detect whether or not the clock is running; if so, then the micro should start running it's "I'm on the PS/2 port" stuff. If the micro doesn't see the clock, then it should get itself set up to do USB, and when ready, it should pull up either D+ or D- (depending on desired bus speed), at which point the USB hub will detect the attach and enumerate the device, and the device should be running it's "I'm a USB device" firmware. Also: forget about bit-banging USB. Get a micro that has a proper USB serial interface engine. -a |