The primary concept at play is that you want to merge MOSI and MISO into a single combined TPID signal. The problem is that there's no mechanism to tri-state MOSI when it's the chip's turn to talk. So you connect TPID up to MISO and then connect MOSI to both through a series resistor. Select the resistor so that it's low enough to override any competing impedance on the target board, but not so low that it overrides the output signal from the chip and screws up programming. I've not worked out a value yet, but 330Ω seems a good starting guess.
Additionally, if you use the !RESET disable fuse, you can use the !RESET pin as a 4th general I/O pin. If you do, then to re-enter TPI, instead of driving that pin low, you feed it +12 volts. To do this conveniently, the adapter has a boost converter based on the AP3015 to turn the incoming 5 volt Vcc (TPI programming only works at +5 volts) into 12 volts, and then switch it onto the pin when the incoming !RESET is pulled low. This requires two MOSFETs - one P and one N. The N recognizes when the incoming !RESET pin is pulled down from 5 volts. That output pulls the gate of the P low, which actually switches the 12 volts in.
Because not all targets will be happy about having +12 volts injected, there's a switch on the board so you can select between the original active low !RESET signal and the +12 one.
If you are going to use the !RESET disable fuse, and support in-situ programming, you should insure that your design is tolerant of having +12 volts put there. The best way to do this is to put a reverse-biased diode between that pin (and the programming port) and your circuit, using it as an active-low signal with a pull-up on the other side. Of course when you start jumping through hoops like that, the ATTiny85 starts to look attractive.
The patch to AVRdude in the files section does three things:
- It adds TPI support to the USBTinyISP programmer (this part of the patch is courtesy of David Mosberger).
- It adds Linux SPI support (this part of the patch is courtesy Kevin Cuzner).
- It adds TPI support to the LinuxSPI driver (that's my work, though I took some cues from David's work).
- It cleans up everything relative to avrdude-6.3 and fixes a bug or two (again, me).