diff --git a/checher_slave.uvoptx b/checher_slave.uvoptx
index 69e25bb..78c0778 100644
--- a/checher_slave.uvoptx
+++ b/checher_slave.uvoptx
@@ -153,24 +153,7 @@
-
-
- 0
- 0
- 185
- 1
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- .\source\rt_thread\libcpu\arm\cortex-m3\context_rvds.S
-
-
-
-
+
0
@@ -316,7 +299,7 @@
1
0
- 0
+ 1
18
@@ -557,7 +540,7 @@
1
0
- 1
+ 0
18
@@ -652,22 +635,6 @@
\\checker_slave_app\source/rt_thread/board.c\108
-
- 1
- 0
- 185
- 1
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- .\source\rt_thread\libcpu\arm\cortex-m3\context_rvds.S
-
-
-
diff --git a/checher_slave.uvprojx b/checher_slave.uvprojx
index abf8932..7708fc1 100644
--- a/checher_slave.uvprojx
+++ b/checher_slave.uvprojx
@@ -3555,57 +3555,6 @@
EW_TestUsartApp.c
1
.\source\elec_det\test\EW_TestUsartApp.c
-
-
- 2
- 0
- 0
- 0
- 0
- 0
- 2
- 2
- 2
- 2
- 11
-
-
- 1
-
-
-
- 2
- 0
- 2
- 2
- 2
- 2
- 2
- 2
- 2
- 2
- 0
- 2
- 2
- 2
- 2
- 2
- 0
- 0
- 2
- 2
- 2
- 2
- 2
-
-
-
-
-
-
-
-
-
EWCheckerTest.c
diff --git a/source/ReadMe.txt b/source/ReadMe.txt
index c6a39ca..78dc287 100644
--- a/source/ReadMe.txt
+++ b/source/ReadMe.txt
@@ -316,3 +316,8 @@
ew写延时验证成功,ej写流水号验证成功
解决上位机协议crc错误依然执行命令的bug
注意:小板方案中芯片类型与主板不同时,使用槽任务可能造成各种异常问题(死机,死循环,不返回数据等)
+2023.12.29
+ 适配Ew开头的协议
+ 注释iic相关命令,添加命令jwtcrc用于验证jwt程序是否正常
+ EW_Updata 添加错误12表示小板中无jwt程序
+
diff --git a/source/codec/codec.c b/source/codec/codec.c
index 0cc9900..5c03450 100644
--- a/source/codec/codec.c
+++ b/source/codec/codec.c
@@ -314,14 +314,5 @@ protuc_codec_export(ym_slave,protm_decode,protm_encode);
-// 小板ew协议解码
-array_def *protew_decode(protu_def *p,array_def *data)
-{
-
-}
-array_def *protew_encode(protu_def *p,array_def *data)
-{
-}
-// protuc_codec_export(ew_slave,protm_decode,protm_encode);
diff --git a/source/elec_det/elec_cmd.c b/source/elec_det/elec_cmd.c
index 0c843f0..92125c7 100644
--- a/source/elec_det/elec_cmd.c
+++ b/source/elec_det/elec_cmd.c
@@ -52,7 +52,7 @@ static int cmd_iic_erase(list_def *argv)
cmd_print("cmd end,ret=%d.",ret);
return 0;
}
-commend_export(iic_erase,cmd_iic_erase,"erase mtp via iic,param:mtp_addr,erase_mode")
+//commend_export(iic_erase,cmd_iic_erase,"erase mtp via iic,param:mtp_addr,erase_mode")
@@ -89,7 +89,7 @@ static int cmd_iic_updata(list_def *argv)
cmd_print("cmd end,ret=%d.",ret);
return 0;
}
-commend_export(iic_updata,cmd_iic_updata,"updata mtp via iic,param:mtp_addr,data_length")
+//commend_export(iic_updata,cmd_iic_updata,"updata mtp via iic,param:mtp_addr,data_length")
@@ -111,7 +111,7 @@ static int cmd_iic_read(list_def *argv)
cmd_print("cmd end,ret=%d.",ret);
return 0;
}
-commend_export(iic_read,cmd_iic_read,"read mtp via iic,param:mtp_addr,data_length")
+//commend_export(iic_read,cmd_iic_read,"read mtp via iic,param:mtp_addr,data_length")
diff --git a/source/elec_det/elec_io.c b/source/elec_det/elec_io.c
index 8df7647..0e2bcab 100644
--- a/source/elec_det/elec_io.c
+++ b/source/elec_det/elec_io.c
@@ -18,14 +18,32 @@
#include "elec_det.h"
#include "dev_flash.h"
#include "mystring.h"
+#include "prot_uc.h"
+#include "board.h"
+#include "transmit.h"
+#include "mystdlib.h"
#include "elec_io.h"
+
+
// 此文件实现elec模块的输入输出接口
+typedef struct{
+ tran_def *tran;
+}self_def;
+
+static self_def g_self;
+
int ConsoleUsart_send_bytes(uint8_t *d,int len)
{
+ self_def *s=&g_self;
+ if(s->tran){
+ array_def *r=arr_creat();
+ arr_appends(r,d,len);
+ emit tran_reply_signal(s->tran,arr_temp(r));
+ }
return 0;
}
@@ -64,7 +82,43 @@ void Ye_RunPlanCheckTest(void)
-
+// 小板ew协议解码
+array_def *protew_decode(protu_def *p,array_def *data)
+{
+ if((arr_get(data,0)=='E')&&(arr_get(data,1)=='w')){
+ str_set(p->str_err,"ok");
+ p->cmd=0x01;
+ return arr_duplicate(data);
+ }
+ str_set(p->str_err,"decode for Ew failed.");
+ return arr_creat();
+}
+array_def *protew_encode(protu_def *p,array_def *data)
+{
+ array_def *r;
+ r=arr_duplicate(data);
+ return r;
+}
+protuc_codec_export(ew_slave,protew_decode,protew_encode);
+
+static int ew_slave_dolater(ucport_def *u,uint8_t cmd,array_def *data,char *err_str)
+{
+ void EW_UsartApp_Push_Cmd(uint8_t* buf, uint16_t len);
+ EW_UsartApp_Push_Cmd(arr_data(data),arr_length(data));
+ return 0;
+}
+static ucport_def *ew_slave_fun(tran_def *t, uint8_t cmd,array_def *data)
+{
+ int ret=0;
+ self_def *s=&g_self;
+ s->tran=t;
+ ucport_def *u=calloc(1,sizeof(ucport_def));
+ u->p=t;
+ u->dolater=ew_slave_dolater;
+ u->dolater(u,cmd,data,"ok");
+ return (ucport_def *)u;
+}
+transmit_export(ew_slave,0x01,ew_slave_fun)
diff --git a/source/elec_det/elec_io.h b/source/elec_det/elec_io.h
index 80bc7e1..c51826d 100644
--- a/source/elec_det/elec_io.h
+++ b/source/elec_det/elec_io.h
@@ -40,10 +40,6 @@
}\
commend_export(cmd_,__msh_##fun_,#desc);
-
-#define ConsoleRxDisable()
-
-#define ConsoleRxEnable()
int ConsoleUsart_send_bytes(uint8_t *d,int len);
diff --git a/source/elec_det/hardware/adc_cfg.c b/source/elec_det/hardware/adc_cfg.c
index ecfa992..e2557f1 100644
--- a/source/elec_det/hardware/adc_cfg.c
+++ b/source/elec_det/hardware/adc_cfg.c
@@ -383,6 +383,69 @@ uint16_t AD_CurMonitor(uint32_t ul_times)
return ul_shake;
}
+
+
+static void ad_gets(uint16_t *v,int num)
+{
+ for(int i =0; i < num;i++)
+ {
+ v[i] = ADC_GetCurADCFast();
+ }
+}
+/*rc{ 重写电流采集 }*/
+uint16_t AD_CurMonitor_(uint32_t ul_times)
+{
+ uint32_t ul_count = 0, ul_count2;
+ uint16_t us_count = 0;
+ uint16_t aus_adc[20];
+ uint16_t us_maxadv=0,us_minadv = 4096;
+ uint16_t ul_shake = 0;
+ uint16_t us_mid;
+ ul_count2 = 0;
+ while(ul_times > 0)
+ {
+ ul_count = 0;
+ Get100usCount();
+ while(ul_count< 50000 && ul_count < ul_times)
+ {
+ us_maxadv = 0;
+ us_minadv = 0xFFF;
+
+ ad_gets(aus_adc,20);
+ Bubble_Sort_u16(aus_adc,20);
+ us_mid=aus_adc[10];
+ if(us_mid>us_maxadv){
+ us_maxadv=us_mid;
+ }
+ if(us_mid= ul_times)
+ {
+ LED1_Out = 0;
+ return ul_shake;
+ }
+ ul_times -= ul_count;
+ }
+ LED1_Out= 0;
+ return ul_shake;
+}
+
+
+
+
+
+
+
+
/*
@brief 电流降到指定电流下的时间
@param 采样超时
diff --git a/source/elec_det/interface/EWUpdata.c b/source/elec_det/interface/EWUpdata.c
index e095b9f..d922e29 100644
--- a/source/elec_det/interface/EWUpdata.c
+++ b/source/elec_det/interface/EWUpdata.c
@@ -29,6 +29,7 @@
#define UPDATA_CRC_ALL ((uint32_t *)(MC_CODE_ADDR+16*1024))[0]
#define UPDATA_CRC_APP ((uint32_t *)(MC_CODE_ADDR+16*1024))[1]
+#define UPDATA_FILE_NAME ((const char *)(MC_CODE_ADDR+16*1024+8))
@@ -50,7 +51,7 @@ static int cmd_jwt_boot_erase(list_def *argv)
ret=EW_bootErease();
return ret;
}
-commend_export(jwt_boot_erase,cmd_jwt_boot_erase,"jwt srase in boot")
+//commend_export(jwt_boot_erase,cmd_jwt_boot_erase,"jwt srase in boot")
// 跳转
@@ -70,7 +71,7 @@ static int cmd_jwt_boot_jump(list_def *argv)
ret=EW_bootJump();
return ret;
}
-commend_export(jwt_boot_jump,cmd_jwt_boot_jump,"jwt jump in boot")
+//commend_export(jwt_boot_jump,cmd_jwt_boot_jump,"jwt jump in boot")
// 充电
@@ -91,7 +92,7 @@ static int cmd_jwt_boot_charg(list_def *argv)
ret=EW_bootCharg();
return ret;
}
-commend_export(jwt_boot_charg,cmd_jwt_boot_charg,"jwt charg in boot")
+//commend_export(jwt_boot_charg,cmd_jwt_boot_charg,"jwt charg in boot")
@@ -112,7 +113,7 @@ static int cmd_jwt_boot_discharg(list_def *argv)
ret=EW_bootDisCharg();
return ret;
}
-commend_export(jwt_boot_discharg,cmd_jwt_boot_discharg,"jwt discharg in boot")
+//commend_export(jwt_boot_discharg,cmd_jwt_boot_discharg,"jwt discharg in boot")
@@ -172,7 +173,27 @@ static int cmd_jwt_boot_checkcrc(list_def *argv)
cmd_print("local crc32=0x%04x.",crc);
return ret;
}
-commend_export(jwt_boot_checkcrc,cmd_jwt_boot_checkcrc,"jwt checkcrc in boot")
+//commend_export(jwt_boot_checkcrc,cmd_jwt_boot_checkcrc,"jwt checkcrc in boot")
+
+
+
+
+// 校验jwt程序的crc
+static int cmd_jwtcrc(list_def *argv)
+{
+ int ret=0;
+ uint32_t crc=0,crc2=0;
+ crc=Crc32Calu((uint32_t *)(MC_CODE_ADDR+UPDATA_BASE_ADDR),UPDATA_DATA_LEN);
+ crc2=UPDATA_CRC_APP;
+ cmd_print("crc_calc=0x%08x,crc_rom=0x%08x.",crc,crc2);
+ if(crc==crc2){
+ cmd_print("rom name:%s.",UPDATA_FILE_NAME);
+ }
+ return ret;
+}
+commend_export(jwtcrc,cmd_jwtcrc,"check jwt app crc32.")
+
+
@@ -215,7 +236,7 @@ static int cmd_jwt_app_read(list_def *argv)
ret=EW_appRead();
return ret;
}
-commend_export(jwt_app_read,cmd_jwt_app_read,"jwt read in app")
+//commend_export(jwt_app_read,cmd_jwt_app_read,"jwt read in app")
// app:通信测试
@@ -235,7 +256,7 @@ static int cmd_jwt_app_commtest(list_def *argv)
ret=EW_appCommTest();
return ret;
}
-commend_export(jwt_app_commtest,cmd_jwt_app_commtest,"jwt commtest in app")
+//commend_export(jwt_app_commtest,cmd_jwt_app_commtest,"jwt commtest in app")
@@ -255,7 +276,7 @@ static int cmd_jwt_app_runboot(list_def *argv)
EW_appRunBoot();
return ret;
}
-commend_export(jwt_app_runboot,cmd_jwt_app_runboot,"jwt turn to bootloader")
+//commend_export(jwt_app_runboot,cmd_jwt_app_runboot,"jwt turn to bootloader")
@@ -389,6 +410,15 @@ void EW_Updata(void)
ew_updata.time_poweroff=checker_runcfg.params[2];
// 升级模式,0,无app时升级;1,无条件升级
ew_updata.updata_mode=checker_runcfg.params[3];
+
+ // 校验jwt程序是否正常
+ crc=Crc32Calu((uint32_t *)(MC_CODE_ADDR+UPDATA_BASE_ADDR),UPDATA_DATA_LEN);
+ if(crc!=UPDATA_CRC_APP)
+ {
+ ret=12;
+ goto err;
+ }
+
EW_ParamPrint(&ew_updata);
PowerCalibration_set(200,120);
ret=EW_CheckState(&ew_updata);
diff --git a/source/elec_det/test/EW_TestUsartApp.c b/source/elec_det/test/EW_TestUsartApp.c
index 298fd83..6154d90 100644
--- a/source/elec_det/test/EW_TestUsartApp.c
+++ b/source/elec_det/test/EW_TestUsartApp.c
@@ -1,14 +1,12 @@
#include "driver/ewdriver.h"
#include "base/define.h"
#include "base/delay.h"
-//#include "console_usart.h"
#include "base/utility.h"
-//#include "usartapp.h"
-//#include "arrayfifo.h"
-//#include "YeCommProtocol.h"
#include "hardware/power.h"
#include "elec_io.h"
+#include "mymisc.h"
+
#pragma pack(1)
typedef struct{
uint8_t head[2];//̶ͷ豸
@@ -100,7 +98,6 @@ static void EW_AckCmd(EWCmd_un* cmd_un)
uc_crc = CheckCRC_8(cmd_un->buf,cmd_un->head.frame_len-1);
cmd_un->buf[cmd_un->head.frame_len-1] = uc_crc;
ConsoleUsart_send_bytes(cmd_un->buf,cmd_un->head.frame_len);
- //ConsoleUsart0DMA_send_bytes(cmd_un->yecmdbuf,cmd_un->head.frame_len,10);
}
static void EW_BusCmd01(EWCmd_un* cmd_un)
@@ -119,6 +116,16 @@ static void EW_BusCmd01(EWCmd_un* cmd_un)
cmd_un->head.frame_len++;
EW_AckCmd(cmd_un);
}
+
+
+static void DoHeartBeat(void);
+static void heart_beat_fun(void *t)
+{
+ if(heard_beat_flag){
+ DoHeartBeat();
+ later_execute(heart_beat_fun,0,1000);
+ }
+}
static void EW_HeartBeatCmd02(EWCmd_un* cmd_un)
{
heard_beat_flag = cmd_un->heartbeat02.oper_cmd;
@@ -127,6 +134,9 @@ static void EW_HeartBeatCmd02(EWCmd_un* cmd_un)
cmd_un->buf[cmd_un->head.frame_len] = 0;
cmd_un->head.frame_len++;
EW_AckCmd(cmd_un);
+ if(heard_beat_flag){
+ later_execute(heart_beat_fun,0,1000);
+ }
}
extern uint16_t EW_DMOD_READ_Timeout;
static void EW_RWCmd03(EWCmd_un* cmd_un)
@@ -212,7 +222,7 @@ void EW_DoCmd(EWCmd_un* cmd_un)
}
-static void DoHeartBeat()
+static void DoHeartBeat(void)
{
uint8_t uc_crc;
ew_beat_ack.oper_cmd = 1;
@@ -227,52 +237,6 @@ static void DoHeartBeat()
}
-void EWUsartApp_Task(void* param)
-{
- rt_uint32_t event;
- uint32_t idle_count = 0;
- UNUSED(param);
- rt_event_init(&ew_usart0_rx_event, "ew_usart_rx_e", RT_IPC_FLAG_PRIO);
- ew_app_rec_flag = 0;
-
- while(1)
- {
- if(idle_count > 9)
- {
- idle_count = 0;
- if(heard_beat_flag > 0)
- {
- DoHeartBeat();
- }
- }
-
- if(rt_event_recv(&ew_usart0_rx_event, UART_MC_FRAME_EVENT,RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR,100, &event) != RT_EOK)
- {
- idle_count++;
- continue;
- }
-
- if((event & UART_MC_FRAME_EVENT) > 0)
- {
- ConsoleRxDisable();
- if(ewcmd_nu.buf[0]=='E' && ewcmd_nu.buf[1] == 'w')
- {
-
- if(ewcmd_nu.buf[ewcmd_nu.head.frame_len-1] == CheckCRC_8(ewcmd_nu.buf,ewcmd_nu.head.frame_len-1))
- {
-
- EW_DoCmd(&ewcmd_nu);
- }
-
- }
- ConsoleRxEnable();
- ew_app_rec_flag = 0;
- }
-
- }
-
-
- }
/*
@@ -293,8 +257,13 @@ void EW_UsartApp_Push_Cmd(uint8_t* buf, uint16_t len)
len = sizeof(EWCmd_un);
}
rt_memcpy((void*)&ewcmd_nu,buf,len);
- rt_event_send(&ew_usart0_rx_event,UART_MC_FRAME_EVENT);//ʹݽ¼
- ew_app_rec_flag = 1;
+ if(ewcmd_nu.buf[0]=='E' && ewcmd_nu.buf[1] == 'w')
+ {
+ if(ewcmd_nu.buf[ewcmd_nu.head.frame_len-1] == CheckCRC_8(ewcmd_nu.buf,ewcmd_nu.head.frame_len-1))
+ {
+ EW_DoCmd(&ewcmd_nu);
+ }
+ }
}
diff --git a/source/interface/if_uart.c b/source/interface/if_uart.c
index da616b1..7e33f02 100644
--- a/source/interface/if_uart.c
+++ b/source/interface/if_uart.c
@@ -87,7 +87,7 @@ static const uart_dtb g_uartdtb[]={
.uart=USART1,
.uart_clock_fun=RCC_APB2PeriphClockCmd,
.uart_rcc=RCC_APB2Periph_USART1,
- .baudrate=38400,
+ .baudrate=9600,
.irq_channel=USART1_IRQn,
.gpio_tx_clock_fun=RCC_APB2PeriphClockCmd,
diff --git a/source/main/compiler_info.h b/source/main/compiler_info.h
index 0011358..4544093 100644
--- a/source/main/compiler_info.h
+++ b/source/main/compiler_info.h
@@ -6,7 +6,7 @@
-#define BUILD_DATE "2023-12-27 11:39:17"
+#define BUILD_DATE "2023-12-29 15:21:35"
#define SOFT_VERSION "2.10"