| @@ -405,6 +405,7 @@ static void PlsrDisarmWaitSignal(void); | |||||
| static uint8_t PlsrWaitSignalDetected(uint8_t inputSelection); | static uint8_t PlsrWaitSignalDetected(uint8_t inputSelection); | ||||
| static PLSR_PLATFORM_QUEUE_RESULT PlsrTryContinuousHandoff(void); | static PLSR_PLATFORM_QUEUE_RESULT PlsrTryContinuousHandoff(void); | ||||
| static uint8_t PlsrPrepareShortProfile(PLSR_SHORT_PROFILE *profile, | static uint8_t PlsrPrepareShortProfile(PLSR_SHORT_PROFILE *profile, | ||||
| const PLSR_CONFIG *frequencyConfig, | |||||
| uint8_t segmentNumber, | uint8_t segmentNumber, | ||||
| uint32_t startFrequencyHz, | uint32_t startFrequencyHz, | ||||
| uint32_t targetFrequencyHz, | uint32_t targetFrequencyHz, | ||||
| @@ -1852,6 +1853,7 @@ static uint64_t PlsrRampPulseEstimate(uint32_t fromHz, | |||||
| } | } | ||||
| static uint8_t PlsrPrepareShortProfile(PLSR_SHORT_PROFILE *profile, | static uint8_t PlsrPrepareShortProfile(PLSR_SHORT_PROFILE *profile, | ||||
| const PLSR_CONFIG *frequencyConfig, | |||||
| uint8_t segmentNumber, | uint8_t segmentNumber, | ||||
| uint32_t startFrequencyHz, | uint32_t startFrequencyHz, | ||||
| uint32_t targetFrequencyHz, | uint32_t targetFrequencyHz, | ||||
| @@ -1868,7 +1870,8 @@ static uint8_t PlsrPrepareShortProfile(PLSR_SHORT_PROFILE *profile, | |||||
| uint8_t nextPositive; | uint8_t nextPositive; | ||||
| (void)memset(profile, 0, sizeof(*profile)); | (void)memset(profile, 0, sizeof(*profile)); | ||||
| if ((PlsrActiveConfig.outputMode != PLSR_OUTPUT_PULSE_DIR) | |||||
| if ((frequencyConfig == NULL) | |||||
| || (PlsrActiveConfig.outputMode != PLSR_OUTPUT_PULSE_DIR) | |||||
| || (pulseCount == 0ULL) || (pulseCount > 0xFFFFFFFFULL) | || (pulseCount == 0ULL) || (pulseCount > 0xFFFFFFFFULL) | ||||
| || (segmentNumber == 0U) | || (segmentNumber == 0U) | ||||
| || (segmentNumber > PlsrActiveConfig.segmentCount)) | || (segmentNumber > PlsrActiveConfig.segmentCount)) | ||||
| @@ -1879,8 +1882,8 @@ static uint8_t PlsrPrepareShortProfile(PLSR_SHORT_PROFILE *profile, | |||||
| block.entryHz = startFrequencyHz; | block.entryHz = startFrequencyHz; | ||||
| block.cruiseHz = targetFrequencyHz; | block.cruiseHz = targetFrequencyHz; | ||||
| /* A configured stop speed belongs to the command endpoint. Internal | /* A configured stop speed belongs to the command endpoint. Internal | ||||
| PUL/DIR boundaries stop at the planner's zero endpoint unless they can | |||||
| carry continuously into the next motion segment. */ | |||||
| discontinuities use the zero endpoint; continuous boundaries override | |||||
| it according to the configured send mode below. */ | |||||
| block.exitHz = 0UL; | block.exitHz = 0UL; | ||||
| block.pulseBudget = (uint32_t)pulseCount; | block.pulseBudget = (uint32_t)pulseCount; | ||||
| block.referenceSpeedHz = PlsrActiveConfig.defaultSpeedHz; | block.referenceSpeedHz = PlsrActiveConfig.defaultSpeedHz; | ||||
| @@ -1913,7 +1916,11 @@ static uint8_t PlsrPrepareShortProfile(PLSR_SHORT_PROFILE *profile, | |||||
| nextPositive = (nextDisplacement > 0) ? 1U : 0U; | nextPositive = (nextDisplacement > 0) ? 1U : 0U; | ||||
| if (nextPositive == currentPositive) | if (nextPositive == currentPositive) | ||||
| { | { | ||||
| block.exitHz = targetFrequencyHz; | |||||
| block.exitHz = | |||||
| (PlsrActiveConfig.sendMode == PLSR_SEND_SUBSEQUENT) | |||||
| ? PlsrResolvedSegmentFrequency( | |||||
| frequencyConfig, nextSegment - 1U) | |||||
| : targetFrequencyHz; | |||||
| block.boundary = PLSR_BOUNDARY_NEXT_CARRY; | block.boundary = PLSR_BOUNDARY_NEXT_CARRY; | ||||
| } | } | ||||
| } | } | ||||
| @@ -2188,7 +2195,8 @@ static PLSR_PLATFORM_SERVICE_RESULT PlsrReplanPulseDir( | |||||
| if (replacementPulses != 0UL) | if (replacementPulses != 0UL) | ||||
| { | { | ||||
| if ((tailFrequencyHz == 0UL) | if ((tailFrequencyHz == 0UL) | ||||
| || (PlsrPrepareShortProfile(&replacement, segmentNumber, | |||||
| || (PlsrPrepareShortProfile(&replacement, &PlsrActiveConfig, | |||||
| segmentNumber, | |||||
| tailFrequencyHz, targetHz, | tailFrequencyHz, targetHz, | ||||
| replacementPulses, | replacementPulses, | ||||
| PlsrCountPositive, | PlsrCountPositive, | ||||
| @@ -2614,7 +2622,7 @@ static void PlsrServiceTimedStartPreparation(void) | |||||
| startFrequencyHz = PlsrPulseDirStartFrequency( | startFrequencyHz = PlsrPulseDirStartFrequency( | ||||
| targetFrequencyHz, PLSR_SEGMENT_ENTRY_INTERNAL_RESTART, | targetFrequencyHz, PLSR_SEGMENT_ENTRY_INTERNAL_RESTART, | ||||
| directionChanged, 0UL); | directionChanged, 0UL); | ||||
| if (PlsrPrepareShortProfile(&profile, nextSegment, | |||||
| if (PlsrPrepareShortProfile(&profile, &PlsrActiveConfig, nextSegment, | |||||
| startFrequencyHz, targetFrequencyHz, | startFrequencyHz, targetFrequencyHz, | ||||
| magnitude, positive, 0U) == 0U) | magnitude, positive, 0U) == 0U) | ||||
| { | { | ||||
| @@ -2819,7 +2827,8 @@ static PLSR_PLATFORM_SERVICE_RESULT PlsrPrepareDelayedCurrentOutput( | |||||
| criticalState = PlsrPlatformEnterCritical(); | criticalState = PlsrPlatformEnterCritical(); | ||||
| countPositive = PlsrCountPositive; | countPositive = PlsrCountPositive; | ||||
| PlsrPlatformExitCritical(criticalState); | PlsrPlatformExitCritical(criticalState); | ||||
| if (PlsrPrepareShortProfile(&profile, PlsrCurrentSegment, | |||||
| if (PlsrPrepareShortProfile(&profile, &PlsrActiveConfig, | |||||
| PlsrCurrentSegment, | |||||
| startFrequencyHz, targetFrequencyHz, | startFrequencyHz, targetFrequencyHz, | ||||
| remainingPulses, | remainingPulses, | ||||
| countPositive, 0U) == 0U) | countPositive, 0U) == 0U) | ||||
| @@ -3502,7 +3511,7 @@ static uint8_t PlsrBeginSegmentOutput(uint32_t startFrequencyHz) | |||||
| profileSegment = PlsrCurrentSegment; | profileSegment = PlsrCurrentSegment; | ||||
| countPositive = PlsrCountPositive; | countPositive = PlsrCountPositive; | ||||
| remainingPulses = PlsrRemainingSnapshot(); | remainingPulses = PlsrRemainingSnapshot(); | ||||
| if (PlsrPrepareShortProfile(&PlsrShortProfile, | |||||
| if (PlsrPrepareShortProfile(&PlsrShortProfile, &PlsrActiveConfig, | |||||
| profileSegment, startFrequencyHz, | profileSegment, startFrequencyHz, | ||||
| targetFrequencyHz, | targetFrequencyHz, | ||||
| remainingPulses, | remainingPulses, | ||||
| @@ -4089,7 +4098,7 @@ static uint8_t PlsrBuildHandoffPlan(uint8_t sourceSegment, | |||||
| } | } | ||||
| nextFrequencyHz = | nextFrequencyHz = | ||||
| PlsrResolvedSegmentFrequency(frequencyConfig, nextSegment - 1U); | PlsrResolvedSegmentFrequency(frequencyConfig, nextSegment - 1U); | ||||
| if (PlsrPrepareShortProfile(&plan->profile, nextSegment, | |||||
| if (PlsrPrepareShortProfile(&plan->profile, frequencyConfig, nextSegment, | |||||
| carryFrequencyHz, nextFrequencyHz, | carryFrequencyHz, nextFrequencyHz, | ||||
| plan->magnitude, positive, 0U) == 0U) | plan->magnitude, positive, 0U) == 0U) | ||||
| { | { | ||||