Im looking to use lora components with esp32-C3 mcu.
Sadly it doesn't compile out of the box because vspi_host doesn't seem to exist on this chipset.
So i would like to adapt the library to use a specific spi host depending of the architecture.
which general variable is accessible from preprocessor to distinguish between arch.
Does idf.py set-target esp32/esp32c3 manipulate such existing variables i can rely on ?
Best way for preprocessing conditionnal based on arch
Re: Best way for preprocessing conditionnal based on arch
Hi citoyx,
To have conditional compilation based on the target chip you can include sdkconfig.h and then use CONFIG_IDF_TARGET_ESP32C3, CONFIG_IDF_TARGET_ESP32, etc.
However to future proof your code I'd suggest #ifdef VSPI_HOST as this filters on the property you care about (is there a SPI peripheral called VSPI_HOST?)
For some similar macros please take a look at the soc_caps.h header as well:
https://github.com/espressif/esp-idf/bl ... soc_caps.h
https://github.com/espressif/esp-idf/bl ... soc_caps.h
SOC_SPI_PERIPH_NUM in this header could also be used to distinguish the two (VSPI_HOST is macro-defined to SPI3_HOST in the IDF HAL layer).
To have conditional compilation based on the target chip you can include sdkconfig.h and then use CONFIG_IDF_TARGET_ESP32C3, CONFIG_IDF_TARGET_ESP32, etc.
However to future proof your code I'd suggest #ifdef VSPI_HOST as this filters on the property you care about (is there a SPI peripheral called VSPI_HOST?)
For some similar macros please take a look at the soc_caps.h header as well:
https://github.com/espressif/esp-idf/bl ... soc_caps.h
https://github.com/espressif/esp-idf/bl ... soc_caps.h
SOC_SPI_PERIPH_NUM in this header could also be used to distinguish the two (VSPI_HOST is macro-defined to SPI3_HOST in the IDF HAL layer).
Who is online
Users browsing this forum: No registered users and 444 guests