Skip to content

Commit 491b424

Browse files
authored
Add files via upload
lgpio native changes
1 parent fd72983 commit 491b424

File tree

1 file changed

+10
-8
lines changed
  • src/adafruit_blinka/microcontroller/bcm283x

1 file changed

+10
-8
lines changed

src/adafruit_blinka/microcontroller/bcm283x/pin.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55
from pathlib import Path
66
import lgpio
77

8+
89
def _get_gpiochip():
910
"""
1011
Determines the handle of the GPIO chip device to access.
1112
1213
iterate through sysfs to find a GPIO chip device with a driver known to be
1314
used for userspace GPIO access.
1415
"""
15-
for dev in Path('/sys/bus/gpio/devices').glob('gpiochip*'):
16-
drivers = set((dev / 'of_node/compatible').read_text().split('\0'))
16+
for dev in Path("/sys/bus/gpio/devices").glob("gpiochip*"):
17+
drivers = set((dev / "of_node/compatible").read_text().split("\0"))
1718
# check if driver names are intended for userspace control
18-
if drivers & {'raspberrypi,rp1-gpio',
19-
'raspberrypi,bcm2835-gpio',
20-
'raspberrypi,bcm2711-gpio'}:
19+
if drivers & {
20+
"raspberrypi,rp1-gpio",
21+
"raspberrypi,bcm2835-gpio",
22+
"raspberrypi,bcm2711-gpio",
23+
}:
2124
return lgpio.gpiochip_open(int(dev.name[-1]))
2225
# return chip0 as a fallback
2326
return lgpio.gpiochip_open(0)
@@ -60,7 +63,7 @@ class Pin:
6063
lgpio.exceptions = True
6164

6265
def __init__(self, bcm_number):
63-
self.id = bcm_number # pylint: disable=invalid-name
66+
self.id = bcm_number # pylint: disable=invalid-name
6467

6568
def __repr__(self):
6669
return str(self.id)
@@ -76,8 +79,7 @@ def init(self, mode=IN, pull=None):
7679
self._set_gpio_mode_in()
7780
elif mode == self.OUT:
7881
self._mode = Pin.OUT
79-
Pin._check_result(lgpio.gpio_claim_output(CHIP, self.id,
80-
Pin.LOW))
82+
Pin._check_result(lgpio.gpio_claim_output(CHIP, self.id, Pin.LOW))
8183
else:
8284
raise RuntimeError(f"Invalid mode for pin: {self.id}")
8385
if pull is not None:

0 commit comments

Comments
 (0)