dev #1

Merged
david merged 25 commits from dev into main 2025-04-28 14:20:45 -07:00
2 changed files with 11 additions and 15 deletions
Showing only changes of commit c9469b69cd - Show all commits

View File

@ -3,8 +3,8 @@ from util import *
from receive import receive_packet from receive import receive_packet
debug = True debug = True
GDO0_PIN=23, GDO0_PIN=17
GDO2_PIN=24 GDO2_PIN=27
def menu(): def menu():
print("\nMenu") print("\nMenu")
@ -13,6 +13,7 @@ def menu():
print("3: Dump registers") print("3: Dump registers")
print("4: Poll for packets") print("4: Poll for packets")
print("5: Run Read+Write test") print("5: Run Read+Write test")
print("6: Print GDO state")
print("0: Quit") print("0: Quit")
@ -78,6 +79,8 @@ if __name__ == "__main__":
elif cmd == 5: elif cmd == 5:
res = test_read_write_reg(spi, True) res = test_read_write_reg(spi, True)
print("Test result : "+str(res)) print("Test result : "+str(res))
elif cmd == 6:
print_gdo_state(GDO0_PIN, GDO2_PIN)
else: else:
print("Invalid command") print("Invalid command")
finally: finally:

19
util.py
View File

@ -13,7 +13,7 @@ SNOP = STROBES["SNOP"]
VERSION = STATUS["VERSION"] VERSION = STATUS["VERSION"]
MARCSTATE = STATUS["MARCSTATE"] MARCSTATE = STATUS["MARCSTATE"]
def init_gpio(GDO0_PIN=23, GDO2_PIN=24): def init_gpio(GDO0_PIN=17, GDO2_PIN=27):
# Use BCM numbering # Use BCM numbering
GPIO.setmode(GPIO.BCM) GPIO.setmode(GPIO.BCM)
@ -22,20 +22,13 @@ def init_gpio(GDO0_PIN=23, GDO2_PIN=24):
# GPIO.setup(GDO2_PIN, GPIO.IN) # GPIO.setup(GDO2_PIN, GPIO.IN)
GPIO.setup(GDO0_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(GDO0_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(GDO2_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(GDO2_PIN, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
sleep(0.1)
# def clear_csn(): def print_gdo_state(GDO0_PIN=17, GDO2_PIN=27):
# CSN_PIN = 8 # CE0 = GPIO8 (Pin 24) gdo0 = GPIO.input(GDO0_PIN) # Reads 1 or 0
# GPIO.setmode(GPIO.BCM) gdo2 = GPIO.input(GDO2_PIN)
# GPIO.setup(CSN_PIN, GPIO.OUT) print(f"GDO0 (GPIO{GDO0_PIN}): {gdo0}, GDO2 (GPIO{GDO2_PIN}): {gdo2}")
# sleep(0.1)
# GPIO.output(CSN_PIN, GPIO.HIGH)
# sleep(0.1)
def print_gdo_state(GDO0_PIN=23, GDO2_PIN=24):
gdo0 = GPIO.input(23) # Reads 1 or 0
gdo2 = GPIO.input(24)
print(f"GDO0 (GPIO23): {gdo0}, GDO2 (GPIO24): {gdo2}")
sleep(0.1) sleep(0.1)