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 0000000..c744453
Binary files /dev/null and b/doc/JW3425_boot_v12.bin differ
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;