![](/media/cache/profiles/1006ff12c465532f8c574aeaa4461b16.50x50_q85.jpg)
A test program for PS2 library.
main.cpp
- Committer:
- shintamainjp
- Date:
- 2010-09-13
- Revision:
- 1:e5eac8a97060
- Parent:
- 0:aabf6427c82e
- Child:
- 2:b06d5cea5b11
File content as of revision 1:e5eac8a97060:
/** * Test program. * * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) * http://shinta.main.jp/ */ #include "mbed.h" #include "PS2_Reader.h" #include "PS2_Writer.h" Ticker tick; DigitalOut led(LED1); void func_tick() { led = !led; } int main() { tick.attach_us(&func_tick, 200 * 1000); { PS2_Writer ps2ms_write(p15, p16); ps2ms_write.write(0xff); ps2ms_write.write(0xff); ps2ms_write.write(0xff); ps2ms_write.write(0xf3); ps2ms_write.write(0xc8); ps2ms_write.write(0xf3); ps2ms_write.write(0x64); ps2ms_write.write(0xf3); ps2ms_write.write(0x50); ps2ms_write.write(0xf4); } PS2_Reader ps2kb(p11, p12, PS2_Reader::TIMEOUT_US_KEYBOARD); PS2_Reader ps2ms(p15, p16, PS2_Reader::TIMEOUT_US_MOUSE); uint8_t buf[1024]; while (1) { /* * Keyboard. */ const int nkb = ps2kb.read(buf, sizeof(buf)); if (0 < nkb) { printf("KB[%02d]:", nkb); for (int i = 0; i < nkb; i++) { printf("%02X ", buf[i]); } printf("\n"); } /* * Mouse. */ const int nms = ps2ms.read(buf, sizeof(buf)); if (0 < nms) { printf("MS[%02d]:", nms); for (int i = 0; i < nms; i++) { printf("%02X ", buf[i]); } printf("\n"); } wait_ms(20); } }