Files
xlsw_3dp_LDC1612/src/fwdgt.c
2024-12-29 22:59:07 +08:00

28 lines
691 B
C

//
// Created by yelv1 on 24-12-29.
//
#include "fwdgt.h"
void watchdog_init(void) {
/* Enable the LSI clock */
rcu_osci_on(RCU_IRC40K);
rcu_osci_stab_wait(RCU_IRC40K);
/* Configure FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
fwdgt_config(625, FWDGT_PSC_DIV64); // Set timeout to 1 seconds (625 / 0.625 KHz)
/* Enable FWDGT */
fwdgt_enable();
}
void fwdgt_reset_mcu(void) {
/* Enable the write access to the FWDGT_CTL register */
FWDGT_CTL = FWDGT_WRITEACCESS_ENABLE;
/* Configure FWDGT to trigger a system reset */
fwdgt_config(50, FWDGT_PSC_DIV4);
/* Reload the counter to trigger the reset */
fwdgt_counter_reload();
}