import time
from time import sleep

import machine, rp2
from machine import Pin

Led = Pin("LED", Pin.OUT)
Halt = Pin(13, Pin.OUT)
Slenb = Pin(14, Pin.OUT)
Dir = Pin(15, Pin.OUT)
ResetN = Pin(8, Pin.IN)
EClock = Pin(9, Pin.IN)
WriteC = Pin(10, Pin.IN)
WriteD = Pin(11, Pin.IN)
ReadD = Pin(12, Pin.IN)

Led.value(1)
Halt.value(0)
Slenb.value(0)
Dir.value(1)

@rp2.asm_pio(sideset_init=rp2.PIO.OUT_HIGH)
def mimic_prog():
    wait(0, gpio, 9).side(0)
    wait(1, gpio, 9).side(1)

mimic_sm = rp2.StateMachine(
    0,  # which pio
    mimic_prog,
    freq=125_000_000,
    sideset_base=Halt,
)
mimic_sm.active(True)

print("running...")
while True:
    pass