I have some GPIOs I'm using as outputs with code like this:
J2[21].function(PINJ2_21_GPIO);
J2[21] = 1;
I'd like to be able to read the state of these pins, but if I do something like i=J2[21] they change to inputs. I'm using shadow registers to get around this, but I'd like to know if there's an easy way to read the current state of a pin set as an output without switching it to an input?
Question about reading state of GPIO output
Re: Question about reading state of GPIO output
Not really,
You can read the commanded state...
(you did not say what platform and if you running 3.X or 2.X )
J2[21].readBack(); Should give you the current state without changin the drive/direction setting...
You can read the commanded state...
(you did not say what platform and if you running 3.X or 2.X )
J2[21].readBack(); Should give you the current state without changin the drive/direction setting...