From 1b15db2dba17ba1ab2422b0b9d2d82644d3af257 Mon Sep 17 00:00:00 2001 From: Leandro Resende Mattioli Date: Fri, 7 Jun 2024 12:49:37 -0300 Subject: [PATCH 1/3] fix(misc): Use 64 bit return value for micros() --- cores/esp32/esp32-hal-misc.c | 4 ++-- cores/esp32/esp32-hal.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index cf8edcf279f..ba94a106161 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -191,8 +191,8 @@ BaseType_t xTaskCreateUniversal( #endif } -unsigned long ARDUINO_ISR_ATTR micros() { - return (unsigned long)(esp_timer_get_time()); +unsigned long long ARDUINO_ISR_ATTR micros() { + return (unsigned long long)(esp_timer_get_time()); } unsigned long ARDUINO_ISR_ATTR millis() { diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index 60350ae960b..87c4bfb7d45 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -121,7 +121,7 @@ BaseType_t xTaskCreateUniversal( TaskHandle_t *const pxCreatedTask, const BaseType_t xCoreID ); -unsigned long micros(); +unsigned long long micros(); unsigned long millis(); void delay(uint32_t); void delayMicroseconds(uint32_t us); From 3d254577352557ca4fc36c458b6fae22c49d4d18 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Sun, 9 Jun 2024 11:45:38 -0300 Subject: [PATCH 2/3] feat(hal): delayMicroseconds(uint64_t) Allow delayMicroseconds() to use a 64 bits parameter. It has no bad effect if the parameter has less bits. --- cores/esp32/esp32-hal-misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index ba94a106161..5b193d7a494 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -203,7 +203,7 @@ void delay(uint32_t ms) { vTaskDelay(ms / portTICK_PERIOD_MS); } -void ARDUINO_ISR_ATTR delayMicroseconds(uint32_t us) { +void ARDUINO_ISR_ATTR delayMicroseconds(uint64_t us) { uint64_t m = (uint64_t)esp_timer_get_time(); if (us) { uint64_t e = (m + us); From 5ebb3a4384f98f12a5eb20c9462722cb8f9a1021 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Sun, 9 Jun 2024 11:50:22 -0300 Subject: [PATCH 3/3] feat(hal): Add 64 bits parameter Change from 32 to 64 bits the time parameter for delayMicroseconds() Follows proposed change within the PR. --- cores/esp32/esp32-hal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index 87c4bfb7d45..c83bf17bb1d 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -124,7 +124,7 @@ BaseType_t xTaskCreateUniversal( unsigned long long micros(); unsigned long millis(); void delay(uint32_t); -void delayMicroseconds(uint32_t us); +void delayMicroseconds(uint64_t us); #if !CONFIG_ESP32_PHY_AUTO_INIT void arduino_phy_init();