From 4e8401861f6196bbf8db5e7e53909a76bc23b536 Mon Sep 17 00:00:00 2001 From: ThinkPad-T460P Date: Mon, 7 Sep 2020 18:50:29 +0800 Subject: [PATCH] update --- Core/Inc/navikit.h | 2 +- Core/Src/freertos.c | 4 ++-- Core/Src/navikit.c | 23 ++++++++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-) 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");