From ddeec88a894d0ac8ae53e7b5873e62041d38488f Mon Sep 17 00:00:00 2001 From: ranchuan Date: Wed, 1 Nov 2023 18:10:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8make=20-f=20Makeboot=20?= =?UTF-8?q?=E6=9D=A5=E4=BD=BF=E7=94=A8gcc=E7=BC=96=E8=AF=91=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20DMod=5FFireBusReadDatasV2=5FRC=20=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/c_cpp_properties.json | 19 ++- Makefile => Makeboot | 17 ++- checher_slave.uvoptx | 12 +- checher_slave.uvprojx | 23 ++-- doc/JW3425_boot_v12.bin | Bin 0 -> 3992 bytes doc/creat_jwt_boot.py | 2 +- source/ReadMe.txt | 4 + source/dev/dev_backup.c | 14 +- source/elec_det/driver/EWDriver.c | 181 +++++++++++++++++++++++++- source/elec_det/interface/EWChecker.c | 7 + source/elec_det/test/EWCheckerTest.c | 1 + source/main/compiler_info.h | 2 +- source/main/main.c | 4 +- source/rt_thread/board.c | 16 ++- 14 files changed, 261 insertions(+), 41 deletions(-) rename Makefile => Makeboot (94%) create mode 100644 doc/JW3425_boot_v12.bin diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 2da9afd..8cbb010 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,14 +1,13 @@ { "configurations": [ { - "name": "stm32", + "name": "app", "includePath": [ "${workspaceFolder}/**", "${workspaceFolder}/source/**", "D:/GNU Arm Embedded Toolchain/10 2021.10/arm-none-eabi/include" ], "defines": [ - "STM32F40_41xxx", "USE_STDPERIPH_DRIVER", "RT_THREAD", "STM32F10X_MD" @@ -17,6 +16,22 @@ "cppStandard": "gnu++17", "intelliSenseMode": "windows-gcc-arm", "compilerPath": "D:\\GNU Arm Embedded Toolchain\\10 2021.10\\bin\\arm-none-eabi-gcc" + }, + { + "name": "boot", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/source/**", + "D:/GNU Arm Embedded Toolchain/10 2021.10/arm-none-eabi/include" + ], + "defines": [ + "USE_STDPERIPH_DRIVER", + "STM32F10X_MD" + ], + "cStandard": "c99", + "cppStandard": "gnu++17", + "intelliSenseMode": "windows-gcc-arm", + "compilerPath": "D:\\GNU Arm Embedded Toolchain\\10 2021.10\\bin\\arm-none-eabi-gcc" } ], "version": 4 diff --git a/Makefile b/Makeboot similarity index 94% rename from Makefile rename to Makeboot index dc54142..3f7140b 100644 --- a/Makefile +++ b/Makeboot @@ -16,6 +16,9 @@ TARGET = checker_slave_boot +# this file name +SELF_NAME = Makeboot + ###################################### # building variables ###################################### @@ -29,7 +32,7 @@ OPT = -Og # paths ####################################### # Build path -BUILD_DIR = build +BUILD_DIR = build/boot ###################################### # source @@ -158,6 +161,10 @@ CFLAGS += -g -gdwarf-2 endif +# ignore warnings +CFLAGS += -Wno-unused-but-set-variable -Wno-unused-function -Wno-unused-variable + + # Generate dependency information CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)" @@ -187,13 +194,13 @@ vpath %.c $(sort $(dir $(C_SOURCES))) OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) vpath %.s $(sort $(dir $(ASM_SOURCES))) -$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) +$(BUILD_DIR)/%.o: %.c $(SELF_NAME) | $(BUILD_DIR) $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ -$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR) +$(BUILD_DIR)/%.o: %.s $(SELF_NAME) | $(BUILD_DIR) $(AS) -c $(CFLAGS) $< -o $@ -$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile +$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) $(SELF_NAME) $(CC) $(OBJECTS) $(LDFLAGS) -o $@ $(SZ) $@ @@ -211,7 +218,7 @@ $(BUILD_DIR): ####################################### clean: -rm -fR $(BUILD_DIR) - + ####################################### # dependencies ####################################### diff --git a/checher_slave.uvoptx b/checher_slave.uvoptx index 1911924..62918a6 100644 --- a/checher_slave.uvoptx +++ b/checher_slave.uvoptx @@ -75,7 +75,7 @@ 1 0 - 1 + 0 18 @@ -103,7 +103,7 @@ 1 0 0 - 6 + 4 @@ -114,7 +114,7 @@ - STLink\ST-LINKIII-KEIL_SWO.dll + Segger\JL2CM3.dll @@ -523,7 +523,7 @@ 1 0 - 0 + 1 18 @@ -583,7 +583,7 @@ 0 DLGUARM - 9 + d 0 @@ -1167,7 +1167,7 @@ elec_det - 0 + 1 0 0 0 diff --git a/checher_slave.uvprojx b/checher_slave.uvprojx index baac5af..87e9dab 100644 --- a/checher_slave.uvprojx +++ b/checher_slave.uvprojx @@ -10,7 +10,7 @@ boot 0x4 ARM-ADS - 5060960::V5.06 update 7 (build 960)::.\ARMCC + 5060750::V5.06 update 6 (build 750)::ARMCC 0 @@ -185,7 +185,6 @@ 0 0 0 - 0 0 0 8 @@ -352,7 +351,7 @@ 0 0 0 - 4 + 0 @@ -799,7 +798,7 @@ 2 2 2 - 0 + 2 @@ -1893,7 +1892,7 @@ 2 2 2 - 0 + 2 @@ -2384,7 +2383,7 @@ 2 2 2 - 0 + 2 @@ -2483,7 +2482,7 @@ 2 2 2 - 0 + 2 @@ -2562,7 +2561,7 @@ 2 2 2 - 0 + 2 @@ -2811,7 +2810,6 @@ 0 0 0 - 0 0 0 8 @@ -2978,7 +2976,7 @@ 0 0 0 - 4 + 0 @@ -4256,11 +4254,10 @@ 0 0 0 - 0 0 0 8 - 0 + 1 0 0 0 @@ -4423,7 +4420,7 @@ 0 0 0 - 4 + 0 diff --git a/doc/JW3425_boot_v12.bin b/doc/JW3425_boot_v12.bin new file mode 100644 index 0000000000000000000000000000000000000000..c744453494b12756ffff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Ba@j{Lf6 z&`lv*$@?m~3E4daEZ^-mXUWY}@-u*x=tHblZ0Qe35xc~qF literal 0 HcmV?d00001 diff --git a/doc/creat_jwt_boot.py b/doc/creat_jwt_boot.py index 7a6fcc6..cd7a779 100644 --- a/doc/creat_jwt_boot.py +++ b/doc/creat_jwt_boot.py @@ -5,7 +5,7 @@ import json -BOOT_PATH ="JW3425_boot_v11.bin" +BOOT_PATH ="JW3425_boot_v12.bin" APP_PATH ="MS-IEpro20231007.bin" OUT_PATH = BOOT_PATH.split('.')[0]+".jwt" diff --git a/source/ReadMe.txt b/source/ReadMe.txt index 038ace4..3e8faca 100644 --- a/source/ReadMe.txt +++ b/source/ReadMe.txt @@ -235,3 +235,7 @@ 2023.10.31 添加通用的异常判定算法,已验证 更新EW模块驱动 +2023.11.1 + 使用make -f Makeboot 来使用gcc编译 + 添加 DMod_FireBusReadDatasV2_RC 函数 + diff --git a/source/dev/dev_backup.c b/source/dev/dev_backup.c index 8ca4265..2b17c7a 100644 --- a/source/dev/dev_backup.c +++ b/source/dev/dev_backup.c @@ -97,13 +97,13 @@ typedef struct{ }reboot_type_str; static const reboot_type_str g_reboot_str[]={ - REBOOT_APP_TO_APP,"app restart", - REBOOT_APP_TO_BOOT,"app reboot to boot", - REBOOT_BOOT_TO_APP,"boot guide to app", - REBOOT_BOOT_TO_BOOT,"boot restart", - REBOOT_PARAM_ERR,"param err then reboot", - REBOOT_HARD_ERR,"hard err then reboot", - REBOOT_INIT,"watch dog died then reboot", + {REBOOT_APP_TO_APP,"app restart",}, + {REBOOT_APP_TO_BOOT,"app reboot to boot",}, + {REBOOT_BOOT_TO_APP,"boot guide to app",}, + {REBOOT_BOOT_TO_BOOT,"boot restart",}, + {REBOOT_PARAM_ERR,"param err then reboot",}, + {REBOOT_HARD_ERR,"hard err then reboot",}, + {REBOOT_INIT,"watch dog died then reboot",}, }; diff --git a/source/elec_det/driver/EWDriver.c b/source/elec_det/driver/EWDriver.c index 2e9e39b..9aaeb61 100644 --- a/source/elec_det/driver/EWDriver.c +++ b/source/elec_det/driver/EWDriver.c @@ -685,6 +685,185 @@ uint8_t DMod_FireBusReadDatasV2(uint8_t* buf, uint8_t len, uint32_t time_out) } +static uint16_t us_plus_H,us_plus_H2;//高电平采用次数 +static uint16_t us_plus_T,us_plus_T2;//采样周期 +typedef struct{ + uint16_t cur_idle; + uint16_t cur_idle_ad; + uint16_t cur_high_value; + uint16_t cur_idle_line; + uint16_t cur_max; +}firebus_def; +uint8_t DMod_FireBusReadDatasV2_RC(uint8_t* buf, uint8_t len, uint32_t time_out) +{ + uint32_t ul_ad_sample; + uint32_t ul_check_falg; //奇校验 + uint32_t us_time_out = time_out; + uint32_t ul_data = 0; + uint32_t us_dataT_Or;//数据周期 + uint32_t us_temp1,us_temp2; + uint16_t ad_max = 0,ad_min_temp=0,ad_max_temp = 0; + firebus_def fire_dat={0}; + uint8_t ret=0; + CurrentSample_Range_eu range = buscurrent_range;//档位保存 + Power_SetSampleCurrentRange(R10_2mA_30mA_MC); + ADC_CurChnnelSet(AN_MAL_CH,ADC_SPEED_HFAST); + delay_us(2000); + //总线跳转到中电平 + EW_DIFF_MOD_M; + //延时等待电流稳定 + delay_us(800); + //COM_PH2_Out = 0; + PBout(I2IC_SCL_Pin_Nu) = 0; + delay_us(200); + //获取中电平电流 + PBout(I2IC_SCL_Pin_Nu) = 1 ; + DMod_GetIdle2V(); + fire_dat.cur_idle=SMod_Read_Idle_C; + fire_dat.cur_idle_ad=ADC_GetCurADCFast(); + PBout(I2IC_SCL_Pin_Nu) = 0 ; + //读取指定长度数据 + //读取单字节数据 + ul_data = 0; + //等待起始信号唤醒信号 + us_plus_H = 0; + us_plus_T = 0; + us_time_out = 2000 + time_out; + do{ + + ul_ad_sample = ADC_GetCurADCFast(); + if(ad_max < ul_ad_sample) + ad_max = ul_ad_sample; + if(ul_ad_sample > SMod_Read_Idle_C) + { + if(ul_ad_sample-SMod_Read_Idle_C>50){ + us_plus_H++; + fire_dat.cur_high_value=fire_dat.cur_high_value/2+ul_ad_sample/2; + }else{ + SMod_Read_Idle_C=ul_ad_sample; + } + }else{ + us_plus_H = 0; + fire_dat.cur_high_value=0; + } + delay_us(2); + us_time_out--; + } + while((us_plus_H < 4) && (us_time_out > 0)); + fire_dat.cur_max=ad_max; + if(us_time_out < 1)//等待起始信号超时 + { + ret=1; + goto end; + } + + // 空闲判线以最高电平为基准 + SMod_Read_Idle_C=(SMod_Read_Idle_C+fire_dat.cur_high_value)/2; + fire_dat.cur_idle_line=SMod_Read_Idle_C; + + while(len > 0) + { + //等待数据帧起始信号 + us_time_out = 10; + us_plus_T2 = 0xFFFF; + us_plus_H2 = 0; + while(us_time_out > 0) + { + us_plus_H = 0; + us_plus_T = 0; + idle_line = SMod_Read_Idle_C; +// idle_line = ad_max - SMod_Read_Idle_C; +// idle_line = (idle_line>>1)+ (idle_line>>4)+ SMod_Read_Idle_C; + if(SMod_FireBusReadPlus(&us_plus_H,&us_plus_T,time_out,idle_line,&ad_max_temp,&ad_min_temp ) > 0) + { + ret=2; + goto end; + } + if(us_plus_H2 > (us_plus_T2- us_plus_H2)) + { + us_temp1 = us_plus_T << 1; //2倍 + us_temp2 = us_plus_T + (us_plus_T >> 1);//1.5倍 + if((us_plus_T2 > us_temp2) && (us_plus_T2 < us_temp1)) + { + break; + } + } + us_plus_T2 = us_plus_T; + us_plus_H2 = us_plus_H; + us_time_out--; + } + //采集8bit数据+1位校验 + ul_data = 0; + ul_check_falg = 0; + us_time_out = 0; + us_plus_T2 = 0; + us_dataT_Or = us_plus_T;//保存数据周期 + do{ + ul_data <<= 1; + if(us_plus_H > (us_plus_T- us_plus_H)) //高电平时间大于低电平 1 + { + ul_data |= 0x01; + ul_check_falg ^= 0x01; + }else{//检测是否是结束信号 0 + us_temp1 = us_plus_T2 << 1; //2倍 + us_temp2 = us_plus_T2 + (us_plus_T2 >> 1);//1.5倍 + if((us_plus_T > us_temp2) && (us_plus_T < us_temp1)) + { + break; + } + } + //约束数据周期范围 +// if(((us_dataT_Or+4) < us_plus_T) +// || ((us_dataT_Or - 4) > us_plus_T)) +// { +// SetSampleCurrentRange(range); +// EW_SINGLE_MOD_H; +// return 3; +// } + us_plus_T2 = us_plus_T; + us_plus_H2 = us_plus_H; + us_plus_H = 0; + us_plus_T = 0; + //idle_line = ad_max - SMod_Read_Idle_C; + //idle_line = (idle_line>>1)+ (idle_line>>4)+ SMod_Read_Idle_C; + idle_line = SMod_Read_Idle_C; + if(SMod_FireBusReadPlus(&us_plus_H,&us_plus_T,time_out,idle_line,&ad_max_temp,&ad_min_temp ) > 0) + { + ret=4; + goto end; + } + ad_max = (uint16_t)(ad_max * 0.7f + ad_max_temp*0.3f); + us_time_out++; + }while(us_time_out < 13); + if(ul_check_falg == 0) + { + ret=5; + goto end; + } + if(us_time_out != 9) + { + ret=6; + goto end; + } + ul_data >>= 2; + *buf = (uint8_t)ul_data; + buf++; + len--; + } + //delay_us(time_out >> 1); + + end: + EW_DIFF_MOD_H; + Power_SetSampleCurrentRange(range); + if(ret){ + DBG_LOG("cur_idle=%d,high_value=%d,idle_line=%d.",fire_dat.cur_idle, fire_dat.cur_high_value,fire_dat.cur_idle_line); + DBG_LOG("cur_max=%d,cur_idle_ad=%d",fire_dat.cur_max,fire_dat.cur_idle_ad); + } + return ret; +} + + + /* @brief 差分模式数据发送 @param buf 发送数据缓存 @@ -805,7 +984,7 @@ uint8_t DMod_ReadBytesXor(uint8_t* buf, uint8_t len,uint16_t retry_times) { uint8_t ret; // for(int i=0;ipack_time,20); if(pars.local_id==0xffffffff){ memcpy(pars.host_if,h->host_if,8); - memcpy(pars.device_type,"slave",8); + memcpy(pars.device_type,"slave",6); mac_init(pars.mac); pars.local_id=0; } @@ -401,7 +401,7 @@ void param_init(rom_head *h) // 填充默认配置 if(pars.local_id==0xffffffff){ memcpy(pars.pack_time,"initial app",12); - memcpy(pars.host_if,"host",6); + memcpy(pars.host_if,"host",5); memcpy(pars.device_type,"slave",6); mac_init(pars.mac); pars.local_id=0; diff --git a/source/rt_thread/board.c b/source/rt_thread/board.c index d311223..c2aec5c 100644 --- a/source/rt_thread/board.c +++ b/source/rt_thread/board.c @@ -220,11 +220,21 @@ void cpy4byte(uint32_t *dst,uint32_t *src,int num_4byte) +#ifdef __GNUC__ + +/* With GCC, small printf (option LD Linker->Libraries->Small printf + set to 'Yes') calls __io_putchar() */ +#define PUTCHAR_PROTOTYPE int __io_putchar(int ch) + +#else + +#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) +#pragma import(__use_no_semihosting) + +#endif /* __GNUC__ */ -#pragma import(__use_no_semihosting) - struct __FILE { int handle; @@ -237,7 +247,7 @@ void _sys_exit(int x) x = x; } -int fputc(int ch, FILE *f) +PUTCHAR_PROTOTYPE { // SEGGER_RTT_PutChar(0,ch); return ch;