Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PS2 by
Revision 1:f290d8dc0afc, committed 2014-01-24
- Comitter:
- alexanderh
- Date:
- Fri Jan 24 09:47:28 2014 +0000
- Parent:
- 0:62b62530a82f
- Commit message:
- enabled debug prints
Changed in this revision
--- a/PS2KB.cpp Thu Oct 11 20:15:09 2012 +0000
+++ b/PS2KB.cpp Fri Jan 24 09:47:28 2014 +0000
@@ -6,6 +6,7 @@
*/
#include "PS2KB.h"
+//#include "PS2KB_INIT.h"
/**
* Create.
@@ -18,6 +19,7 @@
init_work();
clk.fall(this, &PS2KB::func_fall);
timeout = 1;
+ //PS2KB_INIT::PS2KB_INIT(clk_pin,dat_pin);
}
/**
@@ -33,12 +35,14 @@
* @return A data from a PS/2 device.
*/
int PS2KB::getc() {
+ char str[10];
+
tot.reset();
tot.start();
while (work.cStart == work.cEnd) {
wait_ms(1);
if ((timeout > 0) && (tot.read_ms() > timeout)) {
- // printf("Timeout occured.\n");
+ //printf("Timeout occured.\n");
return EOF;
}
}
@@ -46,7 +50,9 @@
char c = work.buffer[work.cStart++];
work.cStart = work.cStart % RINGBUFSIZ;
-
+
+ //sprintf(str,"GET: %X",c);
+ //printf(str);
return c;
}
@@ -72,9 +78,14 @@
/*
* Start bit.
*/
+
if (dat.read() != 0) {
- // printf("Illegal start bit condition.\n");
- }
+ printf("Illegal start bit condition.\n");
+ // printf("START:0|");
+ }else{
+ //printf("START:1|");
+ }
+
work.bitcnt++;
break;
case 9:
@@ -87,10 +98,13 @@
}
}
if (dat.read() == 1) {
+ //printf("p:1");
oddpar++;
- }
+ }else{
+ //printf("p:0");
+ }
if ((oddpar % 2) != 1) {
- // printf("Data parity error.\n");
+ // printf("Data parity error.\n");
}
work.bitcnt++;
break;
@@ -99,14 +113,15 @@
* Stop bit.
*/
if (dat.read() != 1) {
- // printf("Illegal stop bit condition.\n");
+ printf("Illegal stop bit condition.\n");
}
+ // printf("|STOP");
if (work.cStart != ((work.cEnd + 1) % RINGBUFSIZ)) {
work.cEnd++;
work.cEnd = work.cEnd % RINGBUFSIZ;
work.bitcnt = 0;
} else {
- // printf("Buffer overrun.\n");
+ printf("Buffer overrun.\n");
}
break;
default:
@@ -115,8 +130,10 @@
* data bit.
*/
if (dat.read() == 1) {
+ //printf("d:1");
work.buffer[work.cEnd] |= (1 << (work.bitcnt - 1));
} else {
+ //printf("d:0");
work.buffer[work.cEnd] &= ~(1 << (work.bitcnt - 1));
}
work.bitcnt++;
@@ -124,7 +141,7 @@
/*
* Illegal internal state.
*/
- // printf("Illegal internal state found.\n");
+ printf("Illegal internal state found.\n");
init_work();
}
break;
--- a/PS2KB_INIT.cpp Thu Oct 11 20:15:09 2012 +0000
+++ b/PS2KB_INIT.cpp Fri Jan 24 09:47:28 2014 +0000
@@ -11,6 +11,7 @@
*/
PS2KB_INIT::PS2KB_INIT(PinName clk_pin, PinName dat_pin)
: clk(clk_pin), dat(dat_pin) {
+
clk.input();
dat.input();
clk.write(1);
@@ -22,8 +23,10 @@
* 0xF2: Read ID.
* 0xF3: Set typematic rate/delay.
* 0xF4: Enable.
+ * 0xF8 disable autorepeat
*/
- char txdat[12] = "\xFF\xED\x07\xF2\xED\x00\xF3\x20\xF3\x00\xF4";
+ printf("Sending config\n");
+ char txdat[9] = "\xFF\xED\x07\xF2\xF8\xED\x00\xF4";
const int n = sizeof(txdat);
int txerrcnt = 0;
int rxerrcnt = 0;
@@ -42,10 +45,10 @@
}
if (txerrcnt > 0) {
- // printf("TX %d errors occured.\n", txerrcnt);
+ printf("TX %d errors occured.\n", txerrcnt);
}
if (rxerrcnt > 0) {
- // printf("RX %d errors occured.\n", rxerrcnt);
+ printf("RX %d errors occured.\n", rxerrcnt);
}
}
--- a/PS2Keyboard.cpp Thu Oct 11 20:15:09 2012 +0000
+++ b/PS2Keyboard.cpp Fri Jan 24 09:47:28 2014 +0000
@@ -7,15 +7,26 @@
#include "PS2Keyboard.h"
PS2Keyboard::PS2Keyboard(PinName clk_pin, PinName dat_pin)
- : ps2kb_init(clk_pin, dat_pin), ps2kb(clk_pin, dat_pin) {
+ : ps2kb_init(clk_pin, dat_pin), ps2kb(clk_pin, dat_pin)
+{
+}
+
+PS2Keyboard::~PS2Keyboard()
+{
}
-PS2Keyboard::~PS2Keyboard() {
-}
-
-bool PS2Keyboard::processing(keyboard_event_t *p) {
+bool PS2Keyboard::processing(keyboard_event_t *p)
+{
bool emit = false;
const int c = ps2kb.getc();
+
+ char str[10];
+ // if(c != -1) {
+ // sprintf(str,"GOT: %X",c);
+ // printf(str);
+ // }
+
+
if (0 <= c) {
scancode[count++] = c;
switch (count) {
