From 8e447f5cd5808a07fc94376596c34142e242246e Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Mon, 9 Aug 2021 16:15:21 +0200 Subject: [PATCH] Removed arduino's delay() --- cores/esp32/HardwareSerial.cpp | 2 +- cores/esp32/HardwareSerial.h | 2 +- cores/esp32/USBCDC.cpp | 2 +- cores/esp32/esp32-hal-i2c.c | 2 +- cores/esp32/esp32-hal-misc.c | 5 ----- cores/esp32/esp32-hal.h | 1 - 6 files changed, 4 insertions(+), 10 deletions(-) diff --git a/cores/esp32/HardwareSerial.cpp b/cores/esp32/HardwareSerial.cpp index 34fda914..7abce142 100644 --- a/cores/esp32/HardwareSerial.cpp +++ b/cores/esp32/HardwareSerial.cpp @@ -94,7 +94,7 @@ void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, in end(); if(detectedBaudRate) { - delay(100); // Give some time... + vTaskDelay(100 / portTICK_PERIOD_MS); // Give some time... _uart = uartBegin(_uart_nr, detectedBaudRate, config, rxPin, txPin, 256, invert); } else { log_e("Could not detect baudrate. Serial data at the port must be present within the timeout for detection to be possible"); diff --git a/cores/esp32/HardwareSerial.h b/cores/esp32/HardwareSerial.h index 1135ffec..68fe361c 100644 --- a/cores/esp32/HardwareSerial.h +++ b/cores/esp32/HardwareSerial.h @@ -26,7 +26,7 @@ Baudrate detection example usage (detection on Serial1): void setup() { Serial.begin(115200); - delay(100); + vTaskDelay(100 / portTICK_PERIOD_MS); Serial.println(); Serial1.begin(0, SERIAL_8N1, -1, -1, true, 11000UL); // Passing 0 for baudrate to detect it, the last parameter is a timeout in ms diff --git a/cores/esp32/USBCDC.cpp b/cores/esp32/USBCDC.cpp index 01299575..ec1e4640 100644 --- a/cores/esp32/USBCDC.cpp +++ b/cores/esp32/USBCDC.cpp @@ -75,7 +75,7 @@ static size_t tinyusb_cdc_write(uint8_t itf, const uint8_t *buffer, size_t size) while(tosend){ uint32_t space = tud_cdc_n_write_available(itf); if(!space){ - delay(1); + vTaskDelay(1 / portTICK_PERIOD_MS); continue; } if(tosend < space){ diff --git a/cores/esp32/esp32-hal-i2c.c b/cores/esp32/esp32-hal-i2c.c index 87b1adcd..9acced54 100644 --- a/cores/esp32/esp32-hal-i2c.c +++ b/cores/esp32/esp32-hal-i2c.c @@ -1146,7 +1146,7 @@ i2c_err_t i2cProcQueue(i2c_t * i2c, uint32_t *readCount, uint16_t timeOutMillis) if(multiMaster){// try to let the bus clear by its self uint32_t timeOutTick = millis(); while((i2c->dev->status_reg.bus_busy)&&(millis()-timeOutTickdev->status_reg.bus_busy){ // still busy, so die diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 5e31285a..aafa1d4e 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -65,11 +65,6 @@ unsigned long ARDUINO_ISR_ATTR micros() return (unsigned long) (esp_timer_get_time()); } -void delay(uint32_t ms) -{ - vTaskDelay(ms / portTICK_PERIOD_MS); -} - void ARDUINO_ISR_ATTR delayMicroseconds(uint32_t us) { uint32_t m = micros(); diff --git a/cores/esp32/esp32-hal.h b/cores/esp32/esp32-hal.h index 129bb37a..b585dfb0 100644 --- a/cores/esp32/esp32-hal.h +++ b/cores/esp32/esp32-hal.h @@ -80,7 +80,6 @@ void yield(void); float temperatureRead(); unsigned long micros(); -void delay(uint32_t); void delayMicroseconds(uint32_t us); #ifdef __cplusplus