BLE_TYQ_CH584M/BSP/src/bsp_iwdg.c

24 lines
445 B
C
Raw Normal View History

2024-12-14 13:31:23 +08:00
#include "bsp_iwdg.h"
#include "bsp_uart.h"
#include "log.h"
#undef LOG_ENABLE
#define LOG_ENABLE 1
#undef LOG_TAG
#define LOG_TAG "idwg"
// 32k rc
// div 0:4 | 1:8 | 2:16 | 3:32 |
// 4:64 | 5:128 | 6:256 | 7:512 |
// reload max 4095
void ch59x_iwdg_init(uint8_t div, uint16_t reload)
{
R32_IWDG_KR = 0x5555;
R32_IWDG_CFG = (RB_PR & (div << 12)) | (RB_STOP_EN) | (reload & RB_RLR);
R32_IWDG_KR = 0xcccc; // enable
}