File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed
src/adafruit_blinka/microcontroller/allwinner/h618 Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change 4
4
"""Allwinner H618 Pin Names"""
5
5
from adafruit_blinka .microcontroller .generic_linux .libgpiod_pin import Pin
6
6
7
- # gpiochip select
8
- __chip_num = 0
9
- with open ("/sys/class/gpio/gpiochip0/label" , "r" ) as f :
10
- label = f .read ().strip ()
11
- if label == "300b000.pinctrl" :
12
- __chip_num = 1
7
+ def find_gpiochip_number (target_label ):
8
+ try :
9
+ with open ('/sys/kernel/debug/gpio' , 'r' ) as f :
10
+ lines = f .readlines ()
11
+ except FileNotFoundError :
12
+ print ("The file /sys/kernel/debug/gpio does not exist." )
13
+ return None
14
+
15
+ gpiochip_number = None
16
+ for line in lines :
17
+ if target_label in line :
18
+ parts = line .split ()
19
+ for part in parts :
20
+ if part .startswith ('gpiochip' ):
21
+ gpiochip_number = part [len ('gpiochip' ):]
22
+ break
23
+ break
24
+
25
+ return gpiochip_number
26
+
27
+ __chip_num = 1
28
+ __chip_num = gpiochip_number = find_gpiochip_number ("300b000.pinctrl" )
13
29
14
30
PC0 = Pin ((__chip_num , 64 ))
15
31
SPI0_SCLK = PC0
You can’t perform that action at this time.
0 commit comments