CAN总线发送数据源地址强制改为本机地址,目标地址强制改为0
    EW模块升级添加运行在app判断
This commit is contained in:
ranchuan
2023-11-14 18:17:11 +08:00
parent bff9b1b774
commit 1708b9ce6a
7 changed files with 56 additions and 13 deletions

View File

@@ -251,4 +251,8 @@
V2.05
重写延时等待函数,解决与模块之间通信间隔有可能过短的问题
修改硬件版本号时自动修改can波特率
2023.11.14
V2.06
CAN总线发送数据源地址强制改为本机地址目标地址强制改为0
EW模块升级添加运行在app判断

View File

@@ -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 //数组结束
};

View File

@@ -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;

View File

@@ -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"

View File

@@ -7,7 +7,7 @@ import mycopy
# 定义软件版本号
SOFT_VERION = "2.05"
SOFT_VERION = "2.06"