Skip to content

Commit

Permalink
Fix delayMicroseconds() to use 64bit period
Browse files Browse the repository at this point in the history
fixes: #5000
  • Loading branch information
me-no-dev committed Apr 5, 2021
1 parent 5502879 commit 8645971
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cores/esp32/esp32-hal-misc.c
Expand Up @@ -160,15 +160,15 @@ void delay(uint32_t ms)

void ARDUINO_ISR_ATTR delayMicroseconds(uint32_t us)
{
uint32_t m = micros();
uint64_t m = (uint64_t)esp_timer_get_time();
if(us){
uint32_t e = (m + us);
uint64_t e = (m + us);
if(m > e){ //overflow
while(micros() > e){
while((uint64_t)esp_timer_get_time() > e){
NOP();
}
}
while(micros() < e){
while((uint64_t)esp_timer_get_time() < e){
NOP();
}
}
Expand Down

0 comments on commit 8645971

Please sign in to comment.