July 23, 2024, 16:47
bash Traceback (most recent call last): File "/home/raspberry/radio.py", line 11, in <module> CS = DigitalInOut(board.CE1) ^^^^^^^^^^^^^^^^^^^^^^^ (redacted traceback stuff) File "/usr/lib/python3/dist-packages/lgpio.py", line 458, in _u2i raise error(error_text(v)) lgpio.error: 'GPIO busy'code:
python import time import busio from digitalio import DigitalInOut, Direction, Pull import board import adafruit_rfm9x btnA = DigitalInOut(board.D17) btnA.direction = Direction.INPUT btnA.pull = Pull.UP CS = DigitalInOut(board.CE1) RESET = DigitalInOut(board.D25) spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) iter = 0 def send_data(): global iter print("send %s"%iter) iter+=1 def get_data(): global iter print("get %s"%iter) iter+=1 def main(): try: while True: if not btnA.value: # Button pressed send_data() else: get_data() except KeyboardInterrupt: pass if __name__ == '__main__': main()