Permalink
Browse files

Fixed pinMux set operation so that input now works

Writing 7 to the mux mode file is only for output. For input with no
pulldown, you must write 2F to mux mode file. Thanks to
http://www.nathandumont.com/node/250
  • Loading branch information...
1 parent 0c6eaf5 commit d642d51bb7bc49e7fb7808fc6bf3fbbda607c68c @mrichardson23 committed Jul 2, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 mrbbio.py
View
@@ -158,18 +158,21 @@ def pinMode(pin, direction):
"""pinMode(pin, direction) opens (exports) a pin for use, sets the pinmux, and
sets the direction"""
if pin in digitalPinDef: # if we know how to refer to the pin:
- muxfile = file("/sys/kernel/debug/omap_mux/" + pinMuxDef[pin], "w") # open its mux file
- muxfile.write("7") # put it into mode 7
- muxfile.close
fw = file("/sys/class/gpio/export", "w")
fw.write("%d" % (digitalPinDef[pin])) # write the pin to export to userspace
fw.close()
fileName = "/sys/class/gpio/gpio%d/direction" % (digitalPinDef[pin])
fw = file(fileName, "w")
if direction == INPUT:
fw.write("in") # write the diretion
+ muxfile = file("/sys/kernel/debug/omap_mux/" + pinMuxDef[pin], "w") # open its mux file
+ muxfile.write("2F") # put it into mode 7 input, no pulldown
+ muxfile.close
else:
fw.write("out") # write the diretion
+ muxfile = file("/sys/kernel/debug/omap_mux/" + pinMuxDef[pin], "w") # open its mux file
+ muxfile.write("7") # put it into mode 7 output)
+ muxfile.close
fw.close()
pinList.append(digitalPinDef[pin]) # Keep a list of exported pins so that we can unexport them.
else: #if we don't know how to refer to a pin:

1 comment on commit d642d51

What would it take to make this compatible with Linux 3.8.x on the BeagleBone Black?

Please sign in to comment.