diff --git a/drivers/ti3410.c b/drivers/ti3410.c index f435b20..423e827 100644 --- a/drivers/ti3410.c +++ b/drivers/ti3410.c @@ -530,7 +530,8 @@ static int download_firmware(struct usb_device *dev) return -1; printc_dbg("Waiting for TI3410 reset...\n"); - usleep(2000000); + delay_s(2); + return 0; } diff --git a/drivers/tilib.c b/drivers/tilib.c index 72cf252..d4643ca 100644 --- a/drivers/tilib.c +++ b/drivers/tilib.c @@ -599,7 +599,7 @@ static int do_init(struct tilib_device *dev, const struct device_args *args) } /* Without this delay, MSP430_OpenDevice will often hang. */ - usleep(1000000); + delay_s(1); printc_dbg("MSP430_OpenDevice\n"); if (dev->MSP430_OpenDevice("DEVICE_UNKNOWN", "", 0, 0, 0) < 0) { diff --git a/util/util.h b/util/util.h index c0fde8a..5349c7b 100644 --- a/util/util.h +++ b/util/util.h @@ -24,6 +24,8 @@ #ifdef __Windows__ #include +#else +#include #endif #define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0])) @@ -69,4 +71,17 @@ HANDLE ctrlc_win32_event(void); /* Expand `~' in path names. Caller must free the returned ptr */ char *expand_tilde(const char *path); +/* Sleep for a number of seconds */ +#ifdef __Windows__ +static inline void delay_s(unsigned int s) +{ + Sleep(s); +} +#else +static inline void delay_s(unsigned int s) +{ + sleep(s); +} +#endif + #endif