Access GPIO/PORTS in mini2440

Sepp bauer 2009-12-19 23:18:39 Link
Hi There,

Im Trying to access the GPIO using c++

Whenever i try to set any register the programm fails droping the error
"Segmentation fault" .. i use teh addresses.h i found in the kernel
directory, 

does anybody have any idea how to access the GPIO?

what im actually trying to do is to set the Register for the internet
serial port for the RTS signals.

Does anybody have any c/c++ examples how to access the GPIO/any other port
on the mini 2440 using the arm linux

Kindest regards
Sepp

gene.sally 2009-12-22 19:53:50 Link
Hi Sepp,

I've wimped out with the GPIO ports and I'm using the /sys file system to
handle communicating with this for me.  I did a little set-up in the
board's specific start-up code to put things in the right state, but after
that, I've used what's available in /sys to handle this for me, because
it's adequate for my application.

Anyway, here's what I did:

1- get gpio information
You can echo into /sys/class/gpio/export the GPIO number you want exported,
but to do this, you'll need to know the GPIO bank's "base".    Here's the
cheap way of finding the "base" numbers for the G

$ cd /sys/class/gpio
$ for i in gpiochip* ; do echo `cat $i/label`: `cat $i/base` ; done
GPIOA: 0
GPIOE: 128
GPIOF: 160
GPIOG: 192
GPIOH: 224
GPIOB: 32
GPIOC: 64
GPIOD: 96

2- Calc your gpio #
If you want line 1 from GPIOE, you would add 1 to the base of GPIOE, in
this case that would equal 129

3- Echo your gpio # into 

Then you echo the number into /sys/class/gpio/export

$ echo 129 > /sys/class/gpio/export

The kernel will create a directory

/sys/class/gpio/gpio166

which contains files for the direction and value of the GPIO.  Not all of
the GPIO lines can be reached this way (I haven't investigated enough to
know why...) You can then read and write to that file like any other file.

You may need to do something more complex, but this is what worked for my
application, where I could poll the file to get the state of the GPIO and
write to it occasionally.

Regards,
gene

h4med 2010-04-04 07:01:10 Link
Hi gene.sally
Would you please write the C program that dose what you say (changing a
GPIO status).
I've seen this:
http://www.avrfreaks.net/wiki/index.php/Documentation:Linux/GPIO
but it isn't for mini2440 and dose not work...

loffe 2010-04-09 15:02:54 Link
Hi Sepp, perhaps you can  use mmap() function for accessing GPIO.

raghu 2010-09-03 09:25:20 Link
Hi ALL Please send me sample code to access GPIO's of MINI2440. how  should
i access them using system calls or by drivers ..please help me out 
thanks 
raghu

Andreo 2010-09-03 10:27:06 Link
I am about to develope a opensource solution:
https://sourceforge.net/projects/gpiolib

i will be finish in a few weeks.

But the driver must be installed with re-compilation of kernel

greetings

Reply

Name
eMail (not visible)
Subject (no text only in upper case; no HELP, URGENT...)
Text
HTML tags are not supported and links are generated automatically if they start with http or ftp.
Please submit long source code or log files as attachment (only registered users).
Please enter the number 6875