controlling pins

This forum is for users of Microchip MPUs and who are interested in using Linux OS.

Moderator: nferre

conger
Posts: 28
Joined: Tue Jul 20, 2004 3:05 am

controlling pins

Sat Mar 05, 2005 1:02 am

hello all,

upon getting Linux up and running on my AT91RM9200-based board, I have realized that I no longer have direct control over the memory-mapper registers, and thus no direct means of driving the pins of the PIO controllers :) Does anyone have a solution for this, to be able to drive individual pins on the PIO ports directly from user-space applications? Are there any PIO drivers with this dist. of Linux (I use v.2.4.19-rmk7)? When I wrote standalone applications, this was of course easy just by using pointers to the proper registers. I use the arm-linux-gcc compiler, with my apps written in C code. Thank you in advance for any advice or experiences.

Conger
Misha
Location: Florence.
Posts: 73
Joined: Mon Nov 22, 2004 4:15 pm

/dev/mem device file.

Fri Jun 17, 2005 4:10 pm

Apart relying on custom drivers, Linux user application can access
whichever memory address (and memory mapped IO as well)
mapping a physical range address to a virtual address range
through the /dev/mem device file.

See the famous devmem.c:

http://www.simtec.co.uk/appnotes/AN0014/files/devmem2.c

Then you can cast the returned virtual address to a pointer of registers structure, and address them in a "transparent "way.

I tested myself this approach: hope this helps....
conger
Posts: 28
Joined: Tue Jul 20, 2004 3:05 am

Sun Jun 19, 2005 5:55 am

Thanks Misha,

I too have come to that conclusion... there is another discussion on a different Forum here which mentions that using the /dev/mem and a mmap() call in the program will give a pointer to the actual registers. This is how I am doing it now, and it is working very well. However, later in the above-mentioned discussion, someone mentioned that this is perhaps 'bad form' or not the intended use of the mmap() function (I am a relative beginner with Linux, and since I have not had any problems result from my use of mmap thus far I don't see what the problem is). They suggested making some kind of ioctl() call, though again since I am no Linux-pro and the mmap() method was easy and effective, I have not looked into the ioctl() thing.

conger

Return to “LINUX”

Who is online

Users browsing this forum: No registered users and 3 guests