wandboard configuring gpio

Drop in to chat about anything, or just to introduce yourself in the welcome to the board thread!

wandboard configuring gpio

Postby gvr_akp » Tue Sep 22, 2015 11:29 am

Hi All,

I am a newbie in kernel programming, am currently working on a task , writing a driver to control GPIO pins . I have identified JP4 connector and added a LED on gpio91 (JP4.06 => /sys/class/gpio/gpio91 ). After reading many tutorials I have written a simple LKM. This LKM received an input from user space and based on input I am setting gpio like gpio_set_value(91,true) (PS. before calling gpio_set_value, I am calling one more function i.e gpio_direction_output) and thus led is glowing .On the other hand when I am getting other command from user space to get status of PIN (for this I am relying on gpio_get_value(91) and for this also setting direction to input) ,here I am not getting proper value.

Am I missing any step to get desired value ? How should I attempt doing this?

Thanks
Anand
gvr_akp
 
Posts: 1
Joined: Tue Sep 22, 2015 11:07 am

Re: wandboard configuring gpio

Postby jury093 » Tue Sep 22, 2015 5:13 pm

gvr_akp wrote:On the other hand when I am getting other command from user space to get status of PIN (for this I am relying on gpio_get_value(91) and for this also setting direction to input) ,here I am not getting proper value.

Hi Anand!
How you get value of gpio91 in user space?
You have three variants:
1. see directly from registers over mmap
2. echo 91 > sysfs structure
3. mount debugfs and see file gpio with gpios mode and state..

if you use N2 - you wrong gpio number for you driver, because if driver get control of gpio, you can't use this gpio in user space..
if you try "get status of PIN" from user program, then you need control result of function
ret=gpio_get_value(91)
if ret<0 then error
jury093
 
Posts: 59
Joined: Fri Feb 06, 2015 10:41 am
Location: Sankt-Peterburg, Russia


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 8 guests