from pyftdi.gpio import GpioController
import serial
import time, struct, binascii, code, os
def delay(amount):
now = start = time.perf_counter()
while True:
now = time.perf_counter()
if now - start >= amount:
return
# for C232HM-DDHSL-0 cable
WIRE_ORANGE = 1 << 0
WIRE_YELLOW = 1 << 1
WIRE_GREEN = 1 << 2
WIRE_BROWN = 1 << 3
WIRE_GRAY = 1 << 4
WIRE_PURPLE = 1 << 5
WIRE_WHITE = 1 << 6
WIRE_BLUE = 1 << 7
class Reset:
def __init__(s, url):
# init gpio mode with gray (conncted to RESET) and green (TOOL0) as outputs
s.gpio = GpioController()
s.gpio.open_from_url(url, direction = WIRE_GRAY | WIRE_GREEN)
def enter_rom(s):
s.gpio.set_direction(WIRE_GRAY | WIRE_GREEN)
# RESET=0, TOOL0=0
s.gpio.write_port(0)
delay(.04)
# RESET=1, TOOL0=0
s.gpio.write_port(WIRE_GRAY)
delay(.001)
# RESET=1, TOOL0=1...