Question about reading state of GPIO output

Discussion to talk about software related topics only.
Post Reply
jaypdx
Posts: 29
Joined: Wed Oct 15, 2014 6:06 pm

Question about reading state of GPIO output

Post by jaypdx »

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?
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: Question about reading state of GPIO output

Post by pbreed »

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...
Post Reply