File tree Expand file tree Collapse file tree 2 files changed +67
-0
lines changed
examples/nucleo_f072rb/independend_watchdog Expand file tree Collapse file tree 2 files changed +67
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2023, Zühlke Engineering (Austria) GmbH
3
+ *
4
+ * This file is part of the modm project.
5
+ *
6
+ * This Source Code Form is subject to the terms of the Mozilla Public
7
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
8
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
+ */
10
+ // ----------------------------------------------------------------------------
11
+
12
+ #include < modm/board.hpp>
13
+ #include < modm/platform.hpp>
14
+
15
+ using namespace Board ;
16
+
17
+ /* *
18
+ * If the button is pressed for more than 4 seconds, the MCU will be reset by the Watchdog.
19
+ * This can be observed by the faster blinking LED after startup.
20
+ */
21
+
22
+ int
23
+ main ()
24
+ {
25
+ Board::initialize ();
26
+ LedD13::setOutput ();
27
+ // set the watchdog timeout to 4 seconds
28
+ Iwdg::initialize (Iwdg::Prescaler::Div32, 0x0FFFu );
29
+
30
+ // Use the logging streams to print some messages.
31
+ // Change MODM_LOG_LEVEL above to enable or disable these messages
32
+ MODM_LOG_DEBUG << " debug" << modm::endl;
33
+ MODM_LOG_INFO << " info" << modm::endl;
34
+ MODM_LOG_WARNING << " warning" << modm::endl;
35
+ MODM_LOG_ERROR << " error" << modm::endl;
36
+
37
+ uint32_t counter (0 );
38
+
39
+ while (counter < 10 )
40
+ {
41
+ LedD13::toggle ();
42
+ modm::delay (100ms);
43
+ MODM_LOG_INFO << " loop: " << counter++ << modm::endl;
44
+ }
45
+
46
+ Iwdg::enable ();
47
+
48
+ while (1 )
49
+ {
50
+ LedD13::toggle ();
51
+ modm::delay (500ms);
52
+ if (!Button::read ()) { Iwdg::trigger (); }
53
+ MODM_LOG_INFO << " loop: " << counter++ << modm::endl;
54
+ }
55
+
56
+ return 0 ;
57
+ }
Original file line number Diff line number Diff line change
1
+ <library >
2
+ <extends >modm:nucleo-f072rb</extends >
3
+ <options >
4
+ <option name =" modm:build:build.path" >../../../build/nucleo_f072rb/independend_watchdog</option >
5
+ </options >
6
+ <modules >
7
+ <module >modm:build:scons</module >
8
+ <module >modm:platform:iwdg</module >
9
+ </modules >
10
+ </library >
You can’t perform that action at this time.
0 commit comments