|
- #ifndef PLSR_H
- #define PLSR_H
-
- #include <stdint.h>
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #define PLSR_CONFIG_FIRST_ADDRESS (0x1000U)
- #define PLSR_CONFIG_LAST_ADDRESS (0x1197U)
- #define PLSR_STATUS_FIRST_ADDRESS (0x2000U)
- #define PLSR_STATUS_LAST_ADDRESS (0x2006U)
- #define PLSR_CONTROL_ADDRESS (0x3000U)
-
- #define PLSR_OUTPUT_MODE_ADDRESS (0x1200U)
- #define PLSR_DIAGNOSTIC_FIRST_ADDRESS (0x2100U)
- #define PLSR_DIAGNOSTIC_LAST_ADDRESS (0x2119U)
- #define PLSR_QUEUE_DIAGNOSTIC_FIRST_ADDRESS (0x2200U)
- #define PLSR_QUEUE_DIAGNOSTIC_LAST_ADDRESS (0x2208U)
- #define PLSR_DIAGNOSTIC_CONTROL_ADDRESS (0x3100U)
-
- typedef enum
- {
- PLSR_MB_NOT_HANDLED = 0,
- PLSR_MB_OK,
- PLSR_MB_ILLEGAL_ADDRESS,
- PLSR_MB_ILLEGAL_VALUE,
- PLSR_MB_DEVICE_BUSY,
- PLSR_MB_SERVER_FAILURE
- } PLSR_MB_RESULT;
-
- typedef enum
- {
- PLSR_STATUS_UNINITIALIZED = 0,
- PLSR_STATUS_IDLE = 1,
- PLSR_STATUS_ACCELERATING = 2,
- PLSR_STATUS_RUNNING = 3,
- PLSR_STATUS_DECELERATING = 4,
- PLSR_STATUS_WAITING = 5,
- PLSR_STATUS_PAUSED = 6,
- PLSR_STATUS_COMPLETED = 7,
- PLSR_STATUS_STOPPED = 8,
- PLSR_STATUS_ERROR = 9
- } PLSR_STATUS;
-
- typedef enum
- {
- PLSR_ERROR_NONE = 0,
- PLSR_ERROR_INVALID_TRANSITION = 1,
- PLSR_ERROR_RESOURCE_CONFLICT = 2,
- PLSR_ERROR_INVALID_RESOURCE = 3,
- PLSR_ERROR_TIMER = 4,
- PLSR_ERROR_COUNT = 5,
- PLSR_ERROR_POSITIVE_LIMIT = 6,
- PLSR_ERROR_NEGATIVE_LIMIT = 7,
- PLSR_ERROR_EMERGENCY_STOP = 8,
- PLSR_ERROR_INTERNAL = 9
- } PLSR_ERROR;
-
- uint8_t PlsrInit(void);
- void PlsrPoll1ms(void);
- /* Returns nonzero while another immediate bounded producer pass is useful. */
- uint8_t PlsrServiceProfileProducer(uint16_t itemBudget);
- void PlsrServicePersistence(void);
-
- PLSR_MB_RESULT PlsrModbusReadHolding(uint16_t startAddress,
- uint16_t quantity,
- uint16_t *values);
- PLSR_MB_RESULT PlsrModbusWriteHolding(uint16_t startAddress,
- uint16_t quantity,
- const uint16_t *values);
-
- /* Legacy per-pulse path used by variable-frequency and AB output. */
- void PlsrPulseTimerIrq(uint8_t pulseOutput);
- void PlsrFinalArmJobIrq(uint8_t pulseOutput);
-
- #ifdef PLSR_HOST_TEST
- void PlsrTestSetInput(uint8_t inputSelection, uint8_t level);
- void PlsrTestEmitPulses(uint32_t pulseCount);
- void PlsrTestEnableFinitePulseTrain(uint8_t enable);
- void PlsrTestCompleteFinitePulseTrain(void);
- uint8_t PlsrTestFinitePulseTrainActive(void);
- void PlsrTestEmitPulseOnCriticalEntry(void);
- void PlsrTestEmitPulseAfterCriticalEntries(uint8_t entriesToSkip);
- void PlsrTestEmitPulseOnCriticalExit(void);
- void PlsrTestLatchPulseOnCriticalEntry(void);
- void PlsrTestLatchAbFinalQuarterOnNextStopArm(void);
- void PlsrTestCompleteAbCycleOnNextQueueCommit(void);
- void PlsrTestServicePendingPulse(void);
- void PlsrTestServiceFinalArmJob(void);
- void PlsrTestDeferFinalArmJob(uint8_t defer);
- void PlsrTestFailNextStart(void);
- void PlsrTestStaleNextFrequencyAtUpdate(void);
- void PlsrTestFailNextFrequencyAtUpdate(void);
- void PlsrTestFailNextStopRequest(void);
- void PlsrTestEmitAbQuarters(uint32_t quarterCount);
- uint8_t PlsrTestPulseIsActive(void);
- uint32_t PlsrTestOutputFrequency(void);
- uint32_t PlsrTestQueuedFrequency(void);
- uint8_t PlsrTestDirectionLevel(void);
- uint8_t PlsrTestDirectionPinLevel(uint8_t directionOutput);
- uint32_t PlsrTestDirectionWriteCount(uint8_t directionOutput);
- uint32_t PlsrTestDirectionTransitionCount(uint8_t directionOutput);
- uint8_t PlsrTestAbPhase(void);
- uint32_t PlsrTestAbTransitionCount(void);
- uint32_t PlsrTestAbFastGateCount(void);
- uint32_t PlsrTestAbCleanupCount(void);
- void PlsrTestInjectCountOffset(int32_t offset);
- void PlsrTestInjectActiveFrequencyOffset(int32_t offsetHz);
- void PlsrTestInjectCurveMismatch(void);
- void PlsrTestForceProfileQueueEmpty(void);
- uint16_t PlsrTestProfileQueueCount(void);
- uint32_t PlsrTestProfileQueueGeneration(void);
- uint32_t PlsrTestProfileQueueReadIndex(void);
- uint32_t PlsrTestProfileQueueWriteIndex(void);
- uint32_t PlsrTestProfileQueueHeadFrequency(void);
- uint16_t PlsrTestProfileProducerNextPeriod(void);
- uint16_t PlsrTestActiveProfileNextPeriod(void);
- uint32_t PlsrTestLastGateEvent(void);
- uint32_t PlsrTestLastDiagnosticFinishEvent(void);
- void PlsrTestSetPosition(int32_t position, uint8_t positionValid);
- void PlsrTestClearPersistentStorage(void);
- void PlsrTestResetSaveCount(void);
- uint32_t PlsrTestSaveCount(void);
- #endif
-
- #if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0)
- extern volatile uint32_t PlsrProfileProducerItemCount;
- extern volatile uint32_t PlsrProfileProducerTotalCycles;
- extern volatile uint32_t PlsrProfileProducerMaxItemCycles;
- extern volatile uint32_t PlsrFiniteBlockIrqCount[4];
- extern volatile uint32_t PlsrFiniteBlockIrqLastCycles[4];
- extern volatile uint32_t PlsrFiniteBlockIrqTotalCycles[4];
- extern volatile uint32_t PlsrFiniteBlockIrqMaxCycles[4];
- extern volatile uint32_t PlsrFiniteFinalIrqCount[4];
- extern volatile uint32_t PlsrFiniteFinalIrqLastCycles[4];
- extern volatile uint32_t PlsrFiniteFinalIrqTotalCycles[4];
- extern volatile uint32_t PlsrFiniteFinalIrqMaxCycles[4];
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* PLSR_H */
|