Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: GPIO using linux-2.6.30 and Buildroot
PostPosted: Fri Apr 22, 2011 1:19 am 
Offline

Joined: Fri Apr 22, 2011 1:04 am
Posts: 1
Location: Washington, DC, USA, Earth
Hi all, this is my first post. I'm very sorry if this question has been answered already, but I've looked all over for the last few weeks with no luck.

I need to wiggle and read GPIO pins on my AT91SAM9260. I'm working with the EK, but will move to a custom board soon. So far I have a root fs built with Buildroot, a resulting uClibc toolchain and a 2.6.30 kernel built using that toolchain. Using SAM-BA, I've flashed AT91Bootstrap, U-Boot and environment variables, my kernel and my fs; I started with the pre-built ones provided here, but finally got new ones to build.

I've read that I can access PIO pins from /sys/class/gpio using the export file. However, when I try to write to it, I get an error message in dmesg. I've also heard that /dev/gpio can be used, but have had no luck in creating that node. Moreover, I've heard of memory mapping the PIO registers but can't find any example code or guidance towards creating my own.

Has anybody ran into this and conquered it? It seems that with the GPIO kernel driver alive it shouldn't be too hard to use GPIO, but this has been eluding me for some time.

Thanks!


Top
 Profile  
 
 Post subject: Re: GPIO using linux-2.6.30 and Buildroot
PostPosted: Mon Apr 25, 2011 7:26 pm 
Offline

Joined: Sun Jan 23, 2011 7:18 pm
Posts: 12
For the sys method, normally you do echo {pin number} > /sys/class/gpio/export
this will cause a node to be created as /sys/class/gpio/gpio{pin number}/* which will have subnodes like direction and value which you can echo output > /sys/class/gpio/gpio{pin number}/direction and like cat 1 > /sys/class/gpio/gpio{pin number}/value to go high.

For the direct memory access method, search for devmem2 on the forums. Its pretty straight forward, mmap the top address (FFFFF000, etc) and read and write to the registers. I'd use the at91lib to figure out the register mapping, the datasheet will show the region but not the individual register addresses.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: