Fixes to keyboard code, making PC-compatible initialization working. #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! First of all, very nice approach using multi-threading.
In my testing I discovered three different issues that preventing the code from working in many PC-compatible systems and making it through the post succesfully. I made only changes related to keyboard part of the code (no mouse fixes yet).
All issues where tested using DEBUG ifdef's and strategically set serial console prints, ommited in these commits.
ISSUE 1
-Testing on: Toshiba Satellite 205CDS, combined keyboard-mouse PS/2 port, mini-DIN connector.
-Problem: This laptop uses the GET DEVICE ID COMMAND to decide if the divice connected is a Keyboard or a Mouse. For some reason the two byte writes for the ID were failing, and because of that the laptop defaulted the device to be a Mouse (and of course that won't work).
-SOLUTION: Adding two While loops to retry the writes as many times as needed solved the problem.
ISSUE 2
-Testing on: Toshiba Satellite 205CDS, combined keyboard-mouse PS/2 port, mini-DIN connector. Possibly affecting more systems.
-Problem: At first power-on the interface was waiting to send 0xAA command in a loop of Write-tries, during PS2Keyboard::begin(). This for some reason caused the interface to miss critical first-hand commands from the laptop, like the GET DEVICE ID discussed above. As a result the laptop was also defaulting the keyboard as a mouse.
-Solution: BAT SUCCESS code (0xAA) should ALWAYS be sent a coulple of houndred of milliseconds after first power up, regardless of bus state. Added a 200ms delay and a ensured write() solved the problem.
ISSUE 3
-Testing on: Intel 486 PC-Compatible desktop system, 5 pin full size DIN connector.
-Problem: For some reason the host wasn't getting the ACKs correctly during the SET/RESET LEDS command. This caused the host to abort initialization and ignore the keyboard from that function in advance.
-Solution: Changed the ACKs to While-Write loops solved the problem. Need testing in more implementations that use LED info, to ensure it's working OK.
Hope this helps. I'm new to GitHub, I'm king of a noob on repositories, so tell me if I'm doing something wrong.
Cheers!