Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

95 righe
2.6 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. typedef enum
  13. {
  14. PLSR_MB_NOT_HANDLED = 0,
  15. PLSR_MB_OK,
  16. PLSR_MB_ILLEGAL_ADDRESS,
  17. PLSR_MB_ILLEGAL_VALUE,
  18. PLSR_MB_DEVICE_BUSY,
  19. PLSR_MB_SERVER_FAILURE
  20. } PLSR_MB_RESULT;
  21. typedef enum
  22. {
  23. PLSR_STATUS_UNINITIALIZED = 0,
  24. PLSR_STATUS_IDLE = 1,
  25. PLSR_STATUS_ACCELERATING = 2,
  26. PLSR_STATUS_RUNNING = 3,
  27. PLSR_STATUS_DECELERATING = 4,
  28. PLSR_STATUS_WAITING = 5,
  29. PLSR_STATUS_PAUSED = 6,
  30. PLSR_STATUS_COMPLETED = 7,
  31. PLSR_STATUS_STOPPED = 8,
  32. PLSR_STATUS_ERROR = 9
  33. } PLSR_STATUS;
  34. typedef enum
  35. {
  36. PLSR_ERROR_NONE = 0,
  37. PLSR_ERROR_INVALID_TRANSITION = 1,
  38. PLSR_ERROR_RESOURCE_CONFLICT = 2,
  39. PLSR_ERROR_INVALID_RESOURCE = 3,
  40. PLSR_ERROR_TIMER = 4,
  41. PLSR_ERROR_COUNT = 5,
  42. PLSR_ERROR_POSITIVE_LIMIT = 6,
  43. PLSR_ERROR_NEGATIVE_LIMIT = 7,
  44. PLSR_ERROR_EMERGENCY_STOP = 8,
  45. PLSR_ERROR_INTERNAL = 9
  46. } PLSR_ERROR;
  47. uint8_t PlsrInit(void);
  48. void PlsrPoll1ms(void);
  49. PLSR_MB_RESULT PlsrModbusReadHolding(uint16_t startAddress,
  50. uint16_t quantity,
  51. uint16_t *values);
  52. PLSR_MB_RESULT PlsrModbusWriteHolding(uint16_t startAddress,
  53. uint16_t quantity,
  54. const uint16_t *values);
  55. /* Called by the selected output timer update interrupt once per pulse. */
  56. void PlsrPulseTimerIrq(uint8_t pulseOutput);
  57. #ifdef PLSR_HOST_TEST
  58. uint64_t PlsrTestDivideU64ByU32(uint64_t dividend,
  59. uint32_t divisor,
  60. uint32_t *remainder);
  61. void PlsrTestSetInput(uint8_t inputSelection, uint8_t level);
  62. void PlsrTestEmitPulses(uint32_t pulseCount);
  63. void PlsrTestEmitPulseOnCriticalEntry(void);
  64. void PlsrTestEmitPulseAfterCriticalEntries(uint8_t entriesToSkip);
  65. void PlsrTestEmitPulseOnCriticalExit(void);
  66. void PlsrTestLatchPulseOnCriticalEntry(void);
  67. void PlsrTestServicePendingPulse(void);
  68. void PlsrTestFailNextStart(void);
  69. void PlsrTestFailNextFrequencyAtUpdate(void);
  70. uint8_t PlsrTestPulseIsActive(void);
  71. uint32_t PlsrTestOutputFrequency(void);
  72. uint32_t PlsrTestQueuedFrequency(void);
  73. uint8_t PlsrTestDirectionLevel(void);
  74. void PlsrTestSetPosition(int32_t position, uint8_t positionValid);
  75. void PlsrTestClearPersistentStorage(void);
  76. void PlsrTestResetSaveCount(void);
  77. uint32_t PlsrTestSaveCount(void);
  78. #endif
  79. #ifdef __cplusplus
  80. }
  81. #endif
  82. #endif /* PLSR_H */