Make hid_test fail less confusingly when programming device is not connected

Add requirements.txt
This commit is contained in:
Daniel Lublin 2022-10-25 14:18:04 +02:00
parent 48f32949bc
commit 7af0fc6777
No known key found for this signature in database
GPG Key ID: 75BD0FEB8D3E7830
3 changed files with 13 additions and 3 deletions

View File

@ -9,8 +9,11 @@ USB_VID = 0xcafe
class ice40_flasher:
def __init__(self):
self.dev = None
for dict in hid.enumerate(USB_VID):
self.dev = hid.Device(dict['vendor_id'], dict['product_id'])
if self.dev is None:
raise IOError("Couldn't find any hid device with vendor id 0x%x" % (USB_VID))
def close(self):
self.dev.close()

View File

@ -0,0 +1,4 @@
hid==1.0.5
numpy==1.23.4
pyserial==3.5
pyusb==1.2.1

View File

@ -2,12 +2,15 @@
import hid_test
import time
def reset_mta1():
""" Manipulate the GPIO lines on the MTA1-USB-CH552 Programmer to issue a hardware reset to the MTA1 """
def reset_tk1():
"""Manipulate the GPIO lines on the MTA1-USB-CH552 Programmer to issue a
hardware reset to the TK1. The result is that TK1 again will be in firmware
mode, so a new app can be loaded."""
d = hid_test.ice40_flasher()
d.gpio_set_direction(14, True)
d.gpio_put(14, False)
d.gpio_set_direction(14, False)
d.close()
reset_mta1()
reset_tk1()