-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathwdt.c
49 lines (40 loc) · 1.42 KB
/
wdt.c
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
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
TinyHawkFlyskyRx
Copyright 2018 Peter Nemcsik
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
https://github.com/nepeee/TinyHawkFlyskyRx
*/
#include "wdt.h"
#include "defines.h"
#include "led.h"
#include "delay.h"
void wdt_init() {
// check if 32khz clock source is rcosc:
if (!(CLKCON & CLKCON_OSC32K)) {
led_green_on();
while (1) {
led_red_on();
delay_ms(200);
led_red_off();
delay_ms(200);
}
}
// set wdt interval to approx 1 second
WDCTL = (WDCTL & ~WDCTL_INT) | WDCTL_INT_1S;
// enable wdt. NOTE: this can not be disabled in software!
WDCTL = (WDCTL & ~WDCTL_MODE) | WDCTL_EN;
}
void wdt_reset() {
// reset wdt (special sequence)
WDCTL = (WDCTL & 0x0F) | 0b10100000;
WDCTL = (WDCTL & 0x0F) | 0b01010000;
}