stm32f4: Add support for watchdog
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
899b6726fa
commit
73709984b0
|
@ -11,7 +11,7 @@ CFLAGS += -Ilib/cmsis-core -Ilib/stm32f4/include
|
||||||
CFLAGS += -DSTM32F446xx
|
CFLAGS += -DSTM32F446xx
|
||||||
|
|
||||||
# Add source files
|
# Add source files
|
||||||
src-y += stm32f4/main.c stm32f4/clock.c stm32f4/gpio.c
|
src-y += stm32f4/main.c stm32f4/clock.c stm32f4/watchdog.c stm32f4/gpio.c
|
||||||
src-y += generic/crc16_ccitt.c generic/alloc.c
|
src-y += generic/crc16_ccitt.c generic/alloc.c
|
||||||
src-y += generic/armcm_irq.c generic/armcm_timer.c
|
src-y += generic/armcm_irq.c generic/armcm_timer.c
|
||||||
src-y += ../lib/stm32f4/system_stm32f4xx.c
|
src-y += ../lib/stm32f4/system_stm32f4xx.c
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
// Watchdog handler on STM32F4
|
||||||
|
//
|
||||||
|
// Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
|
||||||
|
//
|
||||||
|
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
|
#include "internal.h" // IWDG
|
||||||
|
#include "sched.h" // DECL_TASK
|
||||||
|
|
||||||
|
void
|
||||||
|
watchdog_reset(void)
|
||||||
|
{
|
||||||
|
IWDG->KR = 0xAAAA;
|
||||||
|
}
|
||||||
|
DECL_TASK(watchdog_reset);
|
||||||
|
|
||||||
|
void
|
||||||
|
watchdog_init(void)
|
||||||
|
{
|
||||||
|
IWDG->KR = 0x5555;
|
||||||
|
IWDG->PR = 0;
|
||||||
|
IWDG->RLR = 0x0FFF; // 512ms timeout
|
||||||
|
IWDG->KR = 0xCCCC;
|
||||||
|
}
|
||||||
|
DECL_INIT(watchdog_init);
|
Loading…
Reference in New Issue