diff --git a/Core/Inc/navikit.h b/Core/Inc/navikit.h index d7db43a..9743d82 100644 --- a/Core/Inc/navikit.h +++ b/Core/Inc/navikit.h @@ -112,7 +112,7 @@ void NaviKit_var_init(); //power state machine switch function void enter_isp_state(); void enter_runing_state(); -void enter_shutdown_state(); +void enter_shutdown_state(uint8_t timeout = 0); void enter_sleep_state(); void enter_dfu_state(); diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c index c94d08d..4f0944d 100644 --- a/Core/Src/freertos.c +++ b/Core/Src/freertos.c @@ -479,8 +479,8 @@ void StartStateSwitchTask(void *argument) { case shutdown: {//only from running state - if(NaviKit.sys.sta == running) - enter_shutdown_state(); + if((NaviKit.sys.sta == running))// && (NaviKit.som.shutdown_req == true) + enter_shutdown_state(); }break; case running: {//from sleep and shutdown state diff --git a/Core/Src/navikit.c b/Core/Src/navikit.c index 0dfb15b..37008d4 100644 --- a/Core/Src/navikit.c +++ b/Core/Src/navikit.c @@ -52,18 +52,18 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { if(GPIO_Pin == SOM_SHUTDOWN_REQ_Pin) { - if(HAL_GPIO_ReadPin(SOM_SHUTDOWN_REQ_GPIO_Port, SOM_SHUTDOWN_REQ_Pin)==GPIO_PIN_SET) - {//Rising edge trigger -// NaviKit.som.shutdown_req = true; - - } if(HAL_GPIO_ReadPin(SOM_SHUTDOWN_REQ_GPIO_Port, SOM_SHUTDOWN_REQ_Pin)==GPIO_PIN_RESET) {//falling edge trigger -// NaviKit.som.shutdown_req = false; if(NaviKit.sys.sta == running) - { - NaviKit.sys.next_sta = shutdown; + {//if jetson nano shutdown output low,the power_en should be set low less than 10us + HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_RESET); + NaviKit.sys.next_sta = shutdown; + printf("som request to shutdown"); } + NaviKit.som.shutdown_req = true; + } + else{//Rising edge trigger + NaviKit.som.shutdown_req = false; } } @@ -129,10 +129,10 @@ void enter_isp_state() } } - -void enter_shutdown_state() +//timeout:the time of wait +void enter_shutdown_state(uint8_t timeout) { - printf("Enter to shutdown state \n"); + printf("Enter to shutdown state\n"); Beep(50); HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_RESET); osDelay(100); @@ -165,6 +165,7 @@ void enter_shutdown_state() HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_RESET); osDelay(100); } + void enter_sleep_state() { printf("Enter to sleep state \n");