GPIO LED blinker using SYSFS on the Rock64
#2
   

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    Cool

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! )


Messages In This Thread
RE: GPIO LED blinker using SYSFS on the Rock64 - by MarkHaysHarris777 - 07-06-2017, 04:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Disable MicroSD reader for extra GPIO mxruben 0 618 07-27-2024, 10:08 PM
Last Post: mxruben
  Rock64 No Audio @ Debian 12 dmitrymyadzelets 2 1,587 04-08-2024, 06:47 AM
Last Post: dmitrymyadzelets
  OpenWRT on the Rock64 CanadianBacon 14 12,835 04-03-2024, 08:48 AM
Last Post: helpmerock
  Rock64 bricked shawwwn 7 8,035 03-17-2024, 12:22 PM
Last Post: dmitrymyadzelets
  Rock64 won't boot luminosity7 10 7,461 03-16-2024, 08:33 AM
Last Post: dmitrymyadzelets
  Rock64 doesn't boot dstallmo 1 1,066 03-16-2024, 08:29 AM
Last Post: dmitrymyadzelets
  How well does Rock64 deal with HDR and Atmos on Kodi? drvlikhell 3 3,434 04-29-2023, 04:24 AM
Last Post: newestssd
  Rock64 board not working, no HDMI no Ethernet. EDited 3 4,850 01-17-2023, 02:31 PM
Last Post: Flagtrax
  ROCK64 v3 can it boot from USB? Tsagualsa 4 3,694 11-29-2022, 11:31 AM
Last Post: Macgyver
  rock64 v3 spiflash Macgyver 0 1,437 11-28-2022, 02:18 PM
Last Post: Macgyver

Forum Jump:


Users browsing this thread: 1 Guest(s)