blob: 0336b909a6c0bd15007056e58c56828086ecfb53 (
plain)
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
|
static uint8_t wdt_generation __attribute__((section (".noinit")));
static void wdt_init(void)
{
uint8_t temp;
/* timed sequence. bit 4: WDCE, bit 3: WDE,
* 0x07 = WDP2 | WDP1 | WDP0 = 2s */
asm volatile ("\n\
WDTCSR = 0x60\n\
WDCE = 4\n\
WDE = 3\n\
wdr \n\
\n\
ldi %[temp], (1 << WDCE) | (1 << WDE) \n\
sts WDTCSR, %[temp] \n\
\n\
ldi %[temp], (1 << WDE) | 0x20 \n\
sts WDTCSR, %[temp] \n\
" : [temp] "=r" (temp) : : "memory");
if (MCUSR & (1 << WDRF))
wdt_generation++;
}
|