I too have found a curious gap in the literature about how to program the PIO. Page 225 of the PIO manual gives the programming overview. My project is to use a PIO as a digital to analogue (D-A) converter, and I will be using 8 resistors in a binary weighted array to get 8-bit data bytes to set up the appropriate voltage.
One problem I find as an elderly gent is the presence of jargon in the advice offered all over the web, which shows my ignorance, but for instance, the original poster, like myself, might have no idea what a "bitbang" is and would have to research the term first.
The question would appear to me to involve serial data processing for which the SIO would indeed be a more sensible option. However, since Benjamin has stated exactly what he wants to do, rather than trying to change his direction, I will post the Z80 assembly code for my PIO project here in a few days (when it works!) so he can see my solution.
However, a few hours research later, I now realise that my application is too different from Benjamins so my code would be of little use to him. In looking through the Zilog Z80 PIO Technical Manual, there is a good example of an I/O interface on page 18 which I think would be a place for him to start. I'm guessing that the PS/2 keyboard has a serial data connection, so Benjamin might be able to use the circuit using a single PIO data line as an input to the PIO.
Essentially Benjamin, once you have designed the hardware circuit for the PS/2, you can select an operating mode, most likely Mode 2 (bidirectional) and then
follow the PIO setup sequence in the PIO Technical manual. If you like you could email the relevant schematics to me. I would imagine you would might choose to use interrupts rather than polling although it is a bit more tricky to get working, in which case you would load an interrupt vector to point to the code to be executed by the interrupt service routine. The Zilog Applications book published by Sybex has a load of good stuff in it if you can find one
I think you need to have the Zilog books in front of you to get the hang of it. In essence it is easy, like everything else, once you have done it. With the best will in the world, there's a bit too much to put into a post like this.
Busybee I agree with you. I would have to research the PS/2 keyboard spec to know what his hardware design would look like, but guessing the Zilog circuit could be adapted with minimal work.