Add delay_s() for portable sleep() substitute.
This commit is contained in:
parent
3517710455
commit
6fd161faa7
|
@ -530,7 +530,8 @@ static int download_firmware(struct usb_device *dev)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
printc_dbg("Waiting for TI3410 reset...\n");
|
printc_dbg("Waiting for TI3410 reset...\n");
|
||||||
usleep(2000000);
|
delay_s(2);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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. */
|
/* Without this delay, MSP430_OpenDevice will often hang. */
|
||||||
usleep(1000000);
|
delay_s(1);
|
||||||
|
|
||||||
printc_dbg("MSP430_OpenDevice\n");
|
printc_dbg("MSP430_OpenDevice\n");
|
||||||
if (dev->MSP430_OpenDevice("DEVICE_UNKNOWN", "", 0, 0, 0) < 0) {
|
if (dev->MSP430_OpenDevice("DEVICE_UNKNOWN", "", 0, 0, 0) < 0) {
|
||||||
|
|
15
util/util.h
15
util/util.h
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#ifdef __Windows__
|
#ifdef __Windows__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ARRAY_LEN(a) (sizeof(a) / sizeof((a)[0]))
|
#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 */
|
/* Expand `~' in path names. Caller must free the returned ptr */
|
||||||
char *expand_tilde(const char *path);
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue