|
|
@@ -5,6 +5,47 @@ |
|
|
|
|
|
|
|
|
#define PLSR_PLANNER_Q32_ONE (4294967296ULL) |
|
|
#define PLSR_PLANNER_Q32_ONE (4294967296ULL) |
|
|
|
|
|
|
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
#define PLSR_PLANNER_CYCCNT_ADDRESS (0xE0001004UL) |
|
|
|
|
|
|
|
|
|
|
|
volatile PLSR_PLANNER_TIMING PlsrPlannerTiming; |
|
|
|
|
|
|
|
|
|
|
|
static uint32_t PlsrPlannerTimingNow(void) |
|
|
|
|
|
{ |
|
|
|
|
|
return *((volatile uint32_t *)PLSR_PLANNER_CYCCNT_ADDRESS); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void PlsrPlannerTimingRecord( |
|
|
|
|
|
volatile PLSR_PLANNER_TIMING_SAMPLE *sample, |
|
|
|
|
|
uint32_t startedAt) |
|
|
|
|
|
{ |
|
|
|
|
|
uint32_t elapsed = PlsrPlannerTimingNow() - startedAt; |
|
|
|
|
|
uint32_t total = sample->totalCycles; |
|
|
|
|
|
|
|
|
|
|
|
sample->lastCycles = elapsed; |
|
|
|
|
|
if ((sample->callCount == 0UL) || (elapsed < sample->minCycles)) |
|
|
|
|
|
{ |
|
|
|
|
|
sample->minCycles = elapsed; |
|
|
|
|
|
} |
|
|
|
|
|
if (sample->callCount != 0xFFFFFFFFUL) |
|
|
|
|
|
{ |
|
|
|
|
|
sample->callCount++; |
|
|
|
|
|
} |
|
|
|
|
|
sample->totalCycles = (elapsed > (0xFFFFFFFFUL - total)) |
|
|
|
|
|
? 0xFFFFFFFFUL : total + elapsed; |
|
|
|
|
|
if (elapsed > sample->maxCycles) |
|
|
|
|
|
{ |
|
|
|
|
|
sample->maxCycles = elapsed; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PlsrPlannerTimingReset(void) |
|
|
|
|
|
{ |
|
|
|
|
|
(void)memset((void *)&PlsrPlannerTiming, 0, sizeof(PlsrPlannerTiming)); |
|
|
|
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
static const uint32_t PlsrPlannerSmoothIntegralQ24[65] = |
|
|
static const uint32_t PlsrPlannerSmoothIntegralQ24[65] = |
|
|
{ |
|
|
{ |
|
|
0UL, 64UL, 504UL, 1688UL, 3968UL, 7688UL, 13176UL, 20752UL, |
|
|
0UL, 64UL, 504UL, 1688UL, 3968UL, 7688UL, 13176UL, 20752UL, |
|
|
@@ -402,38 +443,86 @@ static void PlsrPlannerStartRamp(PLSR_PLANNER_CONTEXT *context, |
|
|
uint32_t toHz, |
|
|
uint32_t toHz, |
|
|
uint32_t pulseCount) |
|
|
uint32_t pulseCount) |
|
|
{ |
|
|
{ |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
uint32_t totalStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
uint32_t phaseStartedAt; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
context->rampKind = rampKind; |
|
|
context->rampKind = rampKind; |
|
|
context->rampRelativePulse = 0UL; |
|
|
context->rampRelativePulse = 0UL; |
|
|
context->rampPulseCount = pulseCount; |
|
|
context->rampPulseCount = pulseCount; |
|
|
context->rampFromHz = fromHz; |
|
|
context->rampFromHz = fromHz; |
|
|
context->rampToHz = toHz; |
|
|
context->rampToHz = toHz; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
phaseStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
context->rampDurationMs = PlsrPlannerRampTime(&context->block, fromHz, toHz); |
|
|
context->rampDurationMs = PlsrPlannerRampTime(&context->block, fromHz, toHz); |
|
|
|
|
|
|
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampTime, phaseStartedAt); |
|
|
|
|
|
phaseStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
context->rampTotalAreaQ32 = PlsrPlannerRampAreaQ32( |
|
|
context->rampTotalAreaQ32 = PlsrPlannerRampAreaQ32( |
|
|
context, fromHz, toHz, PLSR_PLANNER_Q32_ONE); |
|
|
context, fromHz, toHz, PLSR_PLANNER_Q32_ONE); |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampTotalArea, |
|
|
|
|
|
phaseStartedAt); |
|
|
|
|
|
phaseStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
context->rampAreaStepQ32 = context->rampTotalAreaQ32 / pulseCount; |
|
|
context->rampAreaStepQ32 = context->rampTotalAreaQ32 / pulseCount; |
|
|
context->rampAreaRemainder = |
|
|
context->rampAreaRemainder = |
|
|
(uint32_t)(context->rampTotalAreaQ32 % pulseCount); |
|
|
(uint32_t)(context->rampTotalAreaQ32 % pulseCount); |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampAreaSplit, |
|
|
|
|
|
phaseStartedAt); |
|
|
|
|
|
#endif |
|
|
context->rampRemainderAccumulator = 0UL; |
|
|
context->rampRemainderAccumulator = 0UL; |
|
|
context->rampTargetAreaQ32 = 0ULL; |
|
|
context->rampTargetAreaQ32 = 0ULL; |
|
|
context->rampBoundaryQ32 = 0ULL; |
|
|
context->rampBoundaryQ32 = 0ULL; |
|
|
context->rampActualTimeQ32 = 0ULL; |
|
|
context->rampActualTimeQ32 = 0ULL; |
|
|
context->rampLastPhaseStepQ32 = 0ULL; |
|
|
context->rampLastPhaseStepQ32 = 0ULL; |
|
|
context->lastRampHz = 0UL; |
|
|
context->lastRampHz = 0UL; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
phaseStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
context->rampFirstBoundaryQ32 = PlsrPlannerExactBoundaryQ32( |
|
|
context->rampFirstBoundaryQ32 = PlsrPlannerExactBoundaryQ32( |
|
|
context, 0ULL, context->rampAreaStepQ32); |
|
|
context, 0ULL, context->rampAreaStepQ32); |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampFirstBoundary, |
|
|
|
|
|
phaseStartedAt); |
|
|
|
|
|
#endif |
|
|
if (pulseCount > 1UL) |
|
|
if (pulseCount > 1UL) |
|
|
{ |
|
|
{ |
|
|
uint64_t secondTargetAreaQ32 = context->rampAreaStepQ32 * 2ULL |
|
|
|
|
|
|
|
|
uint64_t secondTargetAreaQ32; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
phaseStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
|
|
|
secondTargetAreaQ32 = context->rampAreaStepQ32 * 2ULL |
|
|
+ ((uint64_t)context->rampAreaRemainder * 2ULL) / pulseCount; |
|
|
+ ((uint64_t)context->rampAreaRemainder * 2ULL) / pulseCount; |
|
|
context->rampSecondBoundaryQ32 = PlsrPlannerExactBoundaryQ32( |
|
|
context->rampSecondBoundaryQ32 = PlsrPlannerExactBoundaryQ32( |
|
|
context, context->rampFirstBoundaryQ32, |
|
|
context, context->rampFirstBoundaryQ32, |
|
|
secondTargetAreaQ32); |
|
|
secondTargetAreaQ32); |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampSecondBoundary, |
|
|
|
|
|
phaseStartedAt); |
|
|
|
|
|
#endif |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
context->rampSecondBoundaryQ32 = PLSR_PLANNER_Q32_ONE; |
|
|
context->rampSecondBoundaryQ32 = PLSR_PLANNER_Q32_ONE; |
|
|
} |
|
|
} |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.startRamp, totalStartedAt); |
|
|
|
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static uint8_t PlsrPlannerSameSetting( |
|
|
static uint8_t PlsrPlannerSameSetting( |
|
|
@@ -452,6 +541,12 @@ static uint8_t PlsrPlannerBuildStep(PLSR_PLANNER_CONTEXT *context, |
|
|
PLSR_PLATFORM_TIMER_SETTING *setting, |
|
|
PLSR_PLATFORM_TIMER_SETTING *setting, |
|
|
uint32_t *normalizedRequestedHz) |
|
|
uint32_t *normalizedRequestedHz) |
|
|
{ |
|
|
{ |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
uint32_t startedAt; |
|
|
|
|
|
uint8_t result; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
if (requestedHz == 0UL) |
|
|
if (requestedHz == 0UL) |
|
|
{ |
|
|
{ |
|
|
requestedHz = 1UL; |
|
|
requestedHz = 1UL; |
|
|
@@ -461,9 +556,19 @@ static uint8_t PlsrPlannerBuildStep(PLSR_PLANNER_CONTEXT *context, |
|
|
requestedHz = PLSR_FREQUENCY_MAX_HZ; |
|
|
requestedHz = PLSR_FREQUENCY_MAX_HZ; |
|
|
} |
|
|
} |
|
|
*normalizedRequestedHz = requestedHz; |
|
|
*normalizedRequestedHz = requestedHz; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
startedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
result = PlsrPlatformBuildTimerSetting(context->block.pulseOutput, |
|
|
|
|
|
PLSR_OUTPUT_PULSE_DIR, |
|
|
|
|
|
requestedHz, setting); |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.timerSetting, startedAt); |
|
|
|
|
|
return result; |
|
|
|
|
|
#else |
|
|
return PlsrPlatformBuildTimerSetting(context->block.pulseOutput, |
|
|
return PlsrPlatformBuildTimerSetting(context->block.pulseOutput, |
|
|
PLSR_OUTPUT_PULSE_DIR, |
|
|
PLSR_OUTPUT_PULSE_DIR, |
|
|
requestedHz, setting); |
|
|
requestedHz, setting); |
|
|
|
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static uint8_t PlsrPlannerTakeRampStep( |
|
|
static uint8_t PlsrPlannerTakeRampStep( |
|
|
@@ -476,6 +581,11 @@ static uint8_t PlsrPlannerTakeRampStep( |
|
|
uint64_t denominator; |
|
|
uint64_t denominator; |
|
|
uint64_t requestedHz; |
|
|
uint64_t requestedHz; |
|
|
uint64_t actualDeltaQ32; |
|
|
uint64_t actualDeltaQ32; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
uint32_t totalStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
uint32_t phaseStartedAt; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
context->rampTargetAreaQ32 += context->rampAreaStepQ32; |
|
|
context->rampTargetAreaQ32 += context->rampAreaStepQ32; |
|
|
context->rampRemainderAccumulator += context->rampAreaRemainder; |
|
|
context->rampRemainderAccumulator += context->rampAreaRemainder; |
|
|
@@ -499,8 +609,17 @@ static uint8_t PlsrPlannerTakeRampStep( |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
phaseStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
nextBoundaryQ32 = PlsrPlannerPredictedBoundaryQ32( |
|
|
nextBoundaryQ32 = PlsrPlannerPredictedBoundaryQ32( |
|
|
context, context->rampTargetAreaQ32); |
|
|
context, context->rampTargetAreaQ32); |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampPredictedBoundary, |
|
|
|
|
|
phaseStartedAt); |
|
|
|
|
|
#endif |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
desiredDeltaQ32 = (nextBoundaryQ32 > context->rampActualTimeQ32) |
|
|
desiredDeltaQ32 = (nextBoundaryQ32 > context->rampActualTimeQ32) |
|
|
@@ -509,11 +628,20 @@ static uint8_t PlsrPlannerTakeRampStep( |
|
|
/* The allocated pulse count closes the ramp area exactly. Derive the |
|
|
/* The allocated pulse count closes the ramp area exactly. Derive the |
|
|
physical duration from N/averageHz instead of rounding it to whole |
|
|
physical duration from N/averageHz instead of rounding it to whole |
|
|
milliseconds; short clipped ramps can be well below 1 ms. */ |
|
|
milliseconds; short clipped ramps can be well below 1 ms. */ |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
phaseStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
denominator = (uint64_t)context->rampPulseCount * desiredDeltaQ32; |
|
|
denominator = (uint64_t)context->rampPulseCount * desiredDeltaQ32; |
|
|
requestedHz = (denominator == 0ULL) |
|
|
requestedHz = (denominator == 0ULL) |
|
|
? context->rampToHz |
|
|
? context->rampToHz |
|
|
: (context->rampTotalAreaQ32 |
|
|
: (context->rampTotalAreaQ32 |
|
|
+ denominator / 2ULL) / denominator; |
|
|
+ denominator / 2ULL) / denominator; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampRequestedDivide, |
|
|
|
|
|
phaseStartedAt); |
|
|
|
|
|
#endif |
|
|
if (requestedHz == 0ULL) |
|
|
if (requestedHz == 0ULL) |
|
|
{ |
|
|
{ |
|
|
requestedHz = 1ULL; |
|
|
requestedHz = 1ULL; |
|
|
@@ -533,21 +661,39 @@ static uint8_t PlsrPlannerTakeRampStep( |
|
|
if (PlsrPlannerBuildStep(context, (uint32_t)requestedHz, setting, |
|
|
if (PlsrPlannerBuildStep(context, (uint32_t)requestedHz, setting, |
|
|
requestedFrequencyHz) == 0U) |
|
|
requestedFrequencyHz) == 0U) |
|
|
{ |
|
|
{ |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampStep, |
|
|
|
|
|
totalStartedAt); |
|
|
|
|
|
#endif |
|
|
return 0U; |
|
|
return 0U; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
phaseStartedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
denominator = (uint64_t)context->rampPulseCount |
|
|
denominator = (uint64_t)context->rampPulseCount |
|
|
* setting->actualFrequencyHz; |
|
|
* setting->actualFrequencyHz; |
|
|
actualDeltaQ32 = (denominator == 0ULL) |
|
|
actualDeltaQ32 = (denominator == 0ULL) |
|
|
? desiredDeltaQ32 |
|
|
? desiredDeltaQ32 |
|
|
: (context->rampTotalAreaQ32 |
|
|
: (context->rampTotalAreaQ32 |
|
|
+ denominator / 2ULL) / denominator; |
|
|
+ denominator / 2ULL) / denominator; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampActualDivide, |
|
|
|
|
|
phaseStartedAt); |
|
|
|
|
|
#endif |
|
|
context->rampActualTimeQ32 += actualDeltaQ32; |
|
|
context->rampActualTimeQ32 += actualDeltaQ32; |
|
|
context->rampLastPhaseStepQ32 = |
|
|
context->rampLastPhaseStepQ32 = |
|
|
nextBoundaryQ32 - context->rampBoundaryQ32; |
|
|
nextBoundaryQ32 - context->rampBoundaryQ32; |
|
|
context->rampBoundaryQ32 = nextBoundaryQ32; |
|
|
context->rampBoundaryQ32 = nextBoundaryQ32; |
|
|
context->lastRampHz = setting->actualFrequencyHz; |
|
|
context->lastRampHz = setting->actualFrequencyHz; |
|
|
context->rampRelativePulse++; |
|
|
context->rampRelativePulse++; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.rampStep, totalStartedAt); |
|
|
|
|
|
#endif |
|
|
return 1U; |
|
|
return 1U; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -602,6 +748,10 @@ PLSR_PLANNER_STATUS PlsrPlannerBegin(PLSR_PLANNER_CONTEXT *context, |
|
|
uint64_t exitWeight; |
|
|
uint64_t exitWeight; |
|
|
uint64_t totalWeight; |
|
|
uint64_t totalWeight; |
|
|
uint64_t scaledEntry; |
|
|
uint64_t scaledEntry; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
uint32_t startedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
if ((context == NULL) || (block == NULL) |
|
|
if ((context == NULL) || (block == NULL) |
|
|
|| (block->pulseBudget == 0UL) |
|
|
|| (block->pulseBudget == 0UL) |
|
|
@@ -614,6 +764,10 @@ PLSR_PLANNER_STATUS PlsrPlannerBegin(PLSR_PLANNER_CONTEXT *context, |
|
|
|| (appliedHz > PLSR_FREQUENCY_MAX_HZ) |
|
|
|| (appliedHz > PLSR_FREQUENCY_MAX_HZ) |
|
|
|| (block->curveMode > 2U) || (block->pulseOutput > 3U)) |
|
|
|| (block->curveMode > 2U) || (block->pulseOutput > 3U)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.begin, startedAt); |
|
|
|
|
|
#endif |
|
|
return PLSR_PLANNER_INVALID; |
|
|
return PLSR_PLANNER_INVALID; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -640,6 +794,10 @@ PLSR_PLANNER_STATUS PlsrPlannerBegin(PLSR_PLANNER_CONTEXT *context, |
|
|
context->entryPulses = block->pulseBudget; |
|
|
context->entryPulses = block->pulseBudget; |
|
|
context->clipped = 1U; |
|
|
context->clipped = 1U; |
|
|
context->active = 1U; |
|
|
context->active = 1U; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.begin, startedAt); |
|
|
|
|
|
#endif |
|
|
return PLSR_PLANNER_CLIPPED; |
|
|
return PLSR_PLANNER_CLIPPED; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -695,6 +853,10 @@ PLSR_PLANNER_STATUS PlsrPlannerBegin(PLSR_PLANNER_CONTEXT *context, |
|
|
context->clipped = 1U; |
|
|
context->clipped = 1U; |
|
|
} |
|
|
} |
|
|
context->active = 1U; |
|
|
context->active = 1U; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.begin, startedAt); |
|
|
|
|
|
#endif |
|
|
return (context->clipped != 0U) ? PLSR_PLANNER_CLIPPED |
|
|
return (context->clipped != 0U) ? PLSR_PLANNER_CLIPPED |
|
|
: PLSR_PLANNER_OK; |
|
|
: PLSR_PLANNER_OK; |
|
|
} |
|
|
} |
|
|
@@ -707,10 +869,18 @@ uint16_t PlsrPlannerGenerate(PLSR_PLANNER_CONTEXT *context,//规划账本:三 |
|
|
uint32_t requestedFrequencyHz; |
|
|
uint32_t requestedFrequencyHz; |
|
|
uint32_t repeatCount; |
|
|
uint32_t repeatCount; |
|
|
uint16_t produced = 0U; |
|
|
uint16_t produced = 0U; |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
uint32_t startedAt = PlsrPlannerTimingNow(); |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
if ((context == NULL) || (output == NULL) || (capacity == 0U) |
|
|
if ((context == NULL) || (output == NULL) || (capacity == 0U) |
|
|
|| (context->active == 0U)) |
|
|
|| (context->active == 0U)) |
|
|
{ |
|
|
{ |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.generate, startedAt); |
|
|
|
|
|
#endif |
|
|
return 0U; |
|
|
return 0U; |
|
|
} |
|
|
} |
|
|
while ((produced < capacity)&& (context->generatedPulses < context->block.pulseBudget)) |
|
|
while ((produced < capacity)&& (context->generatedPulses < context->block.pulseBudget)) |
|
|
@@ -746,6 +916,10 @@ uint16_t PlsrPlannerGenerate(PLSR_PLANNER_CONTEXT *context,//规划账本:三 |
|
|
{ |
|
|
{ |
|
|
context->active = 0U; |
|
|
context->active = 0U; |
|
|
} |
|
|
} |
|
|
|
|
|
#if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0) \ |
|
|
|
|
|
&& !defined(PLSR_HOST_TEST) |
|
|
|
|
|
PlsrPlannerTimingRecord(&PlsrPlannerTiming.generate, startedAt); |
|
|
|
|
|
#endif |
|
|
return produced; |
|
|
return produced; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|