diff --git a/firmware/firmware.h b/firmware/firmware.h index a6b28a4..7484085 100644 --- a/firmware/firmware.h +++ b/firmware/firmware.h @@ -98,6 +98,9 @@ void bridge_close_1(); void bridge_close_2(); void bridge_close_3(); +void cancel_breathing_animation(); +void init_breathing_animation(); + // port.c #define UART_MS_TIMEOUT 10 // send uart data after ms timeout even if buffer is not full diff --git a/firmware/usb.c b/firmware/usb.c index 4382acb..b5b06b0 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -429,6 +429,7 @@ bool usb_cb_set_interface(uint16_t interface, uint16_t new_altsetting) { if (altsetting == ALTSETTING_FLASH) { flash_disable(); + init_breathing_animation(); } else if (altsetting == ALTSETTING_PIPE) { usbpipe_disable(); } @@ -440,6 +441,7 @@ bool usb_cb_set_interface(uint16_t interface, uint16_t new_altsetting) { } if (new_altsetting == ALTSETTING_FLASH){ + cancel_breathing_animation(); flash_init(); } else if (booted && new_altsetting == ALTSETTING_PIPE) { usbpipe_init(); diff --git a/scripts/flash.py b/scripts/flash.py index e6ef349..3b48af1 100644 --- a/scripts/flash.py +++ b/scripts/flash.py @@ -122,6 +122,16 @@ def write_tessel_flash(self, path, mac1, mac2): def randbyte(): return random.randint(0, 255) +def reset_openwrt(device): + # Reset the USB interface + device.reset(); + # Control transfer to put RST line high + device.ctrl_transfer(0x40, 0x10, 1, 0, '') + # Control transfer to put RST line low + device.ctrl_transfer(0x40, 0x10, 0, 0, '') + # Control transfer to put RST line high + device.ctrl_transfer(0x40, 0x10, 1, 0, '') + if __name__ == '__main__': dev = usb.core.find(idVendor=0x1209, idProduct=0x7551) if dev is None: @@ -138,3 +148,6 @@ def randbyte(): print("Generated MAC addr ", ':'.join("{:02x}".format(x) for x in mac1)) flash.write_tessel_flash(basepath, mac1, mac2) + + print("Rebooting device...") + reset_openwrt(dev)