A bit of context: I am making a sort of digital modular toy, where the player can connect modules freely. Each module does a function such as storing a variable or making a math operation over the value that receives. A bit like a physical programming language. These modules have many inputs, and one output. They can be connected in any way, so what happens with the system is defined by how these things are connected together. I expect it to work like a modular synthesizer, but using digital signals. So each module doesn't care of the ID or function of the parent, but only about what numbers he sends. They will be probably fixed 3 or 4 byte bessages.
The approach I was thinking, is that each input is a register in a multiplexor. The multiplexor common input is the AVR's RX pin. While in idle mode, each module is scanning his multiplexor inputs, waiting for an incoming message flag. When a module has a message to communicate it's 'child' module, it sets a flag (raises or lowers the voltage) in it's own TX. This child AVR is scanning the multiplexor, and when it finds that in a port, the level is raised, it raises it's TX pin aswell, letting it's parent know that he is listening, and so this parent AVR can start sending his serial.
For this, I need that the AVR will be switching the use of a same pin for both, digital reading of the flag, and serial reading. * Will this work, or will it get hairy? * is this a proper way of doing this kind of custom communication protocols? * Where does one learn the proper way of making MCU's commuinicate?
(Please don't suggest using I2C, because the data is very short, the bus is not shared, I don't want ACK and units are not aware of other unit's Id's as they are dynamically connected and disconnected)
Thanks for reading, regardless of wether you have an answer :)