|
|
@@ -1166,9 +1166,10 @@ void PLSR_Route_Set(PLSR_RouteConfig_t* route) |
|
|
|
route->section[i].target_freq = ((uint32_t)FlashSave_Get_Holding_Register(seg_base_addr + MODBUS_OFFSET_FREQ_LOW)) | |
|
|
|
((uint32_t)FlashSave_Get_Holding_Register(seg_base_addr + MODBUS_OFFSET_FREQ_HIGH) << 16); |
|
|
|
|
|
|
|
/* 目标脉冲数 = 低16位 | (高16位 << 16) */ |
|
|
|
route->section[i].target_pulse = ((int64_t)FlashSave_Get_Holding_Register(seg_base_addr + MODBUS_OFFSET_PULSE_COUNT_LOW)) | |
|
|
|
((int64_t)FlashSave_Get_Holding_Register(seg_base_addr + MODBUS_OFFSET_PULSE_COUNT_HIGH) << 16); |
|
|
|
uint16_t pulse_low = FlashSave_Get_Holding_Register(seg_base_addr + MODBUS_OFFSET_PULSE_COUNT_LOW); |
|
|
|
uint16_t pulse_high = FlashSave_Get_Holding_Register(seg_base_addr + MODBUS_OFFSET_PULSE_COUNT_HIGH); |
|
|
|
int32_t pulse_32bit = (int32_t)((uint32_t)pulse_low | ((uint32_t)pulse_high << 16)); |
|
|
|
route->section[i].target_pulse = (int64_t)pulse_32bit; |
|
|
|
|
|
|
|
/* 等待条件和跳转编号 */ |
|
|
|
route->section[i].wait_condition.wait_type = FlashSave_Get_Holding_Register(seg_base_addr + MODBUS_OFFSET_WAIT_CONDITION); |
|
|
@@ -1754,7 +1755,7 @@ void PLSR_Section_SwitchNext(PLSR_RouteConfig_t* route, uint8_t is_pulse_complet |
|
|
|
else |
|
|
|
{ |
|
|
|
// 外部事件触发:直接使用全局脉冲计数器作为累计脉冲数 |
|
|
|
route->prevPulseCount = PlsrTotalPulseCount; |
|
|
|
route->prevPulseCount += (TIM2->CNT + (PartUpdatePluse - SectionUpdatePluse)); |
|
|
|
SectionUpdatePluse = PlsrTotalPulseCount; |
|
|
|
} |
|
|
|
} |
|
|
@@ -2164,18 +2165,13 @@ uint8_t PLSR_Section_CheckPulseComplete(PLSR_RouteConfig_t* route) |
|
|
|
|
|
|
|
PLSR_SectionConfig_t* current_section = &route->section[route->current_section_num - 1]; |
|
|
|
|
|
|
|
// 根据等待条件类型检查 |
|
|
|
if (current_section->wait_condition.wait_type == PLSR_WAIT_PLUSEEND || |
|
|
|
current_section->wait_condition.wait_type == PLSR_WAIT_EXT_OR_END) |
|
|
|
{ |
|
|
|
int64_t target_pulse = current_section->actual_pulse; |
|
|
|
if(target_pulse < 0) target_pulse = -target_pulse; |
|
|
|
target_pulse += route->prevPulseCount; // 累加上次的脉冲计数 |
|
|
|
|
|
|
|
int64_t target_pulse = current_section->actual_pulse; |
|
|
|
if(target_pulse < 0) target_pulse = -target_pulse; |
|
|
|
target_pulse += route->prevPulseCount; // 累加上次的脉冲计数 |
|
|
|
|
|
|
|
return (route->pulse_count >= target_pulse) ? 1 : 0; |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
return (route->pulse_count >= target_pulse) ? 1 : 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|