PS2
Overview¶
PS/2 device is a legacy human interface device.
It's easy to use for input device on micro controller.
So I decided to design the library.
The library use only 2 pins (CLK and DAT).
It use interrupt based receive, so your application codes will simplify.
Feautures¶
- Supported a PS/2 keyboard and a mouse.
- Interrupt based receiver.
- Simple interfaces.
Circuits¶
Projects¶
Library¶
Test program¶
How to use it?¶
PS2Keyboard class¶
#include "mbed.h" #include "PS2Keyboard.h" PS2Keyboard ps2kb(p12, p11); // CLK, DAT int main() { PS2Keyboard::keyboard_event_t evt_kb; while (1) { if (ps2kb.processing(&evt_kb)) { printf("[%d]:", evt_kb.type); for (int i = 0; i < evt_kb.length; i++) { printf("%02x ", evt_kb.scancode[i]); } printf("\n"); } } }
PS2Mouse class¶
#include "mbed.h" #include "PS2Mouse.h" PS2Mouse ps2ms(p23, p22); // CLK, DAT int main() { PS2Mouse::mouse_event_t evt_ms; while (1) { if (ps2ms.processing(&evt_ms)) { printf("%c%c%c:%4d,%4d,%2d\n", evt_ms.left ? 'L' : '.', evt_ms.center ? 'C' : '.', evt_ms.right ? 'R' : '.', evt_ms.x, evt_ms.y, evt_ms.z); } } }
References¶
Limits¶
- Some PS/2 mouses will transmit data high rates. In this case, the internal buffer will overflow.