jadonk / rowboat

Automatically exported from code.google.com/p/rowboat
0 stars 0 forks source link

Can't read GPIO #115

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I have the following bits of code:
// Setup the pin mux
volatile unsigned long *pinconf;
pinconf = (unsigned long*) mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, 
MAP_SHARED, fd, 0x48000000);
pinconf[0x2158/4] = 0x010C0004;

// Setup the GPIO registers
volatile unsigned long *gpio;
gpio = (unsigned long*) mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, 
fd, 0x49050000);
// Make GPIO_131 input and GPIO_130 output (0 - output, 1 - input)
gpio[0x6034/4] |= (1 << 4);
gpio[0x6034/4] &= ~(1 << 3);
// Set GPIO_130
gpio[0x6094/4] = (1 << 3);

I have a BeagleBoard running Rowboat Froyo and I am running that code in root 
shell. There is a push-button connected between the two GPIO pins. GPIO_130 is 
outputting 1 and GPIO_131 is supposed to be pulled-down input idling low and 
staying high when the button is pressed.

What is the expected output? What do you see instead?

I am trying to poll the state of the button with this code:
if ((gpio[0x6038/4] & (1 << 4)) == 0) {
    printf("Button is up (%X)\n", gpio[0x6038/4]);
} else {
    printf("Button is down (%X)\n", gpio[0x6038/4]);
}

The problem is that the button is always reported up no matter what the actual 
state is. It seems that the output control works (I can both write and read the 
output's state) but the input reading is not affected by the voltage present at 
the pin. I have done measurements with my multimeter and thereby confirmed that 
the signaling works i.e. the output works and the pull-down draws current.

What version of the product are you using? On what operating system?
BeagleBoard rev. B and Rowboat Froyo.

Please provide any additional information below.
I have tried the very same polling in both user-space and kernel-space and 
neighter seems to work for the very same reason.

Original issue reported on code.google.com by antti.ga...@gmail.com on 5 Jul 2011 at 9:54

GoogleCodeExporter commented 9 years ago
I guess this actually isn't the place for reports like this (it's very unlikely 
a system bug but rather my bug) but this was the best source of help I could 
come up with. Thus, please at least tell me where to ask...

Original comment by antti.ga...@gmail.com on 5 Jul 2011 at 9:56

GoogleCodeExporter commented 9 years ago
Problem solved. I hadn't enabled the clocks for GPIO modules due to a 
misunderstanding that such is not necessary.

Original comment by antti.ga...@gmail.com on 12 Aug 2011 at 9:03