07-06-2017, 09:00 PM
(This post was last modified: 07-06-2017, 11:22 PM by MarkHaysHarris777.)
Important Update !
The previous posts in this thread have been updated ( including the scripts|codes ) to make the gpio# calculation from the pad names general and applicable to all the gpio pad names! If you have copied the name2gpio.sh script above, please update your code. These scripts will be included in a new release soon.
In the pic above the example being shown is gpio physical pin(10) on the PI P5+ bus; GPIO2_B7; which happens to be the I2S MCLK. This is important to note, that if you're not going to be using I2S, then you have at your disposal nine(9) additional gpio(s) (Green) on the PI P5+ bus!
./name2gpio.sh gpio2_b7
79
physical pin(10), gpio2_b7, is gpio79
name2gpio.sh
Important Notice:
It is your responsibility to ensure that your pad calculation is accurate (as in all calculations) every effort has been made to ensure accuracy and accountability; however, if you should make an error, the calculation may affect a mux outside the intended target register causing adverse effects, including but not limited to destruction of data and temporary loss of the system. Particularly make sure the spelling of your gpio name designation is correct (garbage in garbage out); also be careful -- measure twice, cut once ( and any other sayings your can remember from your youth ).
marcus
The previous posts in this thread have been updated ( including the scripts|codes ) to make the gpio# calculation from the pad names general and applicable to all the gpio pad names! If you have copied the name2gpio.sh script above, please update your code. These scripts will be included in a new release soon.
In the pic above the example being shown is gpio physical pin(10) on the PI P5+ bus; GPIO2_B7; which happens to be the I2S MCLK. This is important to note, that if you're not going to be using I2S, then you have at your disposal nine(9) additional gpio(s) (Green) on the PI P5+ bus!
./name2gpio.sh gpio2_b7
79
physical pin(10), gpio2_b7, is gpio79
name2gpio.sh
Code:
#!/usr/bin/python3
import sys
import string
pads={"A":0,"B":1,"C":2,"D":3}
def convert(value):
value = value.upper()
bank_num = int(value[4:5], 10)
pad_nam = pads[value[6:7]]
pad_num = int(value[7:], 10)
gpionum = (bank_num * 32) + (pad_nam * 8) + pad_num
return gpionum
if __name__ == "__main__":
args = sys.argv[1:]
if not args:
print("Usage: %s <bank_reg> ie; GPIO3_A5" % sys.argv[0])
sys.exit(1)
print("%d" % convert(args[0]))
It is your responsibility to ensure that your pad calculation is accurate (as in all calculations) every effort has been made to ensure accuracy and accountability; however, if you should make an error, the calculation may affect a mux outside the intended target register causing adverse effects, including but not limited to destruction of data and temporary loss of the system. Particularly make sure the spelling of your gpio name designation is correct (garbage in garbage out); also be careful -- measure twice, cut once ( and any other sayings your can remember from your youth ).
marcus
marcushh777
please join us for a chat @ irc.pine64.xyz:6667 or ssl irc.pine64.xyz:6697
( I regret that I am not able to respond to personal messages; let's meet on irc! )
please join us for a chat @ irc.pine64.xyz:6667 or ssl irc.pine64.xyz:6697
( I regret that I am not able to respond to personal messages; let's meet on irc! )