Still testing it, as it can be finicky when it comes to timing. But I have a small test here:
and the extension itself is at https://github.com/gbraad/pxt-ps2-controller
It depends on another extension that handles the reversing of the bits, as the SPI communication of mbed is not configurable to be LSB first, like the PS2. It only does MSB and since the nRF51 is a Cortex-M0 there is no rbit
functionality either… hence, https://github.com/gbraad/pxt-reversebit to perform rbit
or rbuffer
based on a table.
The extension is finicky. If something slows down, due to serial communication or showing leds, the communication with the controller could get lost/out of sync. I am still trying to see what can be done to improve this, and perhaps have to use the interval
extenstion I created? Feedback is much appreciated.