From c1ef11a1cdf34ac384e8e09c1fa0a6c07dfa3af2 Mon Sep 17 00:00:00 2001 From: payton Date: Wed, 20 Dec 2023 09:54:14 +0800 Subject: [PATCH] =?UTF-8?q?1.mcu=E5=8D=87=E7=BA=A7=E8=B0=83=E6=95=B4?= =?UTF-8?q?=EF=BC=9A=E5=8D=87=E7=BA=A7=E5=BC=80lcd=EF=BC=9Bmcu=E8=AF=BB?= =?UTF-8?q?=E5=86=99=E8=B6=85=E6=97=B6=E6=97=B6=E9=97=B4=E8=B0=83=E6=95=B4?= =?UTF-8?q?=EF=BC=9B2.lib=E9=87=8C=E7=9A=84usb=E6=A0=87=E8=AF=86=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/cardv/SrcCode/System/SysMain_Exe.c | 2 +- .../source/sf_app/code/include/sf_param_enum.h | 3 ++- .../sf_app/code/source/paramMng/sf_param_common.c | 2 ++ .../sf_app/code/source/systemMng/sf_commu_mcu.c | 15 +++++++++++++-- code/lib/source/sifar/code/include/sf_mcu.h | 1 + .../source/sifar/code/source/mcu/sf_mcu_client.c | 9 +++++++-- .../code/driver/na51089/source/mcu/sf_commu_mcu.c | 2 +- rtos/code/driver/na51089/source/mcu/sf_mcu.c | 3 ++- 8 files changed, 29 insertions(+), 8 deletions(-) diff --git a/code/application/source/cardv/SrcCode/System/SysMain_Exe.c b/code/application/source/cardv/SrcCode/System/SysMain_Exe.c index a479a460c..e52e84f72 100755 --- a/code/application/source/cardv/SrcCode/System/SysMain_Exe.c +++ b/code/application/source/cardv/SrcCode/System/SysMain_Exe.c @@ -158,7 +158,7 @@ INT32 System_GetBootFirstMode(void) { return PRIMARY_MODE_USBMSDC; } - else if((PWR_ON_SETUP != PowerOnMode) /*|| (sf_get_fw_update())*/) + else if((PWR_ON_SETUP != PowerOnMode) && (PWR_ON_MCU_UPDATA != PowerOnMode)/*|| (sf_get_fw_update())*/) { return PRIMARY_MODE_TRANSCODE; } diff --git a/code/application/source/sf_app/code/include/sf_param_enum.h b/code/application/source/sf_app/code/include/sf_param_enum.h index 0e39a30f5..17ca545c8 100755 --- a/code/application/source/sf_app/code/include/sf_param_enum.h +++ b/code/application/source/sf_app/code/include/sf_param_enum.h @@ -321,7 +321,8 @@ typedef enum sf_STARTUP_TYPE_E SF_MCU_STARTUP_RESET = 0x0A,/*power on to reset(reserve)*/ SF_MCU_STARTUP_SYN_PARAM = 0x0B,/*power on to syn param(reserve)*/ SF_MCU_STARTUP_BATCH_SEND= 0x0C,/*power on to send batch*/ - SF_MCU_STARTUP_BUTT = 0X0D, + SF_MCU_STARTUP_MCU_UPDATA= 0x0F,/*power on to send batch*/ + SF_MCU_STARTUP_BUTT = 0X10, } SF_STARTUP_TYPE_E; typedef enum sfPOWEROFF_TYPE_E diff --git a/code/application/source/sf_app/code/source/paramMng/sf_param_common.c b/code/application/source/sf_app/code/source/paramMng/sf_param_common.c index a10a9797f..5ff399edb 100755 --- a/code/application/source/sf_app/code/source/paramMng/sf_param_common.c +++ b/code/application/source/sf_app/code/source/paramMng/sf_param_common.c @@ -995,6 +995,8 @@ const SF_CHAR* sf_poweron_type_string(SF_STARTUP_TYPE_E enType) return "SF_MCU_STARTUP_SYN_PARAM"; case SF_MCU_STARTUP_BATCH_SEND: return "SF_MCU_STARTUP_BATCH_SEND"; + case SF_MCU_STARTUP_MCU_UPDATA: + return "SF_MCU_STARTUP_MCU_UPDATA"; default: return "unknown poweron type!!!"; } diff --git a/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu.c b/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu.c index 17300097f..151de0b01 100755 --- a/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu.c +++ b/code/application/source/sf_app/code/source/systemMng/sf_commu_mcu.c @@ -40,6 +40,7 @@ #include "kwrap/debug.h" #include "kwrap/util.h" #include +#include "sf_system.h" #define SERIAL_DEVICE_PATH "/dev/ttyS2" #ifdef __cplusplus @@ -707,7 +708,7 @@ unsigned int sf_get_mcu_reg_ack_depack_many(unsigned char reg[], unsigned char v int sf_commu_wait(unsigned char cmd) { - if(sf_mcu_flag_wait_done_timeout(cmd, 60)) + if(sf_mcu_flag_wait_done_timeout(cmd, 100)) { sf_commu_reset(); return - 1; @@ -963,7 +964,17 @@ unsigned char sf_commu_parse_mcu_data(unsigned char * src, unsigned int len) { sf_set_pir_statu_flag(0); sf_set_module_sleep_flag(0); - sf_com_message_send_to_cardv(&stMessageBuf); + if((PWR_ON_SETUP != sf_convert_power_on_mode()) && (PWR_ON_USB!= sf_convert_power_on_mode())) + { + printf("[power off] %s(%d)\n", __FUNCTION__, __LINE__); + sf_set_power_off_flag(1); + sf_app_battery_stop(); + system("reboot"); + } + else + { + sf_com_message_send_to_cardv(&stMessageBuf); + } } else if(0 == stMessageBuf.arg3) //ON->OFF { diff --git a/code/lib/source/sifar/code/include/sf_mcu.h b/code/lib/source/sifar/code/include/sf_mcu.h index 3bbd3516c..93b14f808 100644 --- a/code/lib/source/sifar/code/include/sf_mcu.h +++ b/code/lib/source/sifar/code/include/sf_mcu.h @@ -51,6 +51,7 @@ #define PWR_ON_GPRS_INIT 0x0A #define PWR_ON_TIME_SYNC 0x0B #define PWR_ON_TIME_SEND 0x0C +#define PWR_ON_MCU_UPDATA 0x0F /*REG FUNCTION_SWTICH*/ #define PIR_OFF 0x00 diff --git a/code/lib/source/sifar/code/source/mcu/sf_mcu_client.c b/code/lib/source/sifar/code/source/mcu/sf_mcu_client.c index 0125885b7..028855846 100644 --- a/code/lib/source/sifar/code/source/mcu/sf_mcu_client.c +++ b/code/lib/source/sifar/code/source/mcu/sf_mcu_client.c @@ -46,6 +46,7 @@ #include #include "UIInfo/UIInfo.h" #include "sf_param_enum.h" +#include "GxUSB.h" //#include "../../../application/source/cardv/SrcCode/PrjInc.h" @@ -1910,7 +1911,11 @@ BOOL sf_get_mode_flag(void) BOOL sf_is_usb_flag(void) { - return GxUSB_GetIsUSBPlug(); + if(GxUSB_GetConnectType() == 1) + { + return 1; + } + return 0;//GxUSB_GetIsUSBPlug(); } void sf_calculate_daily_report(UINT8*dailyHour, UINT8*dailyMin) @@ -2144,7 +2149,7 @@ void sf_set_power_on_mode(UINT8 data) ModeFlag = 0; PowerOnMode = data; PowerOnMode &= 0x0f; - if(1 == PowerOnMode) + if((1 == PowerOnMode) || 15 == PowerOnMode) { ConfigureModeFlag = 1; } diff --git a/rtos/code/driver/na51089/source/mcu/sf_commu_mcu.c b/rtos/code/driver/na51089/source/mcu/sf_commu_mcu.c index 1e80ee3c4..3030c01dd 100644 --- a/rtos/code/driver/na51089/source/mcu/sf_commu_mcu.c +++ b/rtos/code/driver/na51089/source/mcu/sf_commu_mcu.c @@ -486,7 +486,7 @@ unsigned int sf_get_mcu_reg_ack_depack_many(unsigned char reg[], unsigned char v int sf_commu_wait(unsigned char cmd) { //sf_mcu_flag_set_done(cmd); - if(sf_mcu_flag_wait_done_timeout(cmd, 30)) + if(sf_mcu_flag_wait_done_timeout(cmd, 100)) { sf_commu_reset(); return - 1; diff --git a/rtos/code/driver/na51089/source/mcu/sf_mcu.c b/rtos/code/driver/na51089/source/mcu/sf_mcu.c index 258aa0731..b0866f118 100755 --- a/rtos/code/driver/na51089/source/mcu/sf_mcu.c +++ b/rtos/code/driver/na51089/source/mcu/sf_mcu.c @@ -691,13 +691,14 @@ UINT8 sf_get_power_on_mode(void) if(gpio_getIntStatus(GPIO_INT_USBPLUGIN)) { PowerOnMode = PWR_ON_USB; + ConfigureModeFlag = 1; } else{ //PowerOnMode = sf_mcu_power_on_para_get(SF_MCU_POWERON); PowerOnMode = sf_mcu_power_on_para_get(SF_MCU_STARTMODE); //PowerOnMode &= 0x0f; //sf_is_night_mode(1); - if(1 == PowerOnMode) + if((PWR_ON_SETUP == PowerOnMode) || (PWR_ON_MCU_UPDATA == PowerOnMode)) { ConfigureModeFlag = 1; }