Mcu-dependent includes

Hi,

this might be a somewhat stupid question but I am looking in the lib-code where the #includes are for MCU-specific boards. I have some ideas to alter of the library-code for a specific MCU.

I am trying to program an esp32 to use simplefoc. After a few hours I simply cannot find where in the code it is determined to use to f.i. esp32_mcu.cpp

Dirk.

All of the hardware-specific files are compiled every time, but depending on what platform you’re compiling for there will be different preprocessor labels defined, which are used to control which one actually gets used. esp32_mcu.cpp has a rather lengthy condition, #if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED) && !defined(SIMPLEFOC_ESP32_USELEDC)

stm32_mcu.cpp’s condition is just #if defined(_STM32_DEF_) and if you’re not compiling for an STM32 platform that will not be defined, so all the code will be stripped out by the preprocessor.

The functions in those files match the prototypes in src/drivers/hardware_api.h.

Thnx dekutree64!

Can you elaborate why all the hardware-specific files are compiled every time?

Dirk

Just the easiest way to do it. If you were using GCC more directly (writing your own makefiles rather than using Arduino IDE) you could be more specific about which .cpp files get compiled. But even then it’s usually more convenient to use wildcards to compile whatever is there, so whenever you create a new file you don’t have to explicitly add it to the makefile.