For something so common, I can't seem to find anything online on what a microcontroller pin "looks like" (besides a high-level voltage source when output, open-circuit when input). So I decided to just do it myself - let me know what you think. Obviousy specs as per transistor characterstics, pull-up value, etc. aren't important for this.
State (Input or Output):
- When 0V, input (just like code), Q1 is off and output voltage is disconnected
- When 3.3V, output (just like code), Q1 is on and output voltage is connected to the pin
- When 0V, low, outputs 0 volts (duh)
- When 3.3V, high, outputs 3.3 volts (duh)
- Only makes it to the pin if state is high
- High-Input impedance straight into gate
- If 0V, Q4 is off and so "input" port will read 0V or low
- If 3.3V, Q4 is on and so "input" port will read 3.3V or high
Pull-Up / Pull-Down
- If they are 3.3V, connects the pin to a pull-up or pull-down resistor.
- If they are 0V, FET is off and so the resistor is floating there not affecting the circuit
Thoughts? In terms of anything maybe missing / unnecessary. The state and pull-up N-Fets probably aren't necessary - they are just there to make the logic not inverted and the system easier to understand.