From 9496060e0e05d228b12d74c3d32311eabeb719fb Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 26 Feb 2024 17:24:52 +0100 Subject: [PATCH] [stm32] add advanced initialize on iwdg --- src/modm/platform/iwdg/stm32/iwdg.hpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/modm/platform/iwdg/stm32/iwdg.hpp b/src/modm/platform/iwdg/stm32/iwdg.hpp index 26321b6c5a..59365c8d3f 100644 --- a/src/modm/platform/iwdg/stm32/iwdg.hpp +++ b/src/modm/platform/iwdg/stm32/iwdg.hpp @@ -46,6 +46,15 @@ class Iwdg : public ::modm::PeripheralDriver }; public: + static inline void + initialize(Prescaler prescaler, uint16_t reload) + { + writeKey(writeCommand); + IWDG->PR = uint32_t(prescaler); + IWDG->RLR = reload; + writeKey(0); // disable access to PR and RLR registers + } + template< class SystemClock, milliseconds_t timeout, percent_t tolerance=pct(1) > static void initialize() @@ -55,10 +64,9 @@ class Iwdg : public ::modm::PeripheralDriver SystemClock::Iwdg, frequency, 1ul << 12, 256, 4); assertDurationInTolerance< 1.0 / result.frequency, 1.0 / frequency, tolerance >(); - configure(Prescaler(result.index), result.counter - 1); + initialize(Prescaler(result.index), result.counter - 1); } - static inline void enable() { @@ -78,15 +86,6 @@ class Iwdg : public ::modm::PeripheralDriver } private: - static inline void - configure(Prescaler prescaler, uint16_t reload) - { - writeKey(writeCommand); - IWDG->PR = uint32_t(prescaler); - IWDG->RLR = reload; - writeKey(0); // disable access to PR and RLR registers - } - static inline void writeKey(uint16_t key) {