On 14/06/2011 11:31 AM, Cheryl Skibski wrote:
Hi, 
I am a graduate student working on a project with the Gumstix Overo Fire and Tobi Expansion Board. This is my first time working on a Linux embedded computing project ever so help would be much appreciated. 

My task is to create a python code for a GPIO (I was planning on GPIO10). This code will turn the pin high to have a voltage output and then turn the pin low. 

I was doing some testing in the command line with the following prompts: 

echo "10">/sys/class/gpio/export 
echo "out">/sys/class/gpio/gpio10/direction 
echo "1">/sys/class/gpio/gpio10/value 
Measured with an oscilloscope using PIN 15 as GND 
echo "in">/sys/class/gpio/gpio10/direction 
echo "o">/sys/class/gpio/gpio10/value 
Measured with an oscilloscope 

I saw no change when measuring both times. 

I have been reading multiple forums and all of them seem confusing and complicated. All I want to do is turn the pin high. 

For the python code I figured I would be doing something according to these steps to make the pin high: 
open /sys/class/gpio/gpio10/value 
write a 1 to the value 
close 

Thanks in advance 
Cheryl


why change the direction in the middle ?

Have you set the pinconf register using devmem2 first?
devmem2  register_address   word/halfword  value

devmem2 0x480021E2 h 0x10c

See OMAP35x Applications Processor: Technical Reference Manual, Chapter 7 - Tables 7.4, 7.5 and 7.6,  at http://focus.ti.com/lit/ug/spruf98r/spruf98r.pdf

to check for the correct register address

Have a careful read of Scotts page on gpio http://www.jumpnowtek.com/index.php?option=com_content&view=article&id=54&Itemid=60

I've made some quick c versions of the code on his page
http://www.alexthegeek.com/omap/overo/code/

Its fairly trivial to either convert the bash or the c code to python.

I'd suggest using subprocess for the system calls
something like
self.cmd0 = "devmem2 0x480021E4 h 0x10c"
 self.process = subprocess.Popen(self.cmd0, stdout=subprocess.PIPE , shell=True)
 os.waitpid(self.process.pid, 0)[1]
 self.udata = self.process.stdout.read().strip()

Then open and close with exception handling to talk to sysfs for accessing the values.


Alex


UTS CRICOS Provider Code: 00099F
DISCLAIMER: This email message and any accompanying attachments may contain confidential information. If you are not the intended recipient, do not read, use, disseminate, distribute or copy this message or attachments. If you have received this message in error, please notify the sender immediately and delete this message. Any views expressed in this message are those of the individual sender, except where the sender expressly, and with authority, states them to be the views the University of Technology, Sydney. Before opening any attachments, please check them for viruses and defects.