{ uint32_t irq_status; while(1) { SYS_DisableAllIrq( &irq_status ); if( true == g_irq_button_event ) { tmos_clear_event( main_func_get_taskid(), BUTTON_IRQ_EVENT); tmos_set_event( main_func_get_taskid(), BUTTON_IRQ_EVENT); g_irq_button_event = false; } SYS_RecoverIrq( irq_status ); TMOS_SystemProcess(); } } __attribute__((interrupt("WCH-Interrupt-fast"))) __attribute__((section(".highcode"))) void GPIOA_IRQHandler(void) { if(GPIOA_ReadITFlagBit(BUTTON_MAINTENANCE_PIN)){ g_irq_button_event = true; PRINT("aaaaaaaaaaaaaa\n"); if(R32_PA_PIN & (BUTTON_MAINTENANCE_PIN)) GPIOA_ITModeCfg(BUTTON_MAINTENANCE_PIN, GPIO_ITMode_LowLevel); else GPIOA_ITModeCfg(BUTTON_MAINTENANCE_PIN, GPIO_ITMode_HighLevel); //GPIOA_ClearITFlagBit(BUTTON_MAINTENANCE_PIN); }else{ PRINT("bbbbbbbbbbbbb\n"); } }
按键状态变换一次就执行一次任务。在不开启休眠HAL_SLEEP时,运行正常,但是开启休眠后,就不能按一次按键打印一次,而且放开后才执行两次
热门产品 :
CH585: 集成高速USB和NFC的蓝牙MCU