Core 9G25 driving GPIO

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

Moderator: nferre

Posts: 14
Joined: Tue Dec 09, 2014 9:59 am

Core 9G25 driving GPIO

Mon Oct 12, 2015 9:06 am

Hello, i have a problem with managing gpio by Python. I installed Python ablib, smbus. If i try manage gpio by shell command then everything is ok but not by Python and no error appears. Could you help me what i have to check ?
I use kernel 3.6.9 and Buildroot 2015.08.1

This is working:
# cd /sys/class/gpio/
# echo "22">export
# echo "out">gpio22/direction
# echo "1">gpio22/value
# echo "0">gpio22/value
# echo "22">unexport
Python code not. I do know why because no error eppears.
from ablib import Pin

led = Pin('W9','OUTPUT')
Posts: 14
Joined: Tue Dec 09, 2014 9:59 am

Re: Core 9G25 driving GPIO

Tue Oct 13, 2015 10:03 am

Issue is solved.
I found the bug in ablib module.

Kernel 3.6.9 is not legacy = it means python code uses path /sys/class/gpio/pio but this path is not right. Kernel 3.6.9 uses path /sys/class/gpio/gpio.

Code: Select all

def get_gpio_path(kernel_id):
	global legacy_id
	if (legacy_id==True):
		iopath="/sys/class/gpio/gpio%d" % (kernel_id+32)
	if (legacy_id==False):
		if kernel_id>=0 and kernel_id<=31:
			iopath="%sA%d" % (iopath,kernel_id-0)
		if kernel_id>=32 and kernel_id<=63:
			iopath="%sB%d" % (iopath,kernel_id-32)
		if kernel_id>=64 and kernel_id<=95:
			iopath="%sC%d" % (iopath,kernel_id-64)
		if kernel_id>=96 and kernel_id<=127:
			iopath="%sD%d" % (iopath,kernel_id-96)
		if kernel_id>=128 and kernel_id<=159:
			iopath="%sE%d" % (iopath,kernel_id-128)
	return iopath	

Return to “LINUX”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest