Closed Tolmeros closed 5 years ago
Thanks. Have you thoroughly tested it? I no longer have the HW setup to test it, so i have to trust you :-)
Yes. I've tested it on arduino nano 328p
before sending pull request. My arduino sketch is working without differences from original ps2dev lib.
ok :-) BTW can you please explain me what the problems were?
- pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
+ pinMode(pin, OUTPUT);
This might have caused the pin to go HIGH for short period before you've fixed it? Do i understand it correctly?
What was the problem with parity? Was it causing data loss?
The pin always went HIGH for a short time when original code executed. It might not lead to burn out pin on Arduino or host. But, It was more dangerous if interrupts enabled in user code or another libraries. If interrupt happened after pinMode but digitalWrite(pin, LOW) did not have time to execute.
Parity bit is need to check data to damages.
It was correct implemented in write()
. Because host controller will reject "damaged data" .
Also, keyboard must to check parity and reject damaged data (by sending 0xFE
"resend").
Parity calculation was implemented incorrectly in the read()
. It always used LSB for parity calculation but data bits are written to LSB once and further to higher bits. Therefore, parity calculation was wrong.
And it was no comparison calculated parity to received parity bit.
Fixed parity calculation in
read()
method. Some refactoring.