Fix delayMicroseconds() to use 64bit period

fixes: https://github.com/espressif/arduino-esp32/issues/5000
This commit is contained in:
me-no-dev 2021-04-05 15:15:09 +03:00
parent 5502879a5b
commit 8645971981

View File

@ -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();
}
}