#include"gd32f30x.h"#include"gd32f307c_eval.h"#include"systick.h"#include"main.h"voidled_config(void);/* software delay to prevent the impact of Vcore fluctuations.
It is strongly recommended to include it to avoid issues caused by self-removal. */staticvoid_soft_delay_(uint32_ttime){__IOuint32_ti;for(i=0;i<time*10;i++){}}intmain(void){/* systick configuration */systick_config();/* LED configuration */led_config();/* enable clock */rcu_periph_clock_enable(RCU_PMU);/* wakeup key configuration */gd_eval_key_init(KEY_WAKEUP,KEY_MODE_GPIO);/* tamper key EXTI configuration */gd_eval_key_init(KEY_TAMPER,KEY_MODE_EXTI);/* press wakeup key to enter deepsleep mode and use tamper key to generate a exti interrupt to wakeup mcu */while(1){if(RESET==gpio_input_bit_get(WAKEUP_KEY_GPIO_PORT,WAKEUP_KEY_PIN)){/* The following is to prevent Vcore fluctuations caused by frequency switching.
It is strongly recommended to include it to avoid issues caused by self-removal. */_soft_delay_(0x50);rcu_ahb_clock_config(RCU_AHB_CKSYS_DIV2);_soft_delay_(0x50);rcu_ahb_clock_config(RCU_AHB_CKSYS_DIV4);_soft_delay_(0x50);rcu_ahb_clock_config(RCU_AHB_CKSYS_DIV8);_soft_delay_(0x50);rcu_ahb_clock_config(RCU_AHB_CKSYS_DIV16);_soft_delay_(0x50);rcu_system_clock_source_config(RCU_CKSYSSRC_IRC8M);_soft_delay_(200);rcu_ahb_clock_config(RCU_AHB_CKSYS_DIV1);pmu_to_deepsleepmode(PMU_LDO_LOWPOWER,PMU_LOWDRIVER_DISABLE,WFI_CMD);}}}voidled_config(void){gd_eval_led_init(LED2);gd_eval_led_init(LED3);gd_eval_led_init(LED4);gd_eval_led_init(LED5);}