#include"gd32f30x.h"#include<stdio.h>#include"gd32f307c_eval.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){/* enable clock */rcu_periph_clock_enable(RCU_PMU);/* LED configuration and turn on all LEDs */led_config();gd_eval_led_on(LED2);gd_eval_led_on(LED4);gd_eval_led_on(LED3);gd_eval_led_on(LED5);/* tamper key configuration */gd_eval_key_init(KEY_TAMPER,KEY_MODE_GPIO);/* enable wakeup pin */pmu_wakeup_pin_enable();/* press tamper key to enter standby mode and use wakeup key to wakeup mcu */while(1){if(RESET==gpio_input_bit_get(TAMPER_KEY_GPIO_PORT,TAMPER_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_standbymode();}}}voidled_config(void){gd_eval_led_init(LED2);gd_eval_led_init(LED3);gd_eval_led_init(LED4);gd_eval_led_init(LED5);}