Update freertos.c

master
bookshiyi 2020-07-15 18:42:01 +08:00
parent 5e594244e9
commit a83be190aa
1 changed files with 19 additions and 26 deletions

View File

@ -312,15 +312,15 @@ void StartButtonDetect(void *argument)
/* Infinite loop */ /* Infinite loop */
for(;;) for(;;)
{ {
//长按<E995BF>???????<3F>???????
if(NaviKit.sys.power_btn == true) if(NaviKit.sys.power_btn == true)
{//power btn has been pushed {//power btn has been pushed
osDelay(2000); osDelay(1000);
if(NaviKit.sys.power_btn == true) 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) if(NaviKit.sys.sta == runing)
{//system is runing now, user request to shutdown {//system is runing now, user request to shutdown
enter_shutdown_state(); enter_shutdown_state();
NaviKit.sys.sta = shutdown;
printf("shutdown \n"); printf("shutdown \n");
Beep(50); Beep(50);
@ -328,7 +328,7 @@ void StartButtonDetect(void *argument)
} }
else if(NaviKit.sys.sta == shutdown) else if(NaviKit.sys.sta == shutdown)
{//system is shutdown now , user request to power on {//system is shutdown now , user request to power on
enter_runing_state(); NaviKit.sys.sta = runing;
printf("power on \n"); printf("power on \n");
Beep(200); Beep(200);
osDelay(500); osDelay(500);
@ -339,20 +339,20 @@ void StartButtonDetect(void *argument)
{ {
if(NaviKit.sys.sta == runing) if(NaviKit.sys.sta == runing)
{ {
enter_sleep_state(); NaviKit.sys.sta = sleep;
} }
else if(NaviKit.sys.sta == sleep) else if(NaviKit.sys.sta == sleep)
{ {
enter_runing_state(); NaviKit.sys.sta = runing;
} }
} }
} }
if(NaviKit.sys.custom_btn == true ) if(NaviKit.sys.custom_btn == true )
{//custom button has been pushed {//custom button has been pushed
osDelay(2000); osDelay(1000);
if(NaviKit.sys.custom_btn == true ) 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) if(NaviKit.sys.sta == runing)
{ {
// restart(); // restart();
@ -414,15 +414,18 @@ void StartStateSwitchTask(void *argument)
switch(NaviKit.sys.sta) switch(NaviKit.sys.sta)
{ {
case shutdown: case shutdown:
{ {//only from runing state
if(NaviKit.sys.last_sta == runing)
enter_shutdown_state();
}break; }break;
case runing: case runing:
{ {//from sleep and shutdown state
enter_runing_state();
}break; }break;
case sleep: case sleep:
{ {//only form runing state
if(NaviKit.sys.last_sta == runing)
enter_sleep_state();
}break; }break;
} }
@ -451,11 +454,8 @@ void StartSOMPowerManageTask(void *argument)
/* Private application code --------------------------------------------------*/ /* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */ /* USER CODE BEGIN Application */
void sys_start()
{
}
//power off by button pushed //power off by button pushed
void force_sys_stop() 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); 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() 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_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_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); 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_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); 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() 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(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); 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__ #ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch) #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
PUTCHAR_PROTOTYPE PUTCHAR_PROTOTYPE