[Solved] Which define defines the stm32 core for libraries?

The official STMicroelectronics Arduino core
Post Reply
tomvdb
Posts: 9
Joined: Mon Jul 17, 2017 2:10 pm

[Solved] Which define defines the stm32 core for libraries?

Post by tomvdb » Fri Jul 21, 2017 10:57 am

So I'm trying the various libraries I usually use for arduino projects and testing/fixing to work with my stm32 board. The question is what define can I use in the library to determine if its using the stm32 core?

For example:

Code: Select all

#if defined(__AVR__)
 #define WIRE Wire
#elif defined(CORE_TEENSY) // Teensy boards
 #define WIRE Wire
#else // Arduino Due
 #define WIRE Wire1
#endif
Is there something like STM32_CORE define that I can use for adding my changes?

User avatar
martinayotte
Posts: 1229
Joined: Mon Apr 27, 2015 1:45 pm

Re: Which define defines the stm32 core for libraries?

Post by martinayotte » Fri Jul 21, 2017 1:33 pm

There are severals ones, but the most common is __STM32F1__ or __STM32F4__, depending of MCU type.
Simply look at the compile command with verbosity turned-on ...

User avatar
Wi6Labs
Posts: 25
Joined: Fri Sep 16, 2016 11:39 am
Location: Rennes, France
Contact:

Re: Which define defines the stm32 core for libraries?

Post by Wi6Labs » Fri Jul 21, 2017 3:14 pm

You can simply use the define STM32 (Here)
Wi6Labs team

tomvdb
Posts: 9
Joined: Mon Jul 17, 2017 2:10 pm

Re: Which define defines the stm32 core for libraries?

Post by tomvdb » Sat Jul 22, 2017 10:02 am

Wi6Labs wrote:
Fri Jul 21, 2017 3:14 pm
You can simply use the define STM32 (Here)
perfect thanks :)

fpiSTM
Posts: 224
Joined: Fri Sep 16, 2016 12:33 pm
Location: Le Mans, France

Re: Which define defines the stm32 core for libraries?

Post by fpiSTM » Mon Jul 31, 2017 9:11 am

Hi,

the good one is ARDUINO_ARCH_STM32
STM32 is not defined.

Post Reply