Skip to content

Commit

Permalink
[iwdg] Enable IWDG on STM32H7 devices
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Aug 22, 2024
1 parent f58b42f commit 5ae26dd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ Please [discover modm's peripheral drivers for your specific device][discover].
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center"></td>
<td align="center"></td>
<td align="center">✅</td>
<td align="center">✅</td>
<td align="center">✅</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions src/modm/platform/iwdg/stm32/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ 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")


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")

0 comments on commit 5ae26dd

Please sign in to comment.