From 6612f8d715ead80793b5a04f9d889962d8a08de6 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Wed, 4 Aug 2021 16:16:11 +0200 Subject: [PATCH 01/11] STM32: Prevent possible crashes before HAL init FastIO_init() is required to fill an array of pointers to GPIO pins, If some user try to use any READ/WRITE/TOGGLE fastio command before HAL_init(), the board will crash. This is STM32 HAL specific, STM32F1 and others are not like that... I enabled it by default for all STM32 boards... I think it may avoid a lot of problems during migration of maple envs --- Marlin/src/HAL/STM32/fastio.cpp | 2 +- Marlin/src/HAL/STM32/fastio.h | 14 ++++++++++---- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 9 +-------- ini/stm32-common.ini | 1 + 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Marlin/src/HAL/STM32/fastio.cpp b/Marlin/src/HAL/STM32/fastio.cpp index 5056e99d35f0..7840be845f05 100644 --- a/Marlin/src/HAL/STM32/fastio.cpp +++ b/Marlin/src/HAL/STM32/fastio.cpp @@ -24,7 +24,7 @@ #include "../../inc/MarlinConfig.h" -GPIO_TypeDef* FastIOPortMap[LastPort + 1]; +GPIO_TypeDef* FastIOPortMap[LastPort + 1] = { 0 }; void FastIO_init() { LOOP_L_N(i, NUM_DIGITAL_PINS) diff --git a/Marlin/src/HAL/STM32/fastio.h b/Marlin/src/HAL/STM32/fastio.h index 17751c44dd8d..b6c999c54605 100644 --- a/Marlin/src/HAL/STM32/fastio.h +++ b/Marlin/src/HAL/STM32/fastio.h @@ -37,7 +37,7 @@ extern GPIO_TypeDef * FastIOPortMap[]; // Public functions // ------------------------ -void FastIO_init(); // Must be called before using fast io macros +void FastIO_init(); // Must be called before using fast io READ/WRITE, or define FASTIO_PREINIT // ------------------------ // Defines @@ -66,9 +66,15 @@ void FastIO_init(); // Must be called before using fast io macros #define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) //!< Output Push Pull Mode & GPIO_NOPULL #define _SET_OUTPUT_OD(IO) pinMode(IO, OUTPUT_OPEN_DRAIN) -#define WRITE(IO,V) _WRITE(IO,V) -#define READ(IO) _READ(IO) -#define TOGGLE(IO) _TOGGLE(IO) +#ifdef FASTIO_PREINIT + #define READ(IO) ((FastIOPortMap[0]) ? _READ(IO) : digitalRead(IO)) + #define WRITE(IO,V) if (FastIOPortMap[0]) _WRITE(IO,V); else digitalWrite(IO,V) + #define TOGGLE(IO) if (FastIOPortMap[0]) _TOGGLE(IO); else digitalWrite(IO,(!digitalRead(IO))) +#else + #define READ(IO) _READ(IO) + #define WRITE(IO,V) _WRITE(IO,V) + #define TOGGLE(IO) _TOGGLE(IO) +#endif #define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0) #define OUT_WRITE_OD(IO,V) do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0) diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index bdf215fa8e4a..f9ec42b68efe 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -99,19 +99,12 @@ // Avoid nozzle heat and fan start before serial init #define BOARD_OPENDRAIN_MOSFETS -#define BOARD_INIT_OD_PINS() { \ +#define BOARD_PREINIT() { \ OUT_WRITE_OD(HEATER_0_PIN, 0); \ OUT_WRITE_OD(HEATER_BED_PIN, 0); \ OUT_WRITE_OD(FAN_PIN, 0); \ } -#ifdef MAPLE_STM32F1 - // Only Maple Framework allow that early - #define BOARD_PREINIT BOARD_INIT_OD_PINS -#else - #define BOARD_INIT BOARD_INIT_OD_PINS -#endif - // // PWM for a servo probe // Other servo devices are not supported on this board! diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini index 08b0f70b4d66..48730eed88d0 100644 --- a/ini/stm32-common.ini +++ b/ini/stm32-common.ini @@ -15,6 +15,7 @@ board_build.core = stm32 build_flags = ${common.build_flags} -std=gnu++14 -DUSBCON -DUSBD_USE_CDC + -DFASTIO_PREINIT -DTIM_IRQ_PRIO=13 -DADC_RESOLUTION=12 build_unflags = -std=gnu++11 From c59cc8af5810c41a3b406cbfc840bf5395fe8214 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Wed, 4 Aug 2021 19:01:22 +0200 Subject: [PATCH 02/11] Brackets to avoid warnings --- Marlin/src/HAL/STM32/fastio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/STM32/fastio.h b/Marlin/src/HAL/STM32/fastio.h index b6c999c54605..2952bda9de63 100644 --- a/Marlin/src/HAL/STM32/fastio.h +++ b/Marlin/src/HAL/STM32/fastio.h @@ -68,8 +68,8 @@ void FastIO_init(); // Must be called before using fast io READ/WRITE, or define #ifdef FASTIO_PREINIT #define READ(IO) ((FastIOPortMap[0]) ? _READ(IO) : digitalRead(IO)) - #define WRITE(IO,V) if (FastIOPortMap[0]) _WRITE(IO,V); else digitalWrite(IO,V) - #define TOGGLE(IO) if (FastIOPortMap[0]) _TOGGLE(IO); else digitalWrite(IO,(!digitalRead(IO))) + #define WRITE(IO,V) { if (FastIOPortMap[0]) _WRITE(IO,V); else digitalWrite(IO,V); } + #define TOGGLE(IO) { if (FastIOPortMap[0]) _TOGGLE(IO); else digitalWrite(IO,(!digitalRead(IO))); } #else #define READ(IO) _READ(IO) #define WRITE(IO,V) _WRITE(IO,V) From 6d399ca7b7af9a6c47ff98681fe5e09768c706bb Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Wed, 4 Aug 2021 19:21:05 +0200 Subject: [PATCH 03/11] Handle special if/else case --- Marlin/src/HAL/STM32/fastio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/STM32/fastio.h b/Marlin/src/HAL/STM32/fastio.h index 2952bda9de63..b2ff478828d0 100644 --- a/Marlin/src/HAL/STM32/fastio.h +++ b/Marlin/src/HAL/STM32/fastio.h @@ -68,8 +68,8 @@ void FastIO_init(); // Must be called before using fast io READ/WRITE, or define #ifdef FASTIO_PREINIT #define READ(IO) ((FastIOPortMap[0]) ? _READ(IO) : digitalRead(IO)) - #define WRITE(IO,V) { if (FastIOPortMap[0]) _WRITE(IO,V); else digitalWrite(IO,V); } - #define TOGGLE(IO) { if (FastIOPortMap[0]) _TOGGLE(IO); else digitalWrite(IO,(!digitalRead(IO))); } + #define WRITE(IO,V) do { if (FastIOPortMap[0]) _WRITE(IO,V); else digitalWrite(IO,V); } while(0) + #define TOGGLE(IO) do { if (FastIOPortMap[0]) _TOGGLE(IO); else digitalWrite(IO,(!digitalRead(IO))); } while(0) #else #define READ(IO) _READ(IO) #define WRITE(IO,V) _WRITE(IO,V) From 1fcb6dbe016a428ca6d42ff9a54e6ac5e87de95f Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 6 Aug 2021 17:10:17 +0200 Subject: [PATCH 04/11] Disable global FASTIO_PREINIT, tested ok --- Marlin/src/MarlinCore.cpp | 8 +++++++- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 7 ++++--- ini/stm32-common.ini | 1 - 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 6134699aa101..6a7c2cf03d78 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1188,7 +1188,13 @@ void setup() { #if HAS_SUICIDE SETUP_LOG("SUICIDE_PIN"); - OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING); + SET_OUTPUT(SUICIDE_PIN); + #ifdef ARDUINO_ARCH_STM32 + // We are before FastIO_init()! + digitalWrite(SUICIDE_PIN, !SUICIDE_PIN_INVERTING); + #else + WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING); + #endif #endif #ifdef JTAGSWD_RESET diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index f9ec42b68efe..2eca9ff16ef8 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -99,10 +99,11 @@ // Avoid nozzle heat and fan start before serial init #define BOARD_OPENDRAIN_MOSFETS +// STM32 framework cannot use WRITE macros before HAL_init() #define BOARD_PREINIT() { \ - OUT_WRITE_OD(HEATER_0_PIN, 0); \ - OUT_WRITE_OD(HEATER_BED_PIN, 0); \ - OUT_WRITE_OD(FAN_PIN, 0); \ + _SET_OUTPUT_OD(HEATER_0_PIN); digitalWrite(HEATER_0_PIN, 0); \ + _SET_OUTPUT_OD(HEATER_BED_PIN); digitalWrite(HEATER_BED_PIN, 0); \ + _SET_OUTPUT_OD(FAN_PIN); digitalWrite(FAN_PIN, 0); \ } // diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini index 48730eed88d0..08b0f70b4d66 100644 --- a/ini/stm32-common.ini +++ b/ini/stm32-common.ini @@ -15,7 +15,6 @@ board_build.core = stm32 build_flags = ${common.build_flags} -std=gnu++14 -DUSBCON -DUSBD_USE_CDC - -DFASTIO_PREINIT -DTIM_IRQ_PRIO=13 -DADC_RESOLUTION=12 build_unflags = -std=gnu++11 From 047fcad3ae257cfb04f540f220f79a99a6ea9332 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 6 Aug 2021 20:55:45 +0200 Subject: [PATCH 05/11] STM32: FastIO_init first + HAL_STM32 env define --- Marlin/src/HAL/STM32/HAL.cpp | 2 +- Marlin/src/HAL/STM32/fastio.h | 14 ++++---------- Marlin/src/MarlinCore.cpp | 12 +++++------- Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h | 7 +++---- ini/stm32-common.ini | 2 +- 5 files changed, 14 insertions(+), 23 deletions(-) diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index d8035a979ded..d770d9170840 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -61,7 +61,7 @@ TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); // HAL initialization task void HAL_init() { - FastIO_init(); + //FastIO_init(); // Moved in setup() // 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. diff --git a/Marlin/src/HAL/STM32/fastio.h b/Marlin/src/HAL/STM32/fastio.h index b2ff478828d0..17751c44dd8d 100644 --- a/Marlin/src/HAL/STM32/fastio.h +++ b/Marlin/src/HAL/STM32/fastio.h @@ -37,7 +37,7 @@ extern GPIO_TypeDef * FastIOPortMap[]; // Public functions // ------------------------ -void FastIO_init(); // Must be called before using fast io READ/WRITE, or define FASTIO_PREINIT +void FastIO_init(); // Must be called before using fast io macros // ------------------------ // Defines @@ -66,15 +66,9 @@ void FastIO_init(); // Must be called before using fast io READ/WRITE, or define #define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) //!< Output Push Pull Mode & GPIO_NOPULL #define _SET_OUTPUT_OD(IO) pinMode(IO, OUTPUT_OPEN_DRAIN) -#ifdef FASTIO_PREINIT - #define READ(IO) ((FastIOPortMap[0]) ? _READ(IO) : digitalRead(IO)) - #define WRITE(IO,V) do { if (FastIOPortMap[0]) _WRITE(IO,V); else digitalWrite(IO,V); } while(0) - #define TOGGLE(IO) do { if (FastIOPortMap[0]) _TOGGLE(IO); else digitalWrite(IO,(!digitalRead(IO))); } while(0) -#else - #define READ(IO) _READ(IO) - #define WRITE(IO,V) _WRITE(IO,V) - #define TOGGLE(IO) _TOGGLE(IO) -#endif +#define WRITE(IO,V) _WRITE(IO,V) +#define READ(IO) _READ(IO) +#define TOGGLE(IO) _TOGGLE(IO) #define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0) #define OUT_WRITE_OD(IO,V) do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0) diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 6a7c2cf03d78..3383ac45530e 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1131,6 +1131,10 @@ inline void tmc_standby_setup() { * - Set Marlin to RUNNING State */ void setup() { + #ifdef HAL_STM32 + FastIO_init(); + #endif + #ifdef BOARD_PREINIT BOARD_PREINIT(); // Low-level init (before serial init) #endif @@ -1188,13 +1192,7 @@ void setup() { #if HAS_SUICIDE SETUP_LOG("SUICIDE_PIN"); - SET_OUTPUT(SUICIDE_PIN); - #ifdef ARDUINO_ARCH_STM32 - // We are before FastIO_init()! - digitalWrite(SUICIDE_PIN, !SUICIDE_PIN_INVERTING); - #else - WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING); - #endif + OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING); #endif #ifdef JTAGSWD_RESET diff --git a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h index 2eca9ff16ef8..f9ec42b68efe 100644 --- a/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h +++ b/Marlin/src/pins/stm32f1/pins_LONGER3D_LK.h @@ -99,11 +99,10 @@ // Avoid nozzle heat and fan start before serial init #define BOARD_OPENDRAIN_MOSFETS -// STM32 framework cannot use WRITE macros before HAL_init() #define BOARD_PREINIT() { \ - _SET_OUTPUT_OD(HEATER_0_PIN); digitalWrite(HEATER_0_PIN, 0); \ - _SET_OUTPUT_OD(HEATER_BED_PIN); digitalWrite(HEATER_BED_PIN, 0); \ - _SET_OUTPUT_OD(FAN_PIN); digitalWrite(FAN_PIN, 0); \ + OUT_WRITE_OD(HEATER_0_PIN, 0); \ + OUT_WRITE_OD(HEATER_BED_PIN, 0); \ + OUT_WRITE_OD(FAN_PIN, 0); \ } // diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini index 08b0f70b4d66..1d3f858bf8e9 100644 --- a/ini/stm32-common.ini +++ b/ini/stm32-common.ini @@ -13,7 +13,7 @@ platform = ststm32@~12.1 board_build.core = stm32 build_flags = ${common.build_flags} - -std=gnu++14 + -std=gnu++14 -DHAL_STM32 -DUSBCON -DUSBD_USE_CDC -DTIM_IRQ_PRIO=13 -DADC_RESOLUTION=12 From 7f08383205fe3d9a360e47504d39a27cc731e83a Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 8 Aug 2021 18:09:47 +0200 Subject: [PATCH 06/11] Remove last refs to STM32GENERIC in F1 HAL --- Marlin/src/HAL/STM32F1/pinsDebug.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/STM32F1/pinsDebug.h b/Marlin/src/HAL/STM32F1/pinsDebug.h index 8e7a3d8135fd..b018a0fc8c0a 100644 --- a/Marlin/src/HAL/STM32F1/pinsDebug.h +++ b/Marlin/src/HAL/STM32F1/pinsDebug.h @@ -19,15 +19,15 @@ #pragma once /** - * Support routines for STM32GENERIC (Maple) + * Support routines for MAPLE_STM32F1 */ /** * Translation of routines & variables used by pinsDebug.h */ -#ifndef BOARD_NR_GPIO_PINS // Only in STM32GENERIC (Maple) - #error "Expected BOARD_NR_GPIO_PINS not found" +#ifndef BOARD_NR_GPIO_PINS // Only in MAPLE_STM32F1 + #error "Expected BOARD_NR_GPIO_PINS not found" #endif #include "fastio.h" From 93c48a758d69acae379a74a8feb46f11c7ffbec0 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Sun, 8 Aug 2021 18:20:45 +0200 Subject: [PATCH 07/11] Simplify code inclusion for STM32 HAL --- Marlin/src/HAL/STM32/HAL.cpp | 4 ++-- Marlin/src/HAL/STM32/HAL_MinSerial.cpp | 2 +- Marlin/src/HAL/STM32/HAL_SPI.cpp | 4 ++-- Marlin/src/HAL/STM32/MarlinSPI.cpp | 4 ++-- Marlin/src/HAL/STM32/MarlinSerial.cpp | 4 ++-- Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp | 4 ++-- Marlin/src/HAL/STM32/Servo.cpp | 4 ++-- Marlin/src/HAL/STM32/eeprom_flash.cpp | 4 ++-- Marlin/src/HAL/STM32/eeprom_sdcard.cpp | 4 ++-- Marlin/src/HAL/STM32/eeprom_sram.cpp | 4 ++-- Marlin/src/HAL/STM32/eeprom_wired.cpp | 4 ++-- Marlin/src/HAL/STM32/fast_pwm.cpp | 4 ++-- Marlin/src/HAL/STM32/fastio.cpp | 4 ++-- Marlin/src/HAL/STM32/msc_sd.cpp | 4 ++-- Marlin/src/HAL/STM32/tft/gt911.cpp | 4 ++-- Marlin/src/HAL/STM32/tft/tft_fsmc.cpp | 4 ++-- Marlin/src/HAL/STM32/tft/tft_ltdc.cpp | 4 ++-- Marlin/src/HAL/STM32/tft/tft_spi.cpp | 4 ++-- Marlin/src/HAL/STM32/tft/xpt2046.cpp | 4 ++-- Marlin/src/HAL/STM32/timers.cpp | 4 ++-- Marlin/src/HAL/STM32/usb_host.cpp | 4 ++-- Marlin/src/HAL/STM32/usb_serial.cpp | 4 ++-- Marlin/src/HAL/STM32/watchdog.cpp | 4 ++-- Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h | 2 +- Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp | 4 ++-- 25 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index d770d9170840..01087e3e930f 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "HAL.h" #include "usb_serial.h" @@ -165,4 +165,4 @@ void HAL_SYSTICK_Callback() { if (systick_user_callback) systick_user_callback(); } -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp index c780a50c57fc..6c83ee1db248 100644 --- a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index ba8e6bef197e..49ede04f8cbf 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" @@ -224,4 +224,4 @@ static SPISettings spiConfig; #endif // SOFTWARE_SPI -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/MarlinSPI.cpp b/Marlin/src/HAL/STM32/MarlinSPI.cpp index 41081dfb80ca..330c8956978d 100644 --- a/Marlin/src/HAL/STM32/MarlinSPI.cpp +++ b/Marlin/src/HAL/STM32/MarlinSPI.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) && !defined(STM32H7xx) +#if defined(HAL_STM32) && !defined(STM32H7xx) #include "MarlinSPI.h" @@ -165,4 +165,4 @@ uint8_t MarlinSPI::dmaSend(const void * transmitBuf, uint16_t length, bool minc) return 1; } -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 && !STM32H7xx +#endif // HAL_STM32 && !STM32H7xx diff --git a/Marlin/src/HAL/STM32/MarlinSerial.cpp b/Marlin/src/HAL/STM32/MarlinSerial.cpp index d990d2f428a1..91407d3033a3 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32/MarlinSerial.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" #include "MarlinSerial.h" @@ -101,4 +101,4 @@ void MarlinSerial::_rx_complete_irq(serial_t *obj) { } } -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp index 55e807f94ee0..f0a53766df67 100644 --- a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp +++ b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" @@ -320,4 +320,4 @@ extern "C" void SDIO_IRQHandler(void) { HAL_SD_IRQHandler(&hsd); } extern "C" void DMA_IRQ_HANDLER(void) { HAL_DMA_IRQHandler(&hdma_sdio); } #endif // SDIO_SUPPORT -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/Servo.cpp b/Marlin/src/HAL/STM32/Servo.cpp index 54b1fbe670c4..1a7fe8e552aa 100644 --- a/Marlin/src/HAL/STM32/Servo.cpp +++ b/Marlin/src/HAL/STM32/Servo.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" @@ -107,4 +107,4 @@ void libServo::setInterruptPriority(uint32_t preemptPriority, uint32_t subPriori } #endif // HAS_SERVOS -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 0c37abfcbb08..29a93d5df61b 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" @@ -270,4 +270,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t } #endif // FLASH_EEPROM_EMULATION -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp index 9cab90f10909..2066dde6122d 100644 --- a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 /** * Implementation of EEPROM settings in SD Card @@ -88,4 +88,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, const size_t size, uin } #endif // SDCARD_EEPROM_EMULATION -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/eeprom_sram.cpp b/Marlin/src/HAL/STM32/eeprom_sram.cpp index c39178523472..e89e4bf39d13 100644 --- a/Marlin/src/HAL/STM32/eeprom_sram.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sram.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" @@ -65,4 +65,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t } #endif // SRAM_EEPROM_EMULATION -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/eeprom_wired.cpp b/Marlin/src/HAL/STM32/eeprom_wired.cpp index 3346abbe4ac3..a6c3a0d819fe 100644 --- a/Marlin/src/HAL/STM32/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32/eeprom_wired.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" @@ -75,4 +75,4 @@ bool PersistentStore::read_data(int &pos, uint8_t *value, size_t size, uint16_t } #endif // USE_WIRED_EEPROM -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/fast_pwm.cpp b/Marlin/src/HAL/STM32/fast_pwm.cpp index eaffb8cfa40f..c872d923901e 100644 --- a/Marlin/src/HAL/STM32/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32/fast_pwm.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" @@ -56,4 +56,4 @@ void set_pwm_duty(const pin_t pin, const uint16_t v, const uint16_t v_size/*=255 } #endif // NEEDS_HARDWARE_PWM -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/fastio.cpp b/Marlin/src/HAL/STM32/fastio.cpp index 7840be845f05..8b4855b6188f 100644 --- a/Marlin/src/HAL/STM32/fastio.cpp +++ b/Marlin/src/HAL/STM32/fastio.cpp @@ -20,7 +20,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" @@ -31,4 +31,4 @@ void FastIO_init() { FastIOPortMap[STM_PORT(digitalPin[i])] = get_GPIO_Port(STM_PORT(digitalPin[i])); } -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/msc_sd.cpp index f95f75c5fcf6..20b1cc53d12e 100644 --- a/Marlin/src/HAL/STM32/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/msc_sd.cpp @@ -13,7 +13,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" @@ -125,4 +125,4 @@ void MSC_SD_init() { } #endif // HAS_SD_HOST_DRIVE -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/tft/gt911.cpp b/Marlin/src/HAL/STM32/tft/gt911.cpp index 8c59a60f92d5..efdd5f970aad 100644 --- a/Marlin/src/HAL/STM32/tft/gt911.cpp +++ b/Marlin/src/HAL/STM32/tft/gt911.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" @@ -199,4 +199,4 @@ bool GT911::getPoint(int16_t *x, int16_t *y) { } #endif // TFT_TOUCH_DEVICE_GT911 -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp index f349eacac31c..b2c0c75cac47 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" @@ -178,4 +178,4 @@ void TFT_FSMC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou } #endif // HAS_FSMC_TFT -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp index 53e5bd83e027..fb6ea68b45f8 100644 --- a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" @@ -384,4 +384,4 @@ void TFT_LTDC::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Cou } #endif // HAS_LTDC_TFT -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 4e3f894a52e0..863b1e7ac8bc 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" @@ -240,4 +240,4 @@ void TFT_SPI::TransmitDMA(uint32_t MemoryIncrease, uint16_t *Data, uint16_t Coun } #endif // HAS_SPI_TFT -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.cpp b/Marlin/src/HAL/STM32/tft/xpt2046.cpp index d50c24d1777d..e3f1b9667c77 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.cpp +++ b/Marlin/src/HAL/STM32/tft/xpt2046.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" @@ -167,4 +167,4 @@ uint16_t XPT2046::SoftwareIO(uint16_t data) { } #endif // HAS_TFT_XPT2046 -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/timers.cpp b/Marlin/src/HAL/STM32/timers.cpp index 78061981803d..dd7c8712df62 100644 --- a/Marlin/src/HAL/STM32/timers.cpp +++ b/Marlin/src/HAL/STM32/timers.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" @@ -319,4 +319,4 @@ static constexpr bool verify_no_timer_conflicts() { // when hovering over it, making it easy to identify the conflicting timers. static_assert(verify_no_timer_conflicts(), "One or more timer conflict detected. Examine \"timers_in_use\" to help identify conflict."); -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp index e45ab560e662..ce0d0ed53cca 100644 --- a/Marlin/src/HAL/STM32/usb_host.cpp +++ b/Marlin/src/HAL/STM32/usb_host.cpp @@ -20,7 +20,7 @@ * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" @@ -114,4 +114,4 @@ uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t b } #endif // USE_OTG_USB_HOST && USBHOST -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/usb_serial.cpp b/Marlin/src/HAL/STM32/usb_serial.cpp index 0e23175fc060..66d9d02ac80f 100644 --- a/Marlin/src/HAL/STM32/usb_serial.cpp +++ b/Marlin/src/HAL/STM32/usb_serial.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" @@ -51,4 +51,4 @@ void USB_Hook_init() { } #endif // EMERGENCY_PARSER && USBD_USE_CDC -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/watchdog.cpp b/Marlin/src/HAL/STM32/watchdog.cpp index 09b403e7f237..9b1f71da50fc 100644 --- a/Marlin/src/HAL/STM32/watchdog.cpp +++ b/Marlin/src/HAL/STM32/watchdog.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" @@ -46,4 +46,4 @@ void HAL_watchdog_refresh() { } #endif // USE_WATCHDOG -#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC && !MAPLE_STM32F1 +#endif // HAL_STM32 diff --git a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h index 339b337e5533..b4438a92b976 100644 --- a/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h +++ b/Marlin/src/lcd/extui/ftdi_eve_touch_ui/ftdi_eve_lib/compat.h @@ -288,7 +288,7 @@ // Remove compiler warning on an unused variable #ifndef UNUSED - #if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) + #ifdef HAL_STM32 #define UNUSED(X) (void)X #else #define UNUSED(x) ((void)(x)) diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp index 37fd2a81dc46..7f800ef95a05 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp @@ -19,7 +19,7 @@ * along with this program. If not, see . * */ -#if defined(ARDUINO_ARCH_STM32) && !defined(STM32GENERIC) && !defined(MAPLE_STM32F1) +#ifdef HAL_STM32 #include "../../../inc/MarlinConfigPre.h" @@ -349,4 +349,4 @@ int WifiSerial::write(uint8_t c) { } #endif // HAS_TFT_LVGL_UI && MKS_WIFI_MODULE -#endif // !__STM32F1__ +#endif // HAL_STM32 From 1d77ebdeecf21d21a67e5bb16f7fbfe6a6f10f2b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 8 Aug 2021 12:52:47 -0500 Subject: [PATCH 08/11] Define HAL_STM32 in HAL/platforms.h --- Marlin/src/HAL/STM32/HAL.cpp | 4 ++-- Marlin/src/HAL/STM32/HAL_MinSerial.cpp | 4 +++- Marlin/src/HAL/STM32/HAL_SPI.cpp | 2 ++ Marlin/src/HAL/STM32/MarlinSerial.cpp | 2 ++ Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp | 2 ++ Marlin/src/HAL/STM32/Servo.cpp | 2 ++ Marlin/src/HAL/STM32/eeprom_flash.cpp | 2 ++ Marlin/src/HAL/STM32/eeprom_sdcard.cpp | 2 ++ Marlin/src/HAL/STM32/eeprom_sram.cpp | 2 ++ Marlin/src/HAL/STM32/eeprom_wired.cpp | 2 ++ Marlin/src/HAL/STM32/fast_pwm.cpp | 2 ++ Marlin/src/HAL/STM32/fastio.cpp | 2 ++ Marlin/src/HAL/STM32/msc_sd.cpp | 2 ++ Marlin/src/HAL/STM32/tft/gt911.cpp | 2 ++ Marlin/src/HAL/STM32/tft/tft_fsmc.cpp | 2 ++ Marlin/src/HAL/STM32/tft/tft_ltdc.cpp | 2 ++ Marlin/src/HAL/STM32/tft/tft_spi.cpp | 2 ++ Marlin/src/HAL/STM32/tft/xpt2046.cpp | 2 ++ Marlin/src/HAL/STM32/timers.cpp | 2 ++ Marlin/src/HAL/STM32/usb_host.cpp | 1 + Marlin/src/HAL/STM32/usb_serial.cpp | 2 ++ Marlin/src/HAL/STM32/watchdog.cpp | 2 ++ Marlin/src/HAL/platforms.h | 1 + Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp | 2 ++ 24 files changed, 47 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index 01087e3e930f..a04a24c1123c 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -20,6 +20,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "HAL.h" @@ -61,8 +63,6 @@ TERN_(POSTMORTEM_DEBUGGING, extern void install_min_serial()); // HAL initialization task void HAL_init() { - //FastIO_init(); // Moved in setup() - // 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. diff --git a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp index 6c83ee1db248..29826a890de4 100644 --- a/Marlin/src/HAL/STM32/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32/HAL_MinSerial.cpp @@ -20,6 +20,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" @@ -149,4 +151,4 @@ extern "C" { #endif #endif // POSTMORTEM_DEBUGGING -#endif // ARDUINO_ARCH_STM32 +#endif // HAL_STM32 diff --git a/Marlin/src/HAL/STM32/HAL_SPI.cpp b/Marlin/src/HAL/STM32/HAL_SPI.cpp index 49ede04f8cbf..85a5238b54af 100644 --- a/Marlin/src/HAL/STM32/HAL_SPI.cpp +++ b/Marlin/src/HAL/STM32/HAL_SPI.cpp @@ -20,6 +20,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/MarlinSerial.cpp b/Marlin/src/HAL/STM32/MarlinSerial.cpp index 91407d3033a3..3caedc72eb26 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32/MarlinSerial.cpp @@ -16,6 +16,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp index f0a53766df67..914969f10cd2 100644 --- a/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp +++ b/Marlin/src/HAL/STM32/Sd2Card_sdio_stm32duino.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/Servo.cpp b/Marlin/src/HAL/STM32/Servo.cpp index 1a7fe8e552aa..a00186e0e79e 100644 --- a/Marlin/src/HAL/STM32/Servo.cpp +++ b/Marlin/src/HAL/STM32/Servo.cpp @@ -20,6 +20,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/eeprom_flash.cpp b/Marlin/src/HAL/STM32/eeprom_flash.cpp index 29a93d5df61b..ee0b192a9a12 100644 --- a/Marlin/src/HAL/STM32/eeprom_flash.cpp +++ b/Marlin/src/HAL/STM32/eeprom_flash.cpp @@ -20,6 +20,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp index 2066dde6122d..77563b2ae502 100644 --- a/Marlin/src/HAL/STM32/eeprom_sdcard.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sdcard.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 /** diff --git a/Marlin/src/HAL/STM32/eeprom_sram.cpp b/Marlin/src/HAL/STM32/eeprom_sram.cpp index e89e4bf39d13..687e7f55c226 100644 --- a/Marlin/src/HAL/STM32/eeprom_sram.cpp +++ b/Marlin/src/HAL/STM32/eeprom_sram.cpp @@ -20,6 +20,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/eeprom_wired.cpp b/Marlin/src/HAL/STM32/eeprom_wired.cpp index a6c3a0d819fe..cf0468151e5e 100644 --- a/Marlin/src/HAL/STM32/eeprom_wired.cpp +++ b/Marlin/src/HAL/STM32/eeprom_wired.cpp @@ -20,6 +20,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/fast_pwm.cpp b/Marlin/src/HAL/STM32/fast_pwm.cpp index c872d923901e..a8fcbe5f82b3 100644 --- a/Marlin/src/HAL/STM32/fast_pwm.cpp +++ b/Marlin/src/HAL/STM32/fast_pwm.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/HAL/STM32/fastio.cpp b/Marlin/src/HAL/STM32/fastio.cpp index 8b4855b6188f..b34555b8c841 100644 --- a/Marlin/src/HAL/STM32/fastio.cpp +++ b/Marlin/src/HAL/STM32/fastio.cpp @@ -20,6 +20,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/msc_sd.cpp b/Marlin/src/HAL/STM32/msc_sd.cpp index 20b1cc53d12e..4f85af0d446a 100644 --- a/Marlin/src/HAL/STM32/msc_sd.cpp +++ b/Marlin/src/HAL/STM32/msc_sd.cpp @@ -13,6 +13,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/HAL/STM32/tft/gt911.cpp b/Marlin/src/HAL/STM32/tft/gt911.cpp index efdd5f970aad..92e14edb2057 100644 --- a/Marlin/src/HAL/STM32/tft/gt911.cpp +++ b/Marlin/src/HAL/STM32/tft/gt911.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../../platforms.h" + #ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp index b2c0c75cac47..e9e712d5a362 100644 --- a/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_fsmc.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../../platforms.h" + #ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp index fb6ea68b45f8..66cfd65995dd 100644 --- a/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_ltdc.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../../platforms.h" + #ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/tft/tft_spi.cpp b/Marlin/src/HAL/STM32/tft/tft_spi.cpp index 863b1e7ac8bc..29a309f40e7b 100644 --- a/Marlin/src/HAL/STM32/tft/tft_spi.cpp +++ b/Marlin/src/HAL/STM32/tft/tft_spi.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../../platforms.h" + #ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/tft/xpt2046.cpp b/Marlin/src/HAL/STM32/tft/xpt2046.cpp index e3f1b9667c77..912e6c2db761 100644 --- a/Marlin/src/HAL/STM32/tft/xpt2046.cpp +++ b/Marlin/src/HAL/STM32/tft/xpt2046.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../../platforms.h" + #ifdef HAL_STM32 #include "../../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/timers.cpp b/Marlin/src/HAL/STM32/timers.cpp index dd7c8712df62..9b69323ef543 100644 --- a/Marlin/src/HAL/STM32/timers.cpp +++ b/Marlin/src/HAL/STM32/timers.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32/usb_host.cpp b/Marlin/src/HAL/STM32/usb_host.cpp index ce0d0ed53cca..d2d1d69a1a8d 100644 --- a/Marlin/src/HAL/STM32/usb_host.cpp +++ b/Marlin/src/HAL/STM32/usb_host.cpp @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ +#include "../platforms.h" #ifdef HAL_STM32 diff --git a/Marlin/src/HAL/STM32/usb_serial.cpp b/Marlin/src/HAL/STM32/usb_serial.cpp index 66d9d02ac80f..959ca4ff4319 100644 --- a/Marlin/src/HAL/STM32/usb_serial.cpp +++ b/Marlin/src/HAL/STM32/usb_serial.cpp @@ -16,6 +16,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/HAL/STM32/watchdog.cpp b/Marlin/src/HAL/STM32/watchdog.cpp index 9b1f71da50fc..72c74a2e3b5b 100644 --- a/Marlin/src/HAL/STM32/watchdog.cpp +++ b/Marlin/src/HAL/STM32/watchdog.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../platforms.h" + #ifdef HAL_STM32 #include "../../inc/MarlinConfigPre.h" diff --git a/Marlin/src/HAL/platforms.h b/Marlin/src/HAL/platforms.h index 0b1b305f6dc4..dd6ffbd09df3 100644 --- a/Marlin/src/HAL/platforms.h +++ b/Marlin/src/HAL/platforms.h @@ -38,6 +38,7 @@ #elif defined(__STM32F1__) || defined(TARGET_STM32F1) #define HAL_PATH(PATH, NAME) XSTR(PATH/STM32F1/NAME) #elif defined(ARDUINO_ARCH_STM32) + #define HAL_STM32 #define HAL_PATH(PATH, NAME) XSTR(PATH/STM32/NAME) #elif defined(ARDUINO_ARCH_ESP32) #define HAL_PATH(PATH, NAME) XSTR(PATH/ESP32/NAME) diff --git a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp index 7f800ef95a05..6607e7531f0e 100644 --- a/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp +++ b/Marlin/src/lcd/extui/mks_ui/wifiSerial_STM32.cpp @@ -19,6 +19,8 @@ * along with this program. If not, see . * */ +#include "../../../HAL/platforms.h" + #ifdef HAL_STM32 #include "../../../inc/MarlinConfigPre.h" From 7baad5b9e9f43f9f041549f4f74254d827865dc4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 8 Aug 2021 18:57:33 -0500 Subject: [PATCH 09/11] ibid. --- Marlin/src/HAL/platforms.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Marlin/src/HAL/platforms.h b/Marlin/src/HAL/platforms.h index dd6ffbd09df3..28fe28e1094f 100644 --- a/Marlin/src/HAL/platforms.h +++ b/Marlin/src/HAL/platforms.h @@ -38,7 +38,9 @@ #elif defined(__STM32F1__) || defined(TARGET_STM32F1) #define HAL_PATH(PATH, NAME) XSTR(PATH/STM32F1/NAME) #elif defined(ARDUINO_ARCH_STM32) - #define HAL_STM32 + #ifndef HAL_STM32 + #define HAL_STM32 + #endif #define HAL_PATH(PATH, NAME) XSTR(PATH/STM32/NAME) #elif defined(ARDUINO_ARCH_ESP32) #define HAL_PATH(PATH, NAME) XSTR(PATH/ESP32/NAME) From 75ec0037228efc3b34728853e63900745d174c21 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 8 Aug 2021 20:29:56 -0500 Subject: [PATCH 10/11] Tweak ini comments --- ini/stm32f0.ini | 2 +- ini/stm32f1-maple.ini | 2 +- ini/stm32f1.ini | 2 +- ini/stm32f4.ini | 2 +- ini/stm32f7.ini | 2 +- ini/stm32h7.ini | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ini/stm32f0.ini b/ini/stm32f0.ini index 6aebd8829852..4559f115bd8e 100644 --- a/ini/stm32f0.ini +++ b/ini/stm32f0.ini @@ -10,7 +10,7 @@ # Naming Example: STM32F070CBT6 # # F : Foundation -# 0 : Cortex M0 core +# 0 : Cortex M0 core (0:M0, 1-2:M3, 3-4:M4, 7:M7) # 70 : Line/Features # C : 48 pins (R:64 or 66, F:20) # B : 128KB Flash-memory (C:256KB, D:384KB, E:512KB, G:1024KB) diff --git a/ini/stm32f1-maple.ini b/ini/stm32f1-maple.ini index 0258fb3b7cc7..17781b63d583 100644 --- a/ini/stm32f1-maple.ini +++ b/ini/stm32f1-maple.ini @@ -10,7 +10,7 @@ # Naming Example: STM32F103RCT6 # # F : Foundation (sometimes High Performance F2/F4) -# 1 : Cortex M1 core +# 1 : Cortex M3 core (0:M0, 1-2:M3, 3-4:M4, 7:M7) # 03 : Line/Features # R : 64 or 66 pins (V:100, Z:144, I:176) # C : 256KB Flash-memory (D:384KB, E:512KB, G:1024KB) diff --git a/ini/stm32f1.ini b/ini/stm32f1.ini index 1185e8f84d8a..e9d3aac41a02 100644 --- a/ini/stm32f1.ini +++ b/ini/stm32f1.ini @@ -10,7 +10,7 @@ # Naming Example: STM32F103RCT6 # # F : Foundation (sometimes High Performance F2/F4) -# 1 : Cortex M3 core +# 1 : Cortex M3 core (0:M0, 1-2:M3, 3-4:M4, 7:M7) # 03 : Line/Features # R : 64 or 66 pins (T:36, C:48, V:100, Z:144, I:176) # C : 256KB Flash-memory (B: 128KB, D:384KB, E:512KB, G:1024KB) diff --git a/ini/stm32f4.ini b/ini/stm32f4.ini index d2332630a100..6832d99034c4 100644 --- a/ini/stm32f4.ini +++ b/ini/stm32f4.ini @@ -10,7 +10,7 @@ # Naming Example: STM32F401RGT6 # # F : Foundation (sometimes High Performance F2/F4) -# 4 : Cortex M4 core +# 4 : Cortex M4 core (0:M0, 1-2:M3, 3-4:M4, 7:M7) # 01 : Line/Features # R : 64 or 66 pins (T:36, C:48 or 49, M:81, V:100, Z:144, I:176) # G : 1024KB Flash-memory (B:128KB, C:256KB, D:384KB, E:512KB) diff --git a/ini/stm32f7.ini b/ini/stm32f7.ini index 984b25162ed6..200740589b1a 100644 --- a/ini/stm32f7.ini +++ b/ini/stm32f7.ini @@ -10,7 +10,7 @@ # Naming Example: STM32F767ZIT6 # # F : Foundation (sometimes High Performance F2/F4) -# 7 : Cortex M7 core +# 7 : Cortex M7 core (0:M0, 1-2:M3, 3-4:M4, 7:M7) # 67 : Line/Features # Z : 144 pins # I : 4096KB Flash-memory diff --git a/ini/stm32h7.ini b/ini/stm32h7.ini index 3d0753a235a6..fb39d4cc6b73 100644 --- a/ini/stm32h7.ini +++ b/ini/stm32h7.ini @@ -10,7 +10,7 @@ # Naming Example: STM32H743IIT6 # # H : High Performance -# 7 : Cortex M7 core +# 7 : Cortex M7 core (0:M0, 1-2:M3, 3-4:M4, 7:M7) # 43 : Line/Features # I : 176 pins # I : 2048KB Flash-memory From 9b4485d1e00a8c2308675b2436e735579b88ed28 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 8 Aug 2021 21:35:01 -0500 Subject: [PATCH 11/11] Define FASTIO_INIT for HAL/STM32 --- Marlin/src/HAL/STM32/fastio.h | 1 + Marlin/src/MarlinCore.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/HAL/STM32/fastio.h b/Marlin/src/HAL/STM32/fastio.h index 17751c44dd8d..4a489544716f 100644 --- a/Marlin/src/HAL/STM32/fastio.h +++ b/Marlin/src/HAL/STM32/fastio.h @@ -38,6 +38,7 @@ extern GPIO_TypeDef * FastIOPortMap[]; // ------------------------ void FastIO_init(); // Must be called before using fast io macros +#define FASTIO_INIT() FastIO_init() // ------------------------ // Defines diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 3383ac45530e..e8f9f16a8f9a 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1131,8 +1131,8 @@ inline void tmc_standby_setup() { * - Set Marlin to RUNNING State */ void setup() { - #ifdef HAL_STM32 - FastIO_init(); + #ifdef FASTIO_INIT + FASTIO_INIT(); #endif #ifdef BOARD_PREINIT