diff options
-rw-r--r-- | buspirate_spi.c | 2 | ||||
-rw-r--r-- | programmer.h | 1 | ||||
-rw-r--r-- | udelay.c | 18 |
3 files changed, 16 insertions, 5 deletions
diff --git a/buspirate_spi.c b/buspirate_spi.c index d2ebc7500..9d229f4dc 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -286,7 +286,7 @@ int buspirate_spi_init(void) /* The Bus Pirate can't handle UART input buffer overflow in BBIO mode, and sending a sequence * of 0x00 too fast apparently triggers such an UART input buffer overflow. */ - usleep(10000); + internal_sleep(10000); } /* We know that 20 commands of \0 should elicit at least one BBIO1 response. */ if ((ret = buspirate_wait_for_string(bp_commbuf, "BBIO"))) diff --git a/programmer.h b/programmer.h index a22bdd263..2ea7b481a 100644 --- a/programmer.h +++ b/programmer.h @@ -250,6 +250,7 @@ extern const struct board_info laptops_known[]; /* udelay.c */ void myusec_delay(int usecs); void myusec_calibrate_delay(void); +void internal_sleep(int usecs); void internal_delay(int usecs); #if CONFIG_INTERNAL == 1 @@ -169,13 +169,23 @@ recalibrate: msg_pinfo("OK.\n"); } +/* Not very precise sleep. */ +void internal_sleep(int usecs) +{ +#ifdef _WIN32 + Sleep((usecs + 999) / 1000); +#else + sleep(usecs / 1000000); + usleep(usecs % 1000000); +#endif +} + +/* Precise delay. */ void internal_delay(int usecs) { - /* If the delay is >1 s, use usleep because timing does not need to - * be so precise. - */ + /* If the delay is >1 s, use internal_sleep because timing does not need to be so precise. */ if (usecs > 1000000) { - usleep(usecs); + internal_sleep(usecs); } else { myusec_delay(usecs); } |