Switch from ms_sleep to us_sleep.

This commit is contained in:
David Betz 2015-01-25 21:37:19 -05:00
parent eac9af39e2
commit 4e4f90c107

View File

@ -12,7 +12,7 @@
#define ACK_TIMEOUT 20 #define ACK_TIMEOUT 20
static int ms_sleep(unsigned long msecs); static int us_sleep(unsigned long usecs);
static void SerialInit(PL_state *state); static void SerialInit(PL_state *state);
static void TByte(PL_state *state, uint8_t x); static void TByte(PL_state *state, uint8_t x);
static void TLong(PL_state *state, uint32_t x); static void TLong(PL_state *state, uint32_t x);
@ -42,7 +42,7 @@ int PL_LoadSpinBinary(PL_state *state, int loadType, uint8_t *image, int size)
TLong(state, data); TLong(state, data);
} }
TComm(state); TComm(state);
ms_sleep(1); us_sleep(1000);
/* wait for an ACK */ /* wait for an ACK */
while (--retries >= 0) { while (--retries >= 0) {
@ -57,11 +57,11 @@ int PL_LoadSpinBinary(PL_state *state, int loadType, uint8_t *image, int size)
return retries >= 0 ? 0 : -1; return retries >= 0 ? 0 : -1;
} }
static int ms_sleep(unsigned long msecs) static int us_sleep(unsigned long usecs)
{ {
struct timespec req; struct timespec req;
req.tv_sec = (int)(msecs / 1000L); req.tv_sec = (int)(usecs / 1000000L);
req.tv_nsec = (msecs - (req.tv_sec * 1000)) * 1000000L; req.tv_nsec = (usecs - (req.tv_sec * 1000000L)) * 1000L;
while (nanosleep(&req, &req) < 0) while (nanosleep(&req, &req) < 0)
; ;
return 1; return 1;