Make F_CPU a compile-time constant (#21051)

This commit is contained in:
X-Ryl669
2021-02-27 00:59:28 +01:00
committed by GitHub
parent f384f81253
commit 56462cf082
3 changed files with 25 additions and 0 deletions

View File

@ -63,6 +63,12 @@ TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial());
void HAL_init() {
FastIO_init();
// Ensure F_CPU is a constant expression.
// If the compiler breaks here, it means that delay code that should compute at compile time will not work.
// So better safe than sorry here.
constexpr int cpuFreq = F_CPU;
UNUSED(cpuFreq);
#if ENABLED(SDSUPPORT) && DISABLED(SDIO_SUPPORT) && (defined(SDSS) && SDSS != -1)
OUT_WRITE(SDSS, HIGH); // Try to set SDSS inactive before any other SPI users start up
#endif

View File

@ -24,3 +24,9 @@
#if defined(USBD_USE_CDC_MSC) && DISABLED(NO_SD_HOST_DRIVE)
#define HAS_SD_HOST_DRIVE 1
#endif
// Fix F_CPU not being a compile-time constant in STSTM32 framework
#ifdef BOARD_F_CPU
#undef F_CPU
#define F_CPU BOARD_F_CPU
#endif