It's certainly possible for a VIA's parallel port to converse bidirectionally with another device. It's mostly just a matter of sorting out the etiquette observed by the two processors so things can go smoothly -- almost like the use of a two-way radio, when each party needs to signal end-of-transmission by saying, "over." This allows you to take turns talking and listening. Obviously things have gone awry if both talk at once, or both listen at once. Also be aware that the "both talk at once" condition means contention on the parallel port lines
-- which will cause overheating of both the VIA and whatever it's talking to. (Had that bug; learned the hard way! Amazing how hot a VIA can get and still survive... !! )
Many effective protocols are possible. In one scenario, one processor is always the boss, responsible for initiating all transfers, both host-to-slave and slave-to-host. So, for example, the ack sent to the AVR could be an actual byte (rather than just a pulse from CA2). The value of the byte would encode one of two possible messages: ordinary "ack," or "ack, but I also have something else to talk about, and I'm waiting for a cue to proceed."
The unused data line could be handy but it's not essential. Just remember that, regardless of what policy you settle on, one processor must let go of the "bus" (the VIA parallel lines) before the other processor commences to drive it. That's the maneuver you'll want to plan first.
If you're willing to install pullup resistors on the bus then matters get somewhat simpler. In that case the VIA and AVR can behave as "open collector" devices. Rather than outputting 0 or outputting 1 on each bit line, they'd output 0 or switch that bit to its input state and let the pullup do its thing. Easier than it sounds. Basically you write your data bytes to the Data Direction Register, and leave the Output Register all zeros. The open collector approach precludes bus contention, eliminating the fried-chip concern entirely. I'm sure the whole thing can be done without relying on the unused data line you mentioned, but using that line may simplify things -- it's your choice.
Another option to consider is the synchronous-serial link (the VIA shift register). That could act as an entirely separate and independent channel, for example to carry all the VIA-to-AVR traffic. The appeal here is that the parallel lines no longer need to switch direction, simplifying matters considerably. Also the shift register has its own interrupt and flag bits, separate from those for the VIA's parallel port. You could create two simple, separate tasks.
My hunch is this may lead to the best solution, so I suggest you give the shift register another try. When the shift-clock pulses are generated by the VIA there are no pitfalls AFAIK, but the modes where the VIA accepts shift-clock pulses from an external source are potentially tricky. You'll find some helpful info on Garth's
web site.
cheers,
Jeff
[Edit: appearance of the VIA SR bug depends on whether the clock pulses are input or output, not whether the serial data is input or output.]
_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html