标签:copy code 配置 print 系统 gpio name 串口调试 col
1 /********************************** (C) COPYRIGHT ******************************* 2 * File Name : Main.c 3 * Author : WCH 4 * Version : V1.0 5 * Date : 2018/12/15 6 * Description : 系统睡眠模式并唤醒演示:GPIOA_6作为唤醒源,共6种睡眠等级 7 *******************************************************************************/ 8 9 #include "CH57x_common.h" 10 11 void DebugInit(void) 12 { 13 GPIOA_SetBits(GPIO_Pin_9); 14 GPIOA_ModeCfg(GPIO_Pin_9, GPIO_ModeOut_PP_5mA); 15 UART1_DefInit(); 16 } 17 18 int main() 19 { 20 /* 配置串口调试 */ 21 DebugInit(); 22 PRINT( "Start @ChipID=%02X\n", R8_CHIP_ID ); 23 DelayMs(500); 24 25 #if 1 26 /* 配置唤醒源为 GPIO - PA6 */ 27 GPIOA_ModeCfg( GPIO_Pin_6, GPIO_ModeIN_PU ); 28 GPIOA_ITModeCfg( GPIO_Pin_6, GPIO_ITMode_FallEdge ); // 下降沿唤醒 29 NVIC_EnableIRQ( GPIO_IRQn ); 30 PWR_PeriphWakeUpCfg( ENABLE, RB_SLP_GPIO_WAKE ); 31 #endif 32 33 #if 1 34 PRINT( "IDLE mode sleep \n"); 35 DelayMs(1); 36 LowPower_Idle(); 37 PRINT( "wake.. \n"); 38 DelayMs(500); 39 #endif 40 41 #if 1 42 PRINT( "Halt_1 mode sleep \n"); 43 DelayMs(1); 44 LowPower_Halt_1(); 45 PRINT( "wake.. \n"); 46 DelayMs(500); 47 #endif 48 49 #if 1 50 PRINT( "Halt_2 mode sleep \n"); 51 DelayMs(1); 52 LowPower_Halt_2(); 53 PRINT( "wake.. \n"); 54 DelayMs(500); 55 #endif 56 57 #if 1 58 PRINT( "sleep mode sleep \n"); 59 DelayMs(1); 60 LowPower_Sleep( RB_PWR_RAM14K|RB_PWR_RAM2K ); //只保留14+2K SRAM 供电 61 PRINT( "wake.. \n"); 62 DelayMs(500); 63 #endif 64 65 #if 1 66 PRINT( "shut down mode sleep \n"); 67 DelayMs(1); 68 LowPower_Shutdown( NULL ); //全部断电,唤醒后复位 69 PRINT( "wake.. \n"); 70 DelayMs(500); 71 #endif 72 73 while(1); 74 } 75 76 77 void GPIO_IRQHandler(void) 78 { 79 GPIOA_ClearITFlagBit( GPIO_Pin_6 ); 80 PRINT( "wake.. \n"); 81 }
标签:copy code 配置 print 系统 gpio name 串口调试 col
原文地址:https://www.cnblogs.com/kingboy100/p/12419546.html