Lessons from the Macintosh ADB bus (keyboard)
Posted: Wed Nov 23, 2022 7:09 pm
IIGS/Macintosh users seem to have taken the plunge to reverse engineer the original code to implement the ADB bus. I thought maybe there's some lessons that can used for the X16 keyboard interfacing..
https://68kmla.org/bb/index.php?threads/mac-se-adb-controller.38363/#post-415047 - Mac SE ADB Controller (2021-07-06)
Scott Squires:
"This is the firmware extracted from the ADB controller chip (342S0440-B) from a Mac SE. The chip is a PIC16CR54."
tashtari:
"The firmware does not make use of the PIC16F54's built-in timer and only uses the instruction clock for timing. It also does not use the watchdog timer, and hence doesn't make use of the OPTION register at all."
"looks like the code is meant to accept a lot of variance in the device's timing."
"The firmware uses the uppermost eight bytes of its teensy twenty-five-byte SRAM as a data buffer (ADB frames contain a maximum of eight bytes)."
"Based on usage, I'm reasonably sure that pins 8, 9, and 10 (RB2, RB3, and RB4; CB1, CB2, and PB3 from the VIA according to the bomarc schematic) are outputs from the PIC, and that pins 17 and 18 (RA0 and RA1; PB4 and PB5 from the VIA according to the bomarc schematic) are inputs to the PIC."
"Looking at the code some more, based on the timing in sending the '1' start bit, I think the external clock is 2 MHz exactly.
Also, further confusing the issue about the data direction registers, there are a pair of subprograms that ostensibly clock a byte into and out of the VIA using the same pin in both directions (pin 9, RB3, CB2 on the VIA). I had previously thought this was an output. This doesn't make sense unless the PIC's GPIO ports are open-collector - a 1 meaning let float and a 0 meaning pull to ground."
"The MiST project has an implementation of the ADB controller wired up to a model of the VIA. "
https://github.com/mist-devel/plus_too/blob/master/adb.v
"here it is, a working port of the Mac SE ADB controller to the PIC16F88, and thusly a pin-compatible drop-in replacement."
https://68kmla.org/bb/index.php?threads/mac-se-adb-controller.38363/post-458217
Pinout:
https://en.wikipedia.org/wiki/Apple_Desktop_Bus
Theoretical speed is 125 kbit/s over the single bi-directional wire used in half-duplex operation though.