From f3b07aeb0a49ef449a86a3d7cc1c445189ff0620 Mon Sep 17 00:00:00 2001 From: icex2 Date: Wed, 6 Jan 2021 19:37:53 +0100 Subject: [PATCH] iidxio-ezusb: Fix same flushing issue on shutdown as bio2 --- src/main/iidxio-ezusb/iidxio.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/iidxio-ezusb/iidxio.c b/src/main/iidxio-ezusb/iidxio.c index 681594b..5017bed 100644 --- a/src/main/iidxio-ezusb/iidxio.c +++ b/src/main/iidxio-ezusb/iidxio.c @@ -90,6 +90,15 @@ bool iidx_io_init( void iidx_io_fini(void) { + // Pushing some final state before closing the IO to the actual outputs, e.g. lights on/off + // can be a bit finicky. Do a few polls to "enforce"/flush this final state + for (uint8_t i = 0; i < 5; i++) { + iidx_io_ep1_send(); + iidx_io_ep2_recv(); + + Sleep(10); + } + ezusb_close(iidx_io_ezusb_handle); iidx_io_ezusb_handle = INVALID_HANDLE_VALUE; }