From 1708b9ce6ab2c0098bc3a9ba6457fea5db8b7a6d Mon Sep 17 00:00:00 2001 From: ranchuan Date: Tue, 14 Nov 2023 18:17:11 +0800 Subject: [PATCH] =?UTF-8?q?=20=20=20=20V2.06=20=20=20=20=20CAN=E6=80=BB?= =?UTF-8?q?=E7=BA=BF=E5=8F=91=E9=80=81=E6=95=B0=E6=8D=AE=E6=BA=90=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E5=BC=BA=E5=88=B6=E6=94=B9=E4=B8=BA=E6=9C=AC=E6=9C=BA?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=EF=BC=8C=E7=9B=AE=E6=A0=87=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E5=BC=BA=E5=88=B6=E6=94=B9=E4=B8=BA0=20=20=20=20=20EW=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E5=8D=87=E7=BA=A7=E6=B7=BB=E5=8A=A0=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=9C=A8app=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +- checher_slave.uvoptx | 2 +- source/ReadMe.txt | 4 +++ source/elec_det/interface/EWChecker.c | 50 +++++++++++++++++++++++---- source/interface/if_can.c | 4 +-- source/main/compiler_info.h | 4 +-- source/prebuild.py | 2 +- 7 files changed, 56 insertions(+), 13 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index c46bc34..2c3f921 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,6 +6,7 @@ "opt.h": "c", "if_can.h": "c", "board.h": "c", - "prot_uc.h": "c" + "prot_uc.h": "c", + "tran_for_slave.h": "c" } } \ No newline at end of file diff --git a/checher_slave.uvoptx b/checher_slave.uvoptx index 1a73382..35f8f2d 100644 --- a/checher_slave.uvoptx +++ b/checher_slave.uvoptx @@ -1507,7 +1507,7 @@ rt_thread - 1 + 0 0 0 0 diff --git a/source/ReadMe.txt b/source/ReadMe.txt index 1d8fdd7..cd006d9 100644 --- a/source/ReadMe.txt +++ b/source/ReadMe.txt @@ -251,4 +251,8 @@ V2.05 重写延时等待函数,解决与模块之间通信间隔有可能过短的问题 修改硬件版本号时自动修改can波特率 +2023.11.14 + V2.06 + CAN总线发送数据源地址强制改为本机地址,目标地址强制改为0 + EW模块升级添加运行在app判断 diff --git a/source/elec_det/interface/EWChecker.c b/source/elec_det/interface/EWChecker.c index 5a1676f..0f7d325 100644 --- a/source/elec_det/interface/EWChecker.c +++ b/source/elec_det/interface/EWChecker.c @@ -252,10 +252,47 @@ void EW_Updata(void) uint8_t pack_len=UPDATA_PACK_LEN; uint32_t crc=0; uint32_t crc_module=0; + + // 充电时间 6000 + int time_charg=checker_runcfg.params[0]; + // 加载app时间 6000 + int time_loadapp=checker_runcfg.params[1]; + // 总线关断时间 1000 + int time_poweroff=checker_runcfg.params[2]; + // 升级模式,0,无app时升级;1,无条件升级 + int updata_mode=checker_runcfg.params[3]; + + retry: delay_ms(100); ret=EW_bootCharg(); + if(ret){ + // 有可能在app中 + delay_ms(time_loadapp); + if(EW_appCommTest()==0){ + if(updata_mode==1){ + delay_ms(50); + EW_RunBootLoader(0,1); + updata_mode=2; + DBG_LOG("turn to bootloader,retry."); + goto retry; + }else if(updata_mode==2){ + // 已经重试过一次了,bootloader还是不能通信 + DBG_WARN("boot commit failed."); + ret=12; + goto err; + }else if(updata_mode==0){ + // 有app的时候不需要升级 + DBG_WARN("no need updata."); + ret=0; + goto err; + } + }else{ + // bootloader 和 app 都不能通信 + DBG_WARN("commit failed"); + } + } if(ret) {ret=1;goto err;} - delay_ms(6000); + delay_ms(time_charg); ret=EW_bootErease(); if(ret) {ret=2;goto err;} delay_ms(600); @@ -279,7 +316,7 @@ void EW_Updata(void) delay_ms(50); ret=EW_bootJump(); if(ret) {ret=6;goto err;} - delay_ms(6000); + delay_ms(time_loadapp); ret=EW_EnWriteMTP(0,1); if(ret) {ret=7;goto err;} DBG_LOG("EW_EnWriteMTP success."); @@ -298,9 +335,9 @@ void EW_Updata(void) DBG_LOG("EW_ReadMTP check success."); delay_ms(1); XTBUS_OFF; - delay_ms(1000); + delay_ms(time_poweroff); XTBUS_ON; - delay_ms(6000); + delay_ms(time_loadapp); ret=EW_appCommTest(); if(ret) {ret=11;goto err;} DBG_LOG("EW_appCommTest success."); @@ -1007,7 +1044,7 @@ void EW_Test_Boom() Power_SetSampleRange_Seep(EWChecker_ChgEnger_Sample_R,ADC_SPEED_HIGH); ADC_GetCurADCFast(); - delay_ms(checker_runcfg.params[3]); + delay_ms(checker_runcfg.params[2]); if(checker_runcfg.params[0] > 0 || checker_runcfg.params[1] > 0) { us_temp = AD_GetBusCurUp(checker_runcfg.params[1],checker_runcfg.params[0]); @@ -1139,7 +1176,7 @@ EW_Test_WriteThreedCode, //11 模拟注码 EW_Test_VerifyThreedCode, //12 EW_Test_CheckSelf, //13 芯片自检 EW_Test_CheckeState, //14状态检测 -EW_Test_Charge, //15 充能统计 +EW_Test_Charge, //15 充电 EW_Test_DisChg, //16 放电 EW_Test_SetDelay, //17写延时 EW_Test_ReadDelay, //18读延时 @@ -1152,6 +1189,7 @@ EW_Test_WriteFacBuff, //24缓存数据写入MTP EW_Test_VerifyFacBuff, //25验证缓存数据 EW_Test_PowerOFF, //26 关总线 EW_Updata, //27 升级 +EW_Test_ChgEnergy, //28 充能统计 (void*)0 //数组结束 }; diff --git a/source/interface/if_can.c b/source/interface/if_can.c index 42bcc9d..ed1eb02 100644 --- a/source/interface/if_can.c +++ b/source/interface/if_can.c @@ -347,8 +347,8 @@ static int read(uart_def *u,uint8_t *b,int len) } static int write(uart_def *u,const uint8_t *b,int len) { - uint8_t src=b[4]; - uint8_t dst=b[5]; + uint8_t src=elec_local_addr(); + uint8_t dst=0; uint8_t ret; ret=YeCan_SendFrame(src,dst,b,len); if(ret==0) return len; diff --git a/source/main/compiler_info.h b/source/main/compiler_info.h index 3084feb..9d56814 100644 --- a/source/main/compiler_info.h +++ b/source/main/compiler_info.h @@ -6,8 +6,8 @@ -#define BUILD_DATE "2023-11-13 17:12:52" -#define SOFT_VERSION "2.05" +#define BUILD_DATE "2023-11-14 18:09:40" +#define SOFT_VERSION "2.06" diff --git a/source/prebuild.py b/source/prebuild.py index 6706e83..6400efd 100644 --- a/source/prebuild.py +++ b/source/prebuild.py @@ -7,7 +7,7 @@ import mycopy # 定义软件版本号 -SOFT_VERION = "2.05" +SOFT_VERION = "2.06"