07-06-2017, 04:59 AM
(This post was last modified: 07-06-2017, 09:07 PM by MarkHaysHarris777.)
In the above pic I've changed the configuration of the LED a bit (not important) and I've selected a new gpio pin#;
... this time I'm going to select physical pin(22) which is (from the chart) GPIO3_A7. We could calculate this manually; however, longsleep wrote a small script for the PineA64 which I have modified for the Rock64 which will calculate the gpio number from the BANK_REG value-- in this case from GPIO3_A7.
./name2gpio.sh gpio3_a7
103
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]))
Note: The name GPIO3_A7 is the bank (3) (one of four) and the register offset (7) (one of eight), of pad zero (0). This Python3 script pulls the numbers from the string and converts them to integers for calculation.
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! )