philipmathieu
philipmathieu

Reputation: 13

Re-Routing Raspberry Pi GPIO - Dummy Pin?

I am working on porting the open-source project OpenROV for Raspberry Pi. (The project is developed for BeagleBone.) The only significant challenge of the port is changing the software's references to GPIO1_0 (aka GPIO32) to a pin that is open on the Raspberry Pi's header (I'm thinking GPIO18). The original code is as follows:

#!/bin/sh
# GPIO1_0 equals equals /sys/class/gpio32 (32 + 0)

#see http://ninjablocks.com/blog/2012/1/20/setting-up-gpio-on-the-beaglebone.htm l


back_to_normal() {
  sleep 1
  #set GPIO1_0 to HIGH
  echo "high" > /sys/class/gpio/gpio32/direction
}

reset() {
  sleep 1
  #prepare gpio
  echo "32" > /sys/class/gpio/export
  echo "out" >/sys/class/gpio/gpio32/direction 
  echo 7 > /sys/kernel/debug/omap_mux/gpmc_ad0
  #set GPIO1_0 to low
  echo "low" > /sys/class/gpio/gpio32/direction
  back_to_normal 
}
echo Initiating arduino reset 1>&2
reset &

Of course, I could just go through and change very reference to 32 to 18, but this would require additional work with every update. Instead, is there some way to create a dummy GPIO32 that automatically redirects commands to GPIO18?

Upvotes: 1

Views: 798

Answers (1)

WorkingMatt
WorkingMatt

Reputation: 657

I have just started playing around with a Raspberry Pi and its GPIO using Python and RPi.GPIO linux package. I've written about my first simple steps on my blog: Using Raspberry Pi GPIO Interface.

There is a call that sets the mode of RPi.GPIO to BOARD or BCM which changes between two pin configurations by calling GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM). If you look at what that does it may help you with your problem.

Upvotes: 0

Related Questions