How to find out a register contains inputs or outputs or both?
How to find out a register contains inputs or outputs or both?


By reading the register reference manual.

If the only thing you can do is read and write registers, there's no way to tell the difference between the following three cases, all of which are reasonably common:


a read-only bit that's currently zero
a bit that's unused and always reads as zero
a bit that's write-only and reads as zero


Worse, writing the wrong values to some registers may have unwanted, and possibly irreversible, effects on the peripheral.