C++23 enable in CMakeLists.txt

This commit is contained in:
2023-04-27 14:20:14 +02:00
parent 38efa465bf
commit 67af3a66d8
2 changed files with 2 additions and 1 deletions

View File

@ -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)

View File

@ -1278,7 +1278,7 @@ uint32_t spiFrequencyToClockDiv(uint32_t freq)
memcpy(&bestReg, &reg, 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, &reg, sizeof(bestReg));
}