Page 1 of 1
core and version identification
Posted: Tue Jan 26, 2021 11:12 am
by ag123
is there a preprocessor define or a #define tag which i can tell between the cores (e.g. between official & libmaple) and version?
i think there is ARDUINO define, but i'd guess that's for the original Arduino?
it is a little unfortunate as APIs (e.g. SPI) between cores are at least a little different so some ifdefs are necessary

Re: core and version identification
Posted: Tue Jan 26, 2021 11:39 am
by MoDu
I think ARDUINO_ARCH_STM32F1 works for libmaple (roger's and steve's). Not sure about STM core.
Have you tried this?
viewtopic.php?f=7&t=870
Re: core and version identification
Posted: Tue Jan 26, 2021 12:02 pm
by ag123
it seemed the official stm core could reserve the tag STM32DUINO or __STM32DUINO__ for its tag
not sure what is a failsafe way to do versions, e.g. so that we can have
Code: Select all
#if defined(STM32DUINO) && VERSION > 10000
//do this
#else
//do that
#endif
But literally i don't like it just that that's the way the world evolves
oh btw i saw that, maybe this would do
Re: core and version identification
Posted: Tue Jan 26, 2021 1:58 pm
by fpiSTM
ag123 wrote: Tue Jan 26, 2021 12:02 pm
oh btw i saw that, maybe this would do
Right this is the official defintion to use for STM32 core.
For Libmaple F1 as mentionned by
@GonzoG :
For Libmaple F4:
In fact this is specified by Arduino:
https://arduino.github.io/arduino-cli/l ... hitectures
Re: core and version identification
Posted: Tue Jan 26, 2021 2:09 pm
by ag123
thanks ! i'd use these symbols for now
oh what about version, does it matter?
i think for now we'd make do 'without versions' (too complicated)
glibc did something like this
https://stackoverflow.com/questions/426 ... bc-is-used
Re: core and version identification
Posted: Tue Jan 26, 2021 4:20 pm
by mrburnette
in the compile/link environment, version is available from platform.txt
name=STM32F1 Boards (Arduino_STM32)
version=0.1.2
Re: core and version identification
Posted: Tue Jan 26, 2021 4:36 pm
by fpiSTM
For STM32 core since version 1.5.0 IIRW, the version are available this help to maintains some backward compatibility and check:
https://github.com/stm32duino/Arduino_C ... f.h#L5-L21
Code: Select all
/**
* @brief STM32 core version number
*/
#define STM32_CORE_VERSION_MAJOR (0x02U) /*!< [31:24] major version */
#define STM32_CORE_VERSION_MINOR (0x00U) /*!< [23:16] minor version */
#define STM32_CORE_VERSION_PATCH (0x00U) /*!< [15:8] patch version */
/*
* Extra label for development:
* 0: official release
* [1-9]: release candidate
* F[0-9]: development
*/
#define STM32_CORE_VERSION_EXTRA (0xF0U) /*!< [7:0] extra version */
#define STM32_CORE_VERSION ((STM32_CORE_VERSION_MAJOR << 24U)\
|(STM32_CORE_VERSION_MINOR << 16U)\
|(STM32_CORE_VERSION_PATCH << 8U )\
|(STM32_CORE_VERSION_EXTRA))
You can use it like this:
Code: Select all
#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION > 0x01090000)
// do some specific stuff
#endif