diff --git a/Makefile b/Makefile index e64aa4e..26eda9d 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ SRCS := \ CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_pwr.c \ CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_sys.c \ CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_timer0.c \ + CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_timer1.c \ CH5xx_ble_firmware_library/StdPeriphDriver/CH58x_timer3.c \ CH5xx_ble_firmware_library/RVMSIS/core_riscv.c \ CH5xx_ble_firmware_library/Startup/startup_CH583.S \ diff --git a/src/main.c b/src/main.c index 3c3ebe9..2a7bde6 100644 --- a/src/main.c +++ b/src/main.c @@ -45,6 +45,9 @@ int main() TMR0_ITCfg(ENABLE, TMR0_3_IT_CYC_END); PFIC_EnableIRQ(TMR0_IRQn); + TMR1_TimerInit((FREQ_SYS / 1000)); + TMR1_ITCfg(ENABLE, TMR0_3_IT_CYC_END); + TMR3_TimerInit(FREQ_SYS / 200); TMR3_ITCfg(ENABLE, TMR0_3_IT_CYC_END); PFIC_EnableIRQ(TMR3_IRQn); @@ -58,6 +61,9 @@ int main() screen_push(&badge_screen); + // set SEVONPEND + PFIC->SCTLR |= (1 << 4); + while (1) { WWDG_SetCounter(0x7F); static int btldr_timer = 0; @@ -108,6 +114,11 @@ int main() TMOS_SystemProcess(); cdc_tick(); hid_tick(); - DelayMs(1); + + while (!TMR1_GetITFlag(TMR0_3_IT_CYC_END)) { + __SEV(); + __asm__ volatile("wfi"); + } + TMR1_ClearITFlag(TMR0_3_IT_CYC_END); } }