LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   Invoking GPIO's of ARM controller (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/invoking-gpios-of-arm-controller-842983/)

aneeshradhakrishnan85 11-08-2010 03:27 AM

Invoking GPIO's of ARM controller
 
Hi all,

Can anyone tell me how to access the GPIO's or other peripherals in ARM9 which runs Linux kernel 2.6.XX. Any steps or documentation or suggestions most welcome.

Thanks in advance

PehJota 11-08-2010 07:15 AM

Well you haven't given any specifics here. Are you looking to do this in a programming language? If so, which one? Or are you looking to do this from a shell?

The best documentation that I've found for doing this in C is from the kernel documentation itself: Documentation/gpio.txt. If I remember right, you must first request a GPIO pin (gpio_request()), then set its direction (gpio_direction_input() or gpio_direction_output()). If you want to send output, then you can just use gpio_set_value(). If you want to receive input when the state changes, you can map the GPIO to an IRQ number (gpio_to_irq()) and use that number with request_irq() to set a handler. Finally, remember to call gpio_free() to release the GPIO pin.

You may also find this documentation to be a good reference, but it relies heavily on the sys filesystem rather than on the kernel API, so I'd suggest only using it to test GPIO access from a shell rather than in an actual program.

aneeshradhakrishnan85 11-08-2010 10:01 AM

I wanted to do programming in C language only. I have no idea about shell programming ..thanks for your support. The documents are useful


All times are GMT -5. The time now is 12:26 AM.