GPIO

Started by kgolding, July 03, 2013, 01:29:21 AM

Previous topic - Next topic

kgolding

Hello,

I want to add 4 inputs and 2 outputs to my A10S board. But I am somewhat of a newbie with Olimex hardware and was looking for some pointers as to what pins to use, and how to configure and read/write to them from a script running on Debian please?

My plan is to use optoisolators for the inputs, and a transistor to drive small relays for the outputs. But at this stage I just want to breadboard it and get a switch and an led working.

Kevin

martinayotte

#1
Hi Kevin,

I didn't personally tried it, but earlier in this forum, we can see this URL :

https://pypi.python.org/pypi/pyA10S/0.1.2

There is also ways to do the same in bash script, a bit like on the Raspberry using the /sys/class/gpio tree.

I've just gave it a try few minutes ago with the small green Led1 :

According to schematic, the LED1 is connected to PE3(gpio21_pe3) and the page http://olimex.wordpress.com/2013/06/19/building-linux-for-a10s-from-scratch/

root@A10s:~# echo out > /sys/class/gpio/gpio21_pe3/direction
root@A10s:~# echo 1 > /sys/class/gpio/gpio21_pe3/value
root@A10s:~# echo 0 > /sys/class/gpio/gpio21_pe3/value

kgolding

Thank for the reply. I've got the green LED flashing at my command which is great, but... I don't understand why it is working given the following:

I have a Rev C A10S board, and the schematic shows LED1 being driven by PIN37, and then PIN37 is shown as being connected to G19 with a description starting "PE3...".

So, is the PE3 in "/sys/class/gpio/gpio21_pe3" the important bit?

To try an answer my own question I wired an LED and resistor to header GPIO-2 pin 26, which has the signal name PIN29 and processor pin F20. The schematic shows F20 with the label starting "PE4...". I found a gpio directory "gpio22_pe4" so I then did the following commands and it worked, flashing my LED as expected :)

root@A10s:~# echo out > /sys/class/gpio/gpio22_pe4/direction
root@A10s:~# echo 1 > /sys/class/gpio/gpio22_pe4/value
root@A10s:~# echo 0 > /sys/class/gpio/gpio22_pe4/value
root@A10s:~# echo 1 > /sys/class/gpio/gpio22_pe4/value

So... what does the "22" in gpio22_pe4 refer to?

I'm using an Olimex supplied MicroSD on the default HDMI option - but I can't help but feel the gpio directory names are wrong?

All the best,

Kevin