run config-pin to set pin mux for qep

This commit is contained in:
Drew Fustini 2017-06-10 02:21:46 +00:00
parent 3f52797bfc
commit bdd3ed493e

View file

@ -52,6 +52,7 @@
# config-pin P8.42 qep
# cat /sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position
from subprocess import call
import os
class QEP :
@ -99,7 +100,25 @@ class RotaryEncoder(object):
EQEP1 = 1
EQEP2 = 2
EQEP2b = 3
def config_pin(self, pin):
'''
config_pin()
Config pin for QEP
'''
result = call(["config-pin", pin, "qep"])
print "config_pin> pin={0} result={1}".format(pin, result)
return result
def cat_file(self, path):
'''
cat_file()
Print contents of file
'''
result = call(["cat", path])
print "cat_file> path={0} result={1}".format(path, result)
return result
def __init__(self, eqep_num):
'''
RotaryEncoder(eqep_num)
@ -108,6 +127,58 @@ class RotaryEncoder(object):
eqep_num can be: EQEP0, EQEP1, EQEP2 or EQEP2b based on which pins \
the rotary encoder is connected to.
'''
print ">>>>>>>> TEST CALL BEGIN"
###################################
print ">>>>>> eqep0: P9_27, P9_92"
pin = "P9_27"
self.config_pin(pin)
pin = "P9_92"
self.config_pin(pin)
path = "/sys/devices/platform/ocp/48300000.epwmss/48300180.eqep/position"
self.cat_file(path);
###################################
print ">>>>>>> eqep1: P8.33, P8.35"
pin = "P8.33"
self.config_pin(pin)
pin = "P8.35"
self.config_pin(pin)
path = "/sys/devices/platform/ocp/48302000.epwmss/48302180.eqep/position"
self.cat_file(path);
###################################
print ">>>>>>> eqep2: P8.11, P8.12"
pin = "P8.11"
self.config_pin(pin)
pin = "P8.12"
self.config_pin(pin)
path = "/sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position"
self.cat_file(path);
###################################
print ">>>>>>> eqep2b: P8.41, P8.42"
pin = "P8.41"
self.config_pin(pin)
pin = "P8.42"
self.config_pin(pin)
path = "/sys/devices/platform/ocp/48304000.epwmss/48304180.eqep/position"
self.cat_file(path);
###################################
print ">>>>>>>> TEST CALL END"
print("RotaryEncoder(): eqep_num: {0}".format(eqep_num))
print("RotaryEncoder(): self._eqep_dirs[0]: {0}".format(self._eqep_dirs[0]))
print("RotaryEncoder(): self._eqep_dirs[1]: {0}".format(self._eqep_dirs[1]))
@ -117,7 +188,7 @@ class RotaryEncoder(object):
self.base_dir = self._eqep_dirs[eqep_num]
print("RotaryEncoder(): self.base_dir: {0}".format(self.base_dir))
self.enable()
def enable(self):
'''
enable()