I am trying to control values of GPIO pins from C by writing into memory through mmap, but I reached a dead end and I don’t know what I could be doing wrong.
I read 8KB starting at 0x10005000 and I try to set mode to GPIO (0), direction to OUT (1) and value to 1, but when I try to read the values right after I set it, I get all zeroes, except for direction. When I started, I was successful at writing to values, but now I can’t even do that.
first you write about bpi-r2, right? that matches with gpio-register…but i’m no expert to recalculate the memory address from physical to logical
imho it is not possible to read out values in direction-out-mode…imho only in can be read out can only be set…yes i see in dev-sheet, that the registers are RW…but afair it was not possible to read the value set before
I am able to manipulate with the pin 25 through /sys/class/gpio. I need to export pin 257 (232 base + 25 pin) and I have full control, but I cannot read or write anything through the registers directly. I tried to set the pin HIGH and read the INPUT register with C code, but it didn’t show any change. Command cat /sys/class/gpio/gpio257/value showed the correct number (1).
I changed the memory allocation and now I have this.