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ů.
 
 
 
 
 
 

148 řádky
5.1 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_QUEUE_DIAGNOSTIC_FIRST_ADDRESS (0x2200U)
  16. #define PLSR_QUEUE_DIAGNOSTIC_LAST_ADDRESS (0x2208U)
  17. #define PLSR_DIAGNOSTIC_CONTROL_ADDRESS (0x3100U)
  18. typedef enum
  19. {
  20. PLSR_MB_NOT_HANDLED = 0,
  21. PLSR_MB_OK,
  22. PLSR_MB_ILLEGAL_ADDRESS,
  23. PLSR_MB_ILLEGAL_VALUE,
  24. PLSR_MB_DEVICE_BUSY,
  25. PLSR_MB_SERVER_FAILURE
  26. } PLSR_MB_RESULT;
  27. typedef enum
  28. {
  29. PLSR_STATUS_UNINITIALIZED = 0,
  30. PLSR_STATUS_IDLE = 1,
  31. PLSR_STATUS_ACCELERATING = 2,
  32. PLSR_STATUS_RUNNING = 3,
  33. PLSR_STATUS_DECELERATING = 4,
  34. PLSR_STATUS_WAITING = 5,
  35. PLSR_STATUS_PAUSED = 6,
  36. PLSR_STATUS_COMPLETED = 7,
  37. PLSR_STATUS_STOPPED = 8,
  38. PLSR_STATUS_ERROR = 9
  39. } PLSR_STATUS;
  40. typedef enum
  41. {
  42. PLSR_ERROR_NONE = 0,
  43. PLSR_ERROR_INVALID_TRANSITION = 1,
  44. PLSR_ERROR_RESOURCE_CONFLICT = 2,
  45. PLSR_ERROR_INVALID_RESOURCE = 3,
  46. PLSR_ERROR_TIMER = 4,
  47. PLSR_ERROR_COUNT = 5,
  48. PLSR_ERROR_POSITIVE_LIMIT = 6,
  49. PLSR_ERROR_NEGATIVE_LIMIT = 7,
  50. PLSR_ERROR_EMERGENCY_STOP = 8,
  51. PLSR_ERROR_INTERNAL = 9
  52. } PLSR_ERROR;
  53. uint8_t PlsrInit(void);
  54. void PlsrPoll1ms(void);
  55. /* Returns nonzero while another immediate bounded producer pass is useful. */
  56. uint8_t PlsrServiceProfileProducer(uint16_t itemBudget);
  57. void PlsrServicePersistence(void);
  58. PLSR_MB_RESULT PlsrModbusReadHolding(uint16_t startAddress,
  59. uint16_t quantity,
  60. uint16_t *values);
  61. PLSR_MB_RESULT PlsrModbusWriteHolding(uint16_t startAddress,
  62. uint16_t quantity,
  63. const uint16_t *values);
  64. /* Legacy per-pulse path used by variable-frequency and AB output. */
  65. void PlsrPulseTimerIrq(uint8_t pulseOutput);
  66. void PlsrFinalArmJobIrq(uint8_t pulseOutput);
  67. #ifdef PLSR_HOST_TEST
  68. void PlsrTestSetInput(uint8_t inputSelection, uint8_t level);
  69. void PlsrTestEmitPulses(uint32_t pulseCount);
  70. void PlsrTestEnableFinitePulseTrain(uint8_t enable);
  71. void PlsrTestCompleteFinitePulseTrain(void);
  72. uint8_t PlsrTestFinitePulseTrainActive(void);
  73. void PlsrTestEmitPulseOnCriticalEntry(void);
  74. void PlsrTestEmitPulseAfterCriticalEntries(uint8_t entriesToSkip);
  75. void PlsrTestEmitPulseOnCriticalExit(void);
  76. void PlsrTestLatchPulseOnCriticalEntry(void);
  77. void PlsrTestLatchAbFinalQuarterOnNextStopArm(void);
  78. void PlsrTestCompleteAbCycleOnNextQueueCommit(void);
  79. void PlsrTestServicePendingPulse(void);
  80. void PlsrTestServiceFinalArmJob(void);
  81. void PlsrTestDeferFinalArmJob(uint8_t defer);
  82. void PlsrTestFailNextStart(void);
  83. void PlsrTestStaleNextFrequencyAtUpdate(void);
  84. void PlsrTestFailNextFrequencyAtUpdate(void);
  85. void PlsrTestFailNextStopRequest(void);
  86. void PlsrTestEmitAbQuarters(uint32_t quarterCount);
  87. uint8_t PlsrTestPulseIsActive(void);
  88. uint32_t PlsrTestOutputFrequency(void);
  89. uint32_t PlsrTestQueuedFrequency(void);
  90. uint8_t PlsrTestDirectionLevel(void);
  91. uint8_t PlsrTestDirectionPinLevel(uint8_t directionOutput);
  92. uint32_t PlsrTestDirectionWriteCount(uint8_t directionOutput);
  93. uint32_t PlsrTestDirectionTransitionCount(uint8_t directionOutput);
  94. uint8_t PlsrTestAbPhase(void);
  95. uint32_t PlsrTestAbTransitionCount(void);
  96. uint32_t PlsrTestAbFastGateCount(void);
  97. uint32_t PlsrTestAbCleanupCount(void);
  98. void PlsrTestInjectCountOffset(int32_t offset);
  99. void PlsrTestInjectActiveFrequencyOffset(int32_t offsetHz);
  100. void PlsrTestInjectCurveMismatch(void);
  101. void PlsrTestForceProfileQueueEmpty(void);
  102. uint16_t PlsrTestProfileQueueCount(void);
  103. uint32_t PlsrTestProfileQueueGeneration(void);
  104. uint32_t PlsrTestProfileQueueReadIndex(void);
  105. uint32_t PlsrTestProfileQueueWriteIndex(void);
  106. uint32_t PlsrTestProfileQueueHeadFrequency(void);
  107. uint16_t PlsrTestProfileProducerNextPeriod(void);
  108. uint16_t PlsrTestActiveProfileNextPeriod(void);
  109. uint32_t PlsrTestLastGateEvent(void);
  110. uint32_t PlsrTestLastDiagnosticFinishEvent(void);
  111. uint8_t PlsrTestInitialDirectionPreparePending(void);
  112. void PlsrTestSetPosition(int32_t position, uint8_t positionValid);
  113. void PlsrTestClearPersistentStorage(void);
  114. void PlsrTestResetSaveCount(void);
  115. uint32_t PlsrTestSaveCount(void);
  116. #endif
  117. #if defined(PLSR_DEBUG_TIMING) && (PLSR_DEBUG_TIMING != 0)
  118. extern volatile uint32_t PlsrProfileProducerItemCount;
  119. extern volatile uint32_t PlsrProfileProducerTotalCycles;
  120. extern volatile uint32_t PlsrProfileProducerMaxItemCycles;
  121. extern volatile uint32_t PlsrFiniteBlockIrqCount[4];
  122. extern volatile uint32_t PlsrFiniteBlockIrqLastCycles[4];
  123. extern volatile uint32_t PlsrFiniteBlockIrqTotalCycles[4];
  124. extern volatile uint32_t PlsrFiniteBlockIrqMaxCycles[4];
  125. extern volatile uint32_t PlsrFiniteFinalIrqCount[4];
  126. extern volatile uint32_t PlsrFiniteFinalIrqLastCycles[4];
  127. extern volatile uint32_t PlsrFiniteFinalIrqTotalCycles[4];
  128. extern volatile uint32_t PlsrFiniteFinalIrqMaxCycles[4];
  129. #endif
  130. #ifdef __cplusplus
  131. }
  132. #endif
  133. #endif /* PLSR_H */