-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
36 lines (29 loc) · 847 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* Copyright (c) 2020 Arm Limited and affiliates.
* SPDX-License-Identifier: Apache-2.0
*/
#include "mbed.h"
const uint32_t TIMEOUT_MS = 5000;
InterruptIn button(BUTTON1);
volatile int countdown = 9;
void trigger()
{
Watchdog::get_instance().kick();
countdown = 9;
}
int main()
{
printf("\r\nTarget started.\r\n");
Watchdog &watchdog = Watchdog::get_instance();
watchdog.start(TIMEOUT_MS);
button.rise(&trigger);
uint32_t watchdog_timeout = watchdog.get_timeout();
printf("Watchdog initialized to %lu ms.\r\n", watchdog_timeout);
printf("Press BUTTON1 at least once every %lu ms to kick the "
"watchdog and prevent system reset.\r\n", watchdog_timeout);
while (1) {
printf("\r%3i", countdown--);
fflush(stdout);
ThisThread::sleep_for(TIMEOUT_MS / 10);
}
}