From cf2aa5258faab409a6f60e4d5f2caf3954d8a737 Mon Sep 17 00:00:00 2001 From: "Frederic.Pillon" Date: Mon, 26 Aug 2019 14:13:59 +0200 Subject: [PATCH] Allow F_CPU redefinition To avoid any issue with `F_CPU` value, it is defined by default to `SystemCoreClock` value which is updated automatically after each clock configuration update. Some libraries use `F_CPU` at build time for conditional purpose (ex to #612). This commit allow to redefine it at build time using `build_opt.h` or `hal_conf_extra.h`: https://github.com/stm32duino/wiki/wiki/Custom-definitions then it will be possible to define it as a constant. Important note: **User have to ensure to set it to the proper value.** Signed-off-by: Frederic.Pillon --- cores/arduino/stm32/stm32_def.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cores/arduino/stm32/stm32_def.h b/cores/arduino/stm32/stm32_def.h index f922d383cf..d0352ce727 100644 --- a/cores/arduino/stm32/stm32_def.h +++ b/cores/arduino/stm32/stm32_def.h @@ -20,7 +20,6 @@ |(STM32_CORE_VERSION_PATCH << 8U )\ |(STM32_CORE_VERSION_EXTRA)) -#define F_CPU SystemCoreClock #define USE_HAL_DRIVER #ifdef STM32F0xx @@ -53,6 +52,10 @@ #error "STM32YYxx chip series is not defined in boards.txt." #endif +#ifndef F_CPU +#define F_CPU SystemCoreClock +#endif + // Here define some compatibility #ifndef CAN1 #define CAN1 CAN