-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
Hi,
I hit a problem with a IBM SK8820 keyboard and a ATmega32U4 based arduino clone (Sparkfun Pro Micro) with current master from this repo (commit 7294fea).
If I call setLock(0xF); or any values > 0x7, I will hang forever.
Here a minimal example and it's trace :
#include <PS2KeyAdvanced.h>
#define PS2_DATA_PIN 4
#define PS2_IRQ_PIN 7
PS2KeyAdvanced ps2kbd;
void setup() {
Serial.begin(115200);
for (int tries=0; !Serial && tries<20; tries++) delay(100);
Serial.println("DEBUG PS2");
ps2kbd.begin(PS2_DATA_PIN, PS2_IRQ_PIN);
ps2kbd_detect_keyboard();
ps2kbd.resetKey(); // Not mandatory, help reproducability of some tests
}
void ps2kbd_detect_keyboard() {
ps2kbd.echo( ); // ping keyboard to see if there
delay( 6 );
uint16_t ps2keycode = ps2kbd.read( );
// BAT is a PS2 protocol keycode to signal that Keyboard self-autotest result is PASSED.
if( (ps2keycode & 0xFF) == PS2_KEY_ECHO || (ps2keycode & 0xFF) == PS2_KEY_BAT ) {
Serial.println( "PS2 keyboard OK.." );
} else {
if( ( ps2keycode & 0xFF ) == 0 ) {
Serial.println( "PS2 keyboard Not Found" );
} else {
Serial.print( "Invalid Code received: 0x" );
Serial.println( ps2keycode, HEX );
}
}
}
void loop() {
Serial.println("loop(): begin");
while ( !ps2kbd.available() ) delay(1);
Serial.println("loop(): ps2kbd.available() > 0");
while ( ps2kbd.available() ) {
uint16_t ps2keycode = ps2kbd.read();
Serial.print("ps2keycode: 0x");
Serial.println(ps2keycode, HEX);
switch (ps2keycode & 0xFF) {
case PS2_KEY_ACK:
case PS2_KEY_BAT:
case PS2_KEY_ECHO:
continue;
default:
// This will hang the PS2 keyboard functionnalities after first (real) key press
ps2kbd.setLock(0xF);
}
}
Serial.println("loop(): ps2kbd.available() == 0");
}
/* Serial trace of this with IBM SK8820 keyboard and ATmega32U4 based arduino clone (Sparkfun Pro Micro)
14:13:19.888 -> DEBUG PS2
14:13:19.888 -> PS2 keyboard OK..
14:13:19.888 -> loop(): begin
14:13:19.888 -> loop(): ps2kbd.available() > 0
14:13:19.888 -> ps2keycode: 0xFA
14:13:19.888 -> loop(): ps2kbd.available() == 0
14:13:19.888 -> loop(): begin
14:13:20.288 -> loop(): ps2kbd.available() > 0
14:13:20.288 -> ps2keycode: 0xAA
14:13:20.288 -> loop(): ps2kbd.available() == 0
14:13:20.288 -> loop(): begin
# Then I pressed PS2_KEY_U (0x55) on the keyboard
14:13:32.721 -> loop(): ps2kbd.available() > 0
14:13:32.721 -> ps2keycode: 0x55
14:13:32.721 -> loop(): ps2kbd.available() == 0
14:13:32.721 -> loop(): begin
14:13:32.721 -> loop(): ps2kbd.available() > 0
14:13:32.721 -> ps2keycode: 0xFA
14:13:32.721 -> loop(): ps2kbd.available() == 0
14:13:32.721 -> loop(): begin
# Then here, anything works with the PS2 keyboard, Verr.Num don't set the LED, ps2kbd.available() never eval to > 0 again
*/Metadata
Metadata
Assignees
Labels
No labels