summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-05-21 13:31:02 +0700
committerhathach <[email protected]>2019-05-21 13:31:02 +0700
commitce6976f40055db185b7260c7619d02cf6ffd4cf6 (patch)
tree569d8c123efa4b00f27a31993d11f54101bbb319 /hw
parent73c7db38f7517bbd5c6710874962774bdc2df65d (diff)
better fix for #72 millis overthrow
Diffstat (limited to 'hw')
-rw-r--r--hw/bsp/board.h18
1 files changed, 2 insertions, 16 deletions
diff --git a/hw/bsp/board.h b/hw/bsp/board.h
index 4970dc303..6467a5e4f 100644
--- a/hw/bsp/board.h
+++ b/hw/bsp/board.h
@@ -97,22 +97,8 @@ static inline void board_led_off(void)
static inline void board_delay(uint32_t ms)
{
- if ( ms == 0 ) return;
-
- uint64_t end_ms = (uint64_t) board_millis();
- end_ms += ms;
-
- // about to overflows
- if (end_ms > UINT32_MAX)
- {
- // first wait for overflow occurs since "ms" is small enough
- while( board_millis() > ms ) {}
-
- // then adjust end time
- end_ms -= UINT32_MAX;
- }
-
- while( board_millis() < end_ms ) {}
+ uint32_t start_ms = board_millis();
+ while( board_millis() - start_ms < ms) {}
}
static inline int8_t board_uart_getchar(void)