diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index 406480d..3af5a97 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -312,15 +312,15 @@ void StartButtonDetect(void *argument) /* Infinite loop */ for(;;) { - //长按�???????�??????? if(NaviKit.sys.power_btn == true) {//power btn has been pushed - osDelay(2000); + osDelay(1000); if(NaviKit.sys.power_btn == true) - {//power btn has been pushed more than 2000 ms + {//power btn has been pushed more than 1000 ms if(NaviKit.sys.sta == runing) {//system is runing now, user request to shutdown enter_shutdown_state(); + NaviKit.sys.sta = shutdown; printf("shutdown \n"); Beep(50); @@ -328,7 +328,7 @@ void StartButtonDetect(void *argument) } else if(NaviKit.sys.sta == shutdown) {//system is shutdown now , user request to power on - enter_runing_state(); + NaviKit.sys.sta = runing; printf("power on \n"); Beep(200); osDelay(500); @@ -339,20 +339,20 @@ void StartButtonDetect(void *argument) { if(NaviKit.sys.sta == runing) { - enter_sleep_state(); + NaviKit.sys.sta = sleep; } else if(NaviKit.sys.sta == sleep) { - enter_runing_state(); + NaviKit.sys.sta = runing; } } } if(NaviKit.sys.custom_btn == true ) {//custom button has been pushed - osDelay(2000); + osDelay(1000); if(NaviKit.sys.custom_btn == true ) - {//custom button has been pushed over 2000 ms + {//custom button has been pushed over 1000 ms if(NaviKit.sys.sta == runing) { // restart(); @@ -414,15 +414,18 @@ void StartStateSwitchTask(void *argument) switch(NaviKit.sys.sta) { case shutdown: - { - + {//only from runing state + if(NaviKit.sys.last_sta == runing) + enter_shutdown_state(); }break; case runing: - { - + {//from sleep and shutdown state + enter_runing_state(); }break; case sleep: - { + {//only form runing state + if(NaviKit.sys.last_sta == runing) + enter_sleep_state(); }break; } @@ -451,11 +454,8 @@ void StartSOMPowerManageTask(void *argument) /* Private application code --------------------------------------------------*/ /* USER CODE BEGIN Application */ -void sys_start() -{ - - -} + + //power off by button pushed void force_sys_stop() { @@ -516,12 +516,9 @@ void enter_shutdown_state() HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_RESET); osDelay(100); - NaviKit.sys.sta = shutdown; } void enter_sleep_state() { - - // HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100); HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100); HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_RESET); osDelay(100); @@ -547,14 +544,10 @@ void enter_sleep_state() HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_RESET); osDelay(100); HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_RESET); osDelay(100); - NaviKit.sys.sta = sleep; } void enter_runing_state() { - NaviKit.sys.sta = runing; - - Beep(40); HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_SET); osDelay(100); HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_SET); osDelay(100); @@ -586,7 +579,7 @@ void enter_runing_state() } - +//printf redefine #ifdef __GNUC__ #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) PUTCHAR_PROTOTYPE