diff --git a/checher_slave.uvoptx b/checher_slave.uvoptx
index eeafa08..1a73382 100644
--- a/checher_slave.uvoptx
+++ b/checher_slave.uvoptx
@@ -299,7 +299,7 @@
1
0
- 0
+ 1
18
@@ -327,7 +327,7 @@
1
0
0
- 4
+ 6
@@ -338,7 +338,7 @@
- Segger\JL2CM3.dll
+ STLink\ST-LINKIII-KEIL_SWO.dll
@@ -359,7 +359,7 @@
0
DLGUARM
- d
+ (105=-1,-1,-1,-1,0)
0
@@ -523,7 +523,7 @@
1
0
- 1
+ 0
18
@@ -1507,7 +1507,7 @@
rt_thread
- 0
+ 1
0
0
0
diff --git a/source/ReadMe.txt b/source/ReadMe.txt
index 1f9ad8b..1d8fdd7 100644
--- a/source/ReadMe.txt
+++ b/source/ReadMe.txt
@@ -247,5 +247,8 @@
2023.11.6
解决本地异常判定任务数量与实际不符的bug
V2.04
-
+2023.11.13
+ V2.05
+ 重写延时等待函数,解决与模块之间通信间隔有可能过短的问题
+ 修改硬件版本号时自动修改can波特率
diff --git a/source/elec_det/base/delay.c b/source/elec_det/base/delay.c
index 1834262..04bfd9f 100644
--- a/source/elec_det/base/delay.c
+++ b/source/elec_det/base/delay.c
@@ -4,6 +4,41 @@
+
+typedef struct{
+ rt_tick_t tick_start;
+}self_def;
+
+
+
+
+static self_def g_self;
+
+void delay_wait_start(void)
+{
+ g_self.tick_start=rt_tick_get();
+}
+
+
+void delay_wait_untill_ms(uint32_t nms)
+{
+ rt_tick_t tick_end;
+ rt_tick_t diff;
+ if(g_self.tick_start==0){
+ delay_wait_start();
+ }
+ while(1){
+ tick_end=rt_tick_get();
+ diff=tick_end-g_self.tick_start;
+ if(diff>=nms){
+ break;
+ }
+ rt_thread_mdelay(1);
+ }
+ g_self.tick_start=0;
+}
+
+
//此函数已在别处实现
//void delay_us(uint32_t nus)
//{
@@ -59,5 +94,6 @@ void delay_nop(uint32_t nop)
+
diff --git a/source/elec_det/base/delay.h b/source/elec_det/base/delay.h
index 28ec8b1..2ad9a7f 100644
--- a/source/elec_det/base/delay.h
+++ b/source/elec_det/base/delay.h
@@ -9,6 +9,9 @@ void delay_ms(uint32_t nms);
void delay_us(uint32_t nus);
void delay_nop(uint32_t nop);
#define delay_os_ms(ms) rt_thread_delay(ms)
+void delay_wait_start(void);
+void delay_wait_untill_ms(uint32_t nms);
+
#endif
diff --git a/source/elec_det/driver/JQDriver.c b/source/elec_det/driver/JQDriver.c
index a4f9949..2904a47 100644
--- a/source/elec_det/driver/JQDriver.c
+++ b/source/elec_det/driver/JQDriver.c
@@ -31,12 +31,16 @@ volatile uint16_t JQ_EnFreeBack_Test = 0;
static void JQ_CommBegin()
{
CurrentSampleR_Def;
- WaitDelayEnd(200);//20ms
+ //WaitDelayEnd(200);//20ms
+ //delay_ms(20);
+ delay_wait_untill_ms(20);
}
static void JQ_CommEnd()
{
uint16_t us_temp;
- StartDelayTime();
+ //StartDelayTime();
+ TimerCount_Off();
+ delay_wait_start();
if(JQ_CommEnd_CurEn > 0)
{
delay_os_ms(10);
diff --git a/source/elec_det/driver/XTDriver.c b/source/elec_det/driver/XTDriver.c
index c842adf..74610c5 100644
--- a/source/elec_det/driver/XTDriver.c
+++ b/source/elec_det/driver/XTDriver.c
@@ -45,12 +45,16 @@ void XT_FreeBack_Prapare(uint8_t enable_flag)
static void XT_CommBegin()
{
CurrentSampleR_Def;
- WaitDelayEnd(50);//5ms
+ //WaitDelayEnd(50);//5ms
+ //delay_ms(5);
+ delay_wait_untill_ms(5);
}
static void XT_CommEnd()
{
uint16_t us_temp;
- StartDelayTime();
+ //StartDelayTime();
+ TimerCount_Off();
+ delay_wait_start();
if(XT_CommEnd_CurEn > 0)
{
delay_os_ms(10);
@@ -157,7 +161,7 @@ static uint8_t XT_Get_Ack(uint32_t timeoutcnt, uint8_t ConfirmAckCount,uint32_t
// }
// XT_ADC_BaseValue = (XT_ADC_BaseValue>>6) + XT_FreeBack_Noise;
XT_ADC_BaseValue = XT_FreeBack_Noise;
- while(ul_runtime < timeoutcnt)
+ while(1)
{
FeekValue = ADC_GetCurADCFast();
if(FeekValue >= XT_ADC_BaseValue)
@@ -181,12 +185,19 @@ static uint8_t XT_Get_Ack(uint32_t timeoutcnt, uint8_t ConfirmAckCount,uint32_t
ul_runtime = 0;
}
ul_runtime = ul_readtime+ul_runtime;
-
+ if(ul_runtime >= timeoutcnt){
+ // time out
+ rtv = 2;
+ break;
+ }
}
LED1_Out_Off;
XTBUS_IDLE;
Power_SetSampleCurrentRange(Current_Max);
XT_CommEnd();
+ if(rtv){
+ rtv=!0;
+ }
return rtv;
}
diff --git a/source/elec_det/elec_det.c b/source/elec_det/elec_det.c
index e2c1708..56a2ec0 100644
--- a/source/elec_det/elec_det.c
+++ b/source/elec_det/elec_det.c
@@ -85,6 +85,10 @@ int elec_scheme_deinit(void)
+
+
+
+
// 找到第一个指定taskid的任务
static CheckerTask_Info_st *elec_find_task_by_taskid(int id)
{
@@ -157,6 +161,15 @@ void elec_led2_power(int power)
}
+// 获取小板硬件版本号
+int elec_hard_version(void)
+{
+ return HARD_VERSION;
+}
+
+
+
+
// 获取自检参数
diff --git a/source/elec_det/elec_det.h b/source/elec_det/elec_det.h
index d2e5233..15c33eb 100644
--- a/source/elec_det/elec_det.h
+++ b/source/elec_det/elec_det.h
@@ -14,6 +14,8 @@ int elec_scheme_deinit(void);
uint8_t elec_local_addr(void);
+int elec_hard_version(void);
+
void elec_led1_power(int power);
void elec_led2_power(int power);
diff --git a/source/elec_det/hardware/gpio_cfg.c b/source/elec_det/hardware/gpio_cfg.c
index 46e3bfd..de6198e 100644
--- a/source/elec_det/hardware/gpio_cfg.c
+++ b/source/elec_det/hardware/gpio_cfg.c
@@ -24,7 +24,7 @@ void CtrlGpio_DefInit(void)
GPIO_ResetBits(GPIOA,GPIO_InitStructure.GPIO_Pin);
GPIO_InitStructure.GPIO_Pin = SEG0_Pin;
- GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
+ GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA,&GPIO_InitStructure);
@@ -69,7 +69,7 @@ void CtrlGpio_DefInit(void)
//GPIO 配置
GPIO_InitStructure.GPIO_Pin=SEG4_Pin|SEG3_Pin|SEG1_Pin|SEG2_Pin;
- GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
+ GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);
diff --git a/source/elec_det/hardware/timer_cfg.c b/source/elec_det/hardware/timer_cfg.c
index 2e574c5..e665755 100644
--- a/source/elec_det/hardware/timer_cfg.c
+++ b/source/elec_det/hardware/timer_cfg.c
@@ -363,3 +363,15 @@ uint16_t GetCountTimerCnt()
return TIM2->CNT;
}
+
+
+void TimerCount_Off(void)
+{
+ TIM_Cmd(TIM2,DISABLE);
+ TIM2->CNT = 0;
+ TIM2->PSC = (uint32_t)7200-1;//10K 0.1ms
+ TIM2->EGR |= TIM_EventSource_Update;
+ TIM2->SR = 0;
+}
+
+
diff --git a/source/elec_det/hardware/timer_cfg.h b/source/elec_det/hardware/timer_cfg.h
index 88858fc..861289f 100644
--- a/source/elec_det/hardware/timer_cfg.h
+++ b/source/elec_det/hardware/timer_cfg.h
@@ -65,4 +65,9 @@ uint16_t GetCountTimerCnt(void);
使用轮询的方式检测校准结束
*/
void FireBus_ClkAmendCycle(void);
+
+// 复位并关闭定时器
+void TimerCount_Off(void);
+
+
#endif
diff --git a/source/interface/if_can.c b/source/interface/if_can.c
index 044edcf..42bcc9d 100644
--- a/source/interface/if_can.c
+++ b/source/interface/if_can.c
@@ -50,7 +50,11 @@ void YeCanInit(void)
CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;
CAN_InitStructure.CAN_BS1 = CAN_BS1_3tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_2tq;
- CAN_InitStructure.CAN_Prescaler = 30;
+ if(elec_hard_version()==1){
+ CAN_InitStructure.CAN_Prescaler = 60;
+ }else{
+ CAN_InitStructure.CAN_Prescaler = 30;
+ }
CAN_Init(CAN1, &CAN_InitStructure);
diff --git a/source/main/compiler_info.h b/source/main/compiler_info.h
index 3d0c6a3..3084feb 100644
--- a/source/main/compiler_info.h
+++ b/source/main/compiler_info.h
@@ -6,8 +6,8 @@
-#define BUILD_DATE "2023-11-06 16:44:51"
-#define SOFT_VERSION "2.04"
+#define BUILD_DATE "2023-11-13 17:12:52"
+#define SOFT_VERSION "2.05"
diff --git a/source/prebuild.py b/source/prebuild.py
index f615a6d..6706e83 100644
--- a/source/prebuild.py
+++ b/source/prebuild.py
@@ -7,7 +7,7 @@ import mycopy
# 定义软件版本号
-SOFT_VERION = "2.04"
+SOFT_VERION = "2.05"