This kind of encoding prevents you from making the programming error of writing to an input pin - which is technically possible, just useless.
This kind of encoding prevents you from making the programming error of writing to an input pin - which is technically possible, just useless.
However, by default, nonsensical operations should not be possible.
I haven't seen that in ARM microcontrollers, but as peripherals vary across manufacturers I don't think you can assume that it's not done this way.
In other cases, you want to avoid glitching when the pin switches to an output on startup.
If there are multiple chips connected in open-drain, you write the I/O pin to 0 or 1 to either ground or float the pin. You read the I/O pin to see if anyone else has grounded it if you haven't. This was called "wired-OR" in the old days. (It's really AND, but was commonly used in DeMorgan equivalent form for communication buses before tri-state drivers became a thing. I'll get my cane and hobble back to my rocking chair now..)