GPIO LED blinker using SYSFS on the Rock64
#4
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

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]))
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
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, 09:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rock64 No Audio @ Debian 12 dmitrymyadzelets 2 428 04-08-2024, 06:47 AM
Last Post: dmitrymyadzelets
  OpenWRT on the Rock64 CanadianBacon 14 8,671 04-03-2024, 08:48 AM
Last Post: helpmerock
  Rock64 bricked shawwwn 7 5,872 03-17-2024, 12:22 PM
Last Post: dmitrymyadzelets
  Rock64 won't boot luminosity7 10 4,410 03-16-2024, 08:33 AM
Last Post: dmitrymyadzelets
  Rock64 doesn't boot dstallmo 1 397 03-16-2024, 08:29 AM
Last Post: dmitrymyadzelets
  How well does Rock64 deal with HDR and Atmos on Kodi? drvlikhell 3 2,014 04-29-2023, 04:24 AM
Last Post: newestssd
  Rock64 board not working, no HDMI no Ethernet. EDited 3 3,623 01-17-2023, 02:31 PM
Last Post: Flagtrax
  ROCK64 v3 can it boot from USB? Tsagualsa 4 2,208 11-29-2022, 11:31 AM
Last Post: Macgyver
  rock64 v3 spiflash Macgyver 0 790 11-28-2022, 02:18 PM
Last Post: Macgyver
  my rock64 dosen't work rookie_267 0 992 10-07-2022, 07:50 PM
Last Post: rookie_267

Forum Jump:


Users browsing this thread: 1 Guest(s)