|
1 | | -/* Version V1.0.5 |
| 1 | +/* Version V1.0.6 |
2 | 2 | PS2KeyAdvanced.cpp - PS2KeyAdvanced library |
3 | 3 | Copyright (c) 2007 Free Software Foundation. All right reserved. |
4 | 4 | Written by Paul Carpenter, PC Services <[email protected]> |
5 | 5 | Created September 2014 |
6 | 6 | Updated January 2016 - Paul Carpenter - add tested on Due and tidy ups for V1.5 Library Management |
| 7 | + January 2020 Fix typos, correct keyboard reset status improve library.properties |
| 8 | + and additional platform handling and some documentation |
7 | 9 |
|
8 | 10 | IMPORTANT WARNING |
9 | 11 | |
|
17 | 19 | September 2014 Uno and Mega 2560 September 2014 using Arduino V1.6.0 |
18 | 20 | January 2016 Uno, Mega 2560 and Due using Arduino 1.6.7 and Due Board |
19 | 21 | Manager V1.6.6 |
| 22 | + |
20 | 23 |
|
21 | 24 | Assumption - Only ONE keyboard added to one Arduino |
22 | 25 | - No stream support |
@@ -469,30 +472,28 @@ if( !( _tx_ready & _HANDSHAKE ) && ( _tx_ready & _COMMAND ) ) |
469 | 472 | _ps2mode |= _WAIT_RESPONSE; |
470 | 473 | } |
471 | 474 |
|
| 475 | +// STOP interrupt handler |
| 476 | +// Setting pin output low will cause interrupt before ready |
| 477 | +detachInterrupt( digitalPinToInterrupt( PS2_IrqPin ) ); |
472 | 478 | // set pins to outputs and high |
473 | 479 | digitalWrite( PS2_DataPin, HIGH ); |
474 | 480 | pinMode( PS2_DataPin, OUTPUT ); |
475 | 481 | digitalWrite( PS2_IrqPin, HIGH ); |
476 | 482 | pinMode( PS2_IrqPin, OUTPUT ); |
| 483 | +// Essential for PS2 spec compliance |
477 | 484 | delayMicroseconds( 10 ); |
478 | | -#if defined(ARDUINO_ARCH_SAM) |
479 | | -// STOP interrupt handler as Due etc. a lot faster than Uno/Mega |
480 | | -// Setting pin output low will cause interrupt before ready |
481 | | -detachInterrupt( digitalPinToInterrupt( PS2_IrqPin ) ); |
482 | | -#endif |
483 | 485 | // set Clock LOW |
484 | 486 | digitalWrite( PS2_IrqPin, LOW ); |
| 487 | +// Essential for PS2 spec compliance |
485 | 488 | // set clock low for 60us |
486 | 489 | delayMicroseconds( 60 ); |
487 | 490 | // Set data low - Start bit |
488 | 491 | digitalWrite( PS2_DataPin, LOW ); |
489 | | -// set clock to input_pullup |
| 492 | +// set clock to input_pullup data stays as output while writing to keyboard |
490 | 493 | pininput( PS2_IrqPin ); |
491 | | -#if defined(ARDUINO_ARCH_SAM) |
492 | | -// Restart interrupt handler as Due etc. a lot faster than Uno/Mega |
| 494 | +// Restart interrupt handler |
493 | 495 | attachInterrupt( digitalPinToInterrupt( PS2_IrqPin ), ps2interrupt, FALLING ); |
494 | 496 | // wait clock interrupt to send data |
495 | | -#endif |
496 | 497 | } |
497 | 498 |
|
498 | 499 |
|
@@ -872,7 +873,10 @@ void PS2KeyAdvanced::resetKey() |
872 | 873 | send_byte( PS2_KC_RESET ); // send command |
873 | 874 | send_byte( PS2_KEY_IGNORE ); // wait ACK |
874 | 875 | if( ( send_byte( PS2_KEY_IGNORE ) ) ) // wait data PS2_KC_BAT or PS2_KC_ERROR |
875 | | - send_next(); // if idle start transmission |
| 876 | + send_next(); // if idle start transmission |
| 877 | +// LEDs and KeyStatus Reset too... to match keyboard |
| 878 | +PS2_led_lock = 0; |
| 879 | +PS2_keystatus = 0; |
876 | 880 | } |
877 | 881 |
|
878 | 882 |
|
|
0 commit comments