generated from hulk/gd32e23x_template
clean shit
This commit is contained in:
28
src/fwdgt.c
Normal file
28
src/fwdgt.c
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// 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();
|
||||
}
|
Reference in New Issue
Block a user