|
- #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)
-
- 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);
-
- 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);
-
- /* Called by the selected output timer update interrupt once per pulse. */
- void PlsrPulseTimerIrq(uint8_t pulseOutput);
-
- #ifdef PLSR_HOST_TEST
- uint64_t PlsrTestDivideU64ByU32(uint64_t dividend,
- uint32_t divisor,
- uint32_t *remainder);
- void PlsrTestSetInput(uint8_t inputSelection, uint8_t level);
- void PlsrTestEmitPulses(uint32_t pulseCount);
- void PlsrTestEmitPulseOnCriticalEntry(void);
- void PlsrTestEmitPulseAfterCriticalEntries(uint8_t entriesToSkip);
- void PlsrTestEmitPulseOnCriticalExit(void);
- void PlsrTestLatchPulseOnCriticalEntry(void);
- void PlsrTestServicePendingPulse(void);
- void PlsrTestFailNextStart(void);
- void PlsrTestFailNextFrequencyAtUpdate(void);
- uint8_t PlsrTestPulseIsActive(void);
- uint32_t PlsrTestOutputFrequency(void);
- uint32_t PlsrTestQueuedFrequency(void);
- uint8_t PlsrTestDirectionLevel(void);
- void PlsrTestSetPosition(int32_t position, uint8_t positionValid);
- void PlsrTestClearPersistentStorage(void);
- void PlsrTestResetSaveCount(void);
- uint32_t PlsrTestSaveCount(void);
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* PLSR_H */
|