Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

135 řádky
4.4 KiB

  1. #ifndef PLSR_H
  2. #define PLSR_H
  3. #include <stdint.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #define PLSR_CONFIG_FIRST_ADDRESS (0x1000U)
  8. #define PLSR_CONFIG_LAST_ADDRESS (0x1197U)
  9. #define PLSR_STATUS_FIRST_ADDRESS (0x2000U)
  10. #define PLSR_STATUS_LAST_ADDRESS (0x2006U)
  11. #define PLSR_CONTROL_ADDRESS (0x3000U)
  12. #define PLSR_OUTPUT_MODE_ADDRESS (0x1200U)
  13. #define PLSR_DIAGNOSTIC_FIRST_ADDRESS (0x2100U)
  14. #define PLSR_DIAGNOSTIC_LAST_ADDRESS (0x2119U)
  15. #define PLSR_DIAGNOSTIC_CONTROL_ADDRESS (0x3100U)
  16. typedef enum
  17. {
  18. PLSR_MB_NOT_HANDLED = 0,
  19. PLSR_MB_OK,
  20. PLSR_MB_ILLEGAL_ADDRESS,
  21. PLSR_MB_ILLEGAL_VALUE,
  22. PLSR_MB_DEVICE_BUSY,
  23. PLSR_MB_SERVER_FAILURE
  24. } PLSR_MB_RESULT;
  25. typedef enum
  26. {
  27. PLSR_STATUS_UNINITIALIZED = 0,
  28. PLSR_STATUS_IDLE = 1,
  29. PLSR_STATUS_ACCELERATING = 2,
  30. PLSR_STATUS_RUNNING = 3,
  31. PLSR_STATUS_DECELERATING = 4,
  32. PLSR_STATUS_WAITING = 5,
  33. PLSR_STATUS_PAUSED = 6,
  34. PLSR_STATUS_COMPLETED = 7,
  35. PLSR_STATUS_STOPPED = 8,
  36. PLSR_STATUS_ERROR = 9
  37. } PLSR_STATUS;
  38. typedef enum
  39. {
  40. PLSR_ERROR_NONE = 0,
  41. PLSR_ERROR_INVALID_TRANSITION = 1,
  42. PLSR_ERROR_RESOURCE_CONFLICT = 2,
  43. PLSR_ERROR_INVALID_RESOURCE = 3,
  44. PLSR_ERROR_TIMER = 4,
  45. PLSR_ERROR_COUNT = 5,
  46. PLSR_ERROR_POSITIVE_LIMIT = 6,
  47. PLSR_ERROR_NEGATIVE_LIMIT = 7,
  48. PLSR_ERROR_EMERGENCY_STOP = 8,
  49. PLSR_ERROR_INTERNAL = 9
  50. } PLSR_ERROR;
  51. uint8_t PlsrInit(void);
  52. void PlsrPoll1ms(void);
  53. void PlsrServicePersistence(void);
  54. PLSR_MB_RESULT PlsrModbusReadHolding(uint16_t startAddress,
  55. uint16_t quantity,
  56. uint16_t *values);
  57. PLSR_MB_RESULT PlsrModbusWriteHolding(uint16_t startAddress,
  58. uint16_t quantity,
  59. const uint16_t *values);
  60. /* Called by the selected output timer update interrupt once per pulse. */
  61. void PlsrPulseTimerIrq(uint8_t pulseOutput);
  62. void PlsrFinalArmJobIrq(uint8_t pulseOutput);
  63. #ifdef PLSR_HOST_TEST
  64. uint64_t PlsrTestDivideU64ByU32(uint64_t dividend,
  65. uint32_t divisor,
  66. uint32_t *remainder);
  67. void PlsrTestSetInput(uint8_t inputSelection, uint8_t level);
  68. void PlsrTestEmitPulses(uint32_t pulseCount);
  69. void PlsrTestEmitPulseOnCriticalEntry(void);
  70. void PlsrTestEmitPulseAfterCriticalEntries(uint8_t entriesToSkip);
  71. void PlsrTestEmitPulseOnCriticalExit(void);
  72. void PlsrTestLatchPulseOnCriticalEntry(void);
  73. void PlsrTestLatchAbFinalQuarterOnNextStopArm(void);
  74. void PlsrTestCompleteAbCycleOnNextQueueCommit(void);
  75. void PlsrTestServicePendingPulse(void);
  76. void PlsrTestServiceFinalArmJob(void);
  77. void PlsrTestDeferFinalArmJob(uint8_t defer);
  78. void PlsrTestFailNextStart(void);
  79. void PlsrTestStaleNextFrequencyAtUpdate(void);
  80. void PlsrTestFailNextFrequencyAtUpdate(void);
  81. void PlsrTestFailNextStopRequest(void);
  82. void PlsrTestEmitAbQuarters(uint32_t quarterCount);
  83. uint8_t PlsrTestPulseIsActive(void);
  84. uint32_t PlsrTestOutputFrequency(void);
  85. uint32_t PlsrTestQueuedFrequency(void);
  86. uint8_t PlsrTestDirectionLevel(void);
  87. uint8_t PlsrTestDirectionPinLevel(uint8_t directionOutput);
  88. uint32_t PlsrTestDirectionWriteCount(uint8_t directionOutput);
  89. uint32_t PlsrTestDirectionTransitionCount(uint8_t directionOutput);
  90. uint8_t PlsrTestAbPhase(void);
  91. uint32_t PlsrTestAbTransitionCount(void);
  92. uint32_t PlsrTestAbFastGateCount(void);
  93. uint32_t PlsrTestAbCleanupCount(void);
  94. void PlsrTestInjectCountOffset(int32_t offset);
  95. void PlsrTestInjectActiveFrequencyOffset(int32_t offsetHz);
  96. void PlsrTestInjectCurveMismatch(void);
  97. void PlsrTestForceProfileQueueEmpty(void);
  98. uint16_t PlsrTestProfileQueueCount(void);
  99. uint32_t PlsrTestProfileQueueGeneration(void);
  100. uint32_t PlsrTestProfileQueueReadIndex(void);
  101. uint32_t PlsrTestProfileQueueWriteIndex(void);
  102. uint32_t PlsrTestProfileQueueHeadFrequency(void);
  103. uint16_t PlsrTestProfileProducerNextPeriod(void);
  104. uint16_t PlsrTestActiveProfileNextPeriod(void);
  105. uint32_t PlsrTestLastGateEvent(void);
  106. uint32_t PlsrTestLastDiagnosticFinishEvent(void);
  107. void PlsrTestSetPosition(int32_t position, uint8_t positionValid);
  108. void PlsrTestClearPersistentStorage(void);
  109. void PlsrTestResetSaveCount(void);
  110. uint32_t PlsrTestSaveCount(void);
  111. #endif
  112. #if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0)
  113. extern volatile uint32_t PlsrProfileProducerItemCount;
  114. extern volatile uint32_t PlsrProfileProducerTotalCycles;
  115. extern volatile uint32_t PlsrProfileProducerMaxItemCycles;
  116. #endif
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif /* PLSR_H */