I am trying to access gpio's from userspace in c++.
Toolchain = the one downloaded from narcissus.
Best i can come up with is
system("echo 133 > /sys/class/gpio/export");
SleepMS(5);
File* fdrdy = fopen ("/sys/class/gpio/gpio133");
int DRDY
for ( int i = 0 ; i < 10000 ; )
{
DRDY = fgetc(fdrdy);
fseek(fdrdy,0,SEEK_SET);
if(DRDY == '0')
{
... the variable i is incremented here..
}
}
I just want to read the status of a gpio.
If its 0, run this code. Or keep polling. Until its zero.
Then run the code. That's all.
I used uboot to mux it. Set its direction as output.
Is there a better way to do this than the code above?
Read somewhere about gpiolib.
But i cant find linux/gpio.h in my toolchain's folder.
:s
Am i missing some basic thing here?
p.s. My beagle isn't handy atm. So this code might be wrong. Haven't
actually tested it. It should work i think...