File tree 3 files changed +51
-67
lines changed
src/modm/platform/iwdg/stm32
3 files changed +51
-67
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 12
12
#pragma once
13
13
#include " ../device.hpp"
14
14
15
+
16
+ namespace modm ::platform
17
+ {
18
+
19
+ // / @ingroup modm_platform_iwdg
15
20
class Iwdg
16
21
{
17
22
public:
18
23
enum class
19
- Prescaler : uint32_t
24
+ Prescaler : uint8_t
20
25
{
21
26
Div4 = 0 ,
22
27
Div8 = IWDG_PR_PR_0,
@@ -29,28 +34,52 @@ class Iwdg
29
34
};
30
35
31
36
enum class
32
- Status : uint32_t
37
+ Status : uint8_t
33
38
{
34
39
None = 0 ,
35
40
Prescaler = IWDG_SR_PVU,
36
41
Reload = IWDG_SR_RVU,
37
42
All = IWDG_SR_PVU | IWDG_SR_RVU,
38
43
};
39
44
40
- static void
41
- initialize (Prescaler prescaler, uint32_t reload);
42
- static void
43
- enable ();
44
- static void
45
- trigger ();
46
- static Status
47
- getStatus ();
45
+ public:
46
+ static inline void
47
+ initialize (Prescaler prescaler, uint32_t reload)
48
+ {
49
+ writeKey (writeCommand);
50
+ IWDG->PR = uint32_t (prescaler);
51
+ IWDG->RLR = reload;
52
+ writeKey (0 ); // disable access to PR and RLR registers
53
+ }
54
+
55
+ static inline void
56
+ enable ()
57
+ {
58
+ writeKey (enableCommand);
59
+ }
60
+
61
+ static inline void
62
+ trigger ()
63
+ {
64
+ writeKey (reloadCommand);
65
+ }
66
+
67
+ static inline Status
68
+ getStatus ()
69
+ {
70
+ return Status (IWDG->SR );
71
+ }
48
72
49
73
private:
50
- static constexpr uint32_t reloadCommand = 0xAAAA ;
51
- static constexpr uint32_t writeCommand = 0x5555 ;
52
- static constexpr uint32_t enableCommand = 0xCCCC ;
74
+ static constexpr uint16_t reloadCommand = 0xAAAA ;
75
+ static constexpr uint16_t writeCommand = 0x5555 ;
76
+ static constexpr uint16_t enableCommand = 0xCCCC ;
77
+
78
+ static inline void
79
+ writeKey (uint16_t key)
80
+ {
81
+ IWDG->KR = key;
82
+ }
83
+ };
53
84
54
- static void
55
- writeKey (uint32_t key);
56
- };
85
+ }
Original file line number Diff line number Diff line change @@ -14,15 +14,17 @@ def init(module):
14
14
module .name = ":platform:iwdg"
15
15
module .description = "Independent watchdog"
16
16
17
+
17
18
def prepare (module , options ):
18
19
device = options [":target" ]
19
- target = device .identifier
20
- if target ["family" ] in ["h7" ]:
21
- # STM32H7 is not yet supported with any IWDG implementation im modm
20
+ # STM32H7 is not yet supported with any IWDG implementation
21
+ if device .identifier .family in ["h7" ]:
22
22
return False
23
+
24
+ module .depends (":cmsis:device" )
23
25
return device .has_driver ("iwdg:stm32" )
24
26
27
+
25
28
def build (env ):
26
29
env .outbasepath = "modm/src/modm/platform/iwdg"
27
30
env .copy ("iwdg.hpp" )
28
- env .copy ("iwdg.cpp" )
You can’t perform that action at this time.
0 commit comments