Page 1 of 1

Controller specific defines for STM

Posted: Mon Jan 18, 2021 11:35 am
by moelski
Hello again,

I´d like to port some code which uses prcocessor specific defines like this ones:
__AVR_ATmega328P__ > AVR Mega 328
ESP8266 > ESP8266
__IMXRT1062__, ARDUINO_TEENSY41 > some Teensy boards

Which defines can I use when working with the STM32?
And can anyone tell me where I can find those defines? So I could search by myself.

For Arduino as an example I can find them in the gcc / Device-Specs Folder.

Dominik

Re: Controller specific defines for STM

Posted: Mon Jan 18, 2021 1:34 pm
by fpiSTM
For the core:

Code: Select all

ARDUINO_ARCH_STM32
For STM32 series:

Code: Select all

STM32YYxx
where YY is the family, example for L4:

Code: Select all

STM32L4xx
For specific product line:

Code: Select all

STM32L452xx
You can find all product line in this file: https://github.com/stm32duino/Arduino_C ... ef_build.h

Finally you can also use specific cortex definition like it is done here: https://github.com/stm32duino/STM32Free ... ortmacro.h

Code: Select all

#ifndef __CORTEX_M
#pragma GCC error  "no \"__CORTEX_M\" definition"
#endif

#if (__CORTEX_M == 0x00U)
#include "../portable/GCC/ARM_CM0/portmacro.h"
#endif

Re: Controller specific defines for STM

Posted: Mon Jan 18, 2021 1:36 pm
by moelski
Again. Many thx for your help.
This helps alot.

Dominik

Re: Controller specific defines for STM

Posted: Mon Jan 18, 2021 1:39 pm
by moelski
One additional question ...

Is it possible to have that in some print statement?
Something like

Code: Select all

Serial.Print("arch : "); Serial.Println(??ARCH??)