From 5ae26ddfe2b8112732bbb74180303d9d18144a56 Mon Sep 17 00:00:00 2001 From: Niklas Hauser Date: Thu, 22 Aug 2024 16:23:31 +0200 Subject: [PATCH] [iwdg] Enable IWDG on STM32H7 devices --- README.md | 2 +- src/modm/platform/iwdg/stm32/{iwdg.hpp => iwdg.hpp.in} | 8 ++++---- src/modm/platform/iwdg/stm32/module.lb | 7 +++---- 3 files changed, 8 insertions(+), 9 deletions(-) rename src/modm/platform/iwdg/stm32/{iwdg.hpp => iwdg.hpp.in} (94%) diff --git a/README.md b/README.md index f829be1912..b3371bed15 100644 --- a/README.md +++ b/README.md @@ -406,7 +406,7 @@ Please [discover modm's peripheral drivers for your specific device][discover]. ✅ ✅ ✅ -○ +✅ ✅ ✅ ✅ diff --git a/src/modm/platform/iwdg/stm32/iwdg.hpp b/src/modm/platform/iwdg/stm32/iwdg.hpp.in similarity index 94% rename from src/modm/platform/iwdg/stm32/iwdg.hpp rename to src/modm/platform/iwdg/stm32/iwdg.hpp.in index 59365c8d3f..b018192d8f 100644 --- a/src/modm/platform/iwdg/stm32/iwdg.hpp +++ b/src/modm/platform/iwdg/stm32/iwdg.hpp.in @@ -50,8 +50,8 @@ class Iwdg : public ::modm::PeripheralDriver initialize(Prescaler prescaler, uint16_t reload) { writeKey(writeCommand); - IWDG->PR = uint32_t(prescaler); - IWDG->RLR = reload; + IWDG{{core}}->PR = uint32_t(prescaler); + IWDG{{core}}->RLR = reload; writeKey(0); // disable access to PR and RLR registers } @@ -82,14 +82,14 @@ class Iwdg : public ::modm::PeripheralDriver static inline Status getStatus() { - return Status(IWDG->SR); + return Status(IWDG{{core}}->SR); } private: static inline void writeKey(uint16_t key) { - IWDG->KR = key; + IWDG{{core}}->KR = key; } static constexpr uint16_t reloadCommand = 0xAAAA; diff --git a/src/modm/platform/iwdg/stm32/module.lb b/src/modm/platform/iwdg/stm32/module.lb index 98536a5b64..848c127725 100644 --- a/src/modm/platform/iwdg/stm32/module.lb +++ b/src/modm/platform/iwdg/stm32/module.lb @@ -17,9 +17,6 @@ def init(module): def prepare(module, options): device = options[":target"] - # STM32H7 is not yet supported with any IWDG implementation - if device.identifier.family in ["h7"]: - return False module.depends(":cmsis:device", ":math:algorithm") return device.has_driver("iwdg:stm32") @@ -27,4 +24,6 @@ def prepare(module, options): def build(env): env.outbasepath = "modm/src/modm/platform/iwdg" - env.copy("iwdg.hpp") + # FIXME: Use IWDG2 for second core on STM32H7x5 + env.substitutions = {"core": 1 if env[":target"].identifier.family in ["h7"] else ""} + env.template("iwdg.hpp.in")