From 67af3a66d88baf2b9761f5f8c7c115a198a7f513 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Thu, 27 Apr 2023 14:20:14 +0200 Subject: [PATCH] C++23 enable in CMakeLists.txt --- CMakeLists.txt | 1 + cores/esp32/esp32-hal-spi.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 719461c6..1a8b73e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ set(requires spi_flash mbedtls wifi_provisioning driver) set(priv_requires nvs_flash bootloader_support espcpputils fmt) idf_component_register(INCLUDE_DIRS ${includedirs} PRIV_INCLUDE_DIRS ${priv_includes} SRCS ${srcs} REQUIRES ${requires} PRIV_REQUIRES ${priv_requires}) +set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 23) if(IDF_TARGET STREQUAL "esp32") target_compile_options(${COMPONENT_TARGET} PUBLIC -DARDUINO=10812 -DARDUINO_ESP32_DEV -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD="ESP32_DEV" -DARDUINO_VARIANT="esp32" -DESP32) diff --git a/cores/esp32/esp32-hal-spi.c b/cores/esp32/esp32-hal-spi.c index fc0b3540..2ac55dc0 100644 --- a/cores/esp32/esp32-hal-spi.c +++ b/cores/esp32/esp32-hal-spi.c @@ -1278,7 +1278,7 @@ uint32_t spiFrequencyToClockDiv(uint32_t freq) memcpy(&bestReg, ®, sizeof(bestReg)); break; } else if(calFreq < (int32_t) freq) { - if(abs(freq - calFreq) < abs(freq - bestFreq)) { + if(freq - calFreq < freq - bestFreq) { bestFreq = calFreq; memcpy(&bestReg, ®, sizeof(bestReg)); }