deviceparams.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*=====================================================================================
  2. * Description:
  3. * The Modbus parameter structures used to define Modbus instances that
  4. * can be addressed by Modbus protocol. Define these structures per your needs in
  5. * your application. Below is just an example of possible parameters.
  6. *====================================================================================*/
  7. #ifndef _DEVICE_PARAMS
  8. #define _DEVICE_PARAMS
  9. #define A24_ARR_SIZE 24
  10. // This file defines structure of modbus parameters which reflect correspond modbus address space
  11. // for each modbus register type (coils, discreet inputs, holding registers, input registers)
  12. #pragma pack(push, 1)
  13. typedef struct
  14. {
  15. // Parameter: discrete_input0
  16. uint8_t discrete_input0:1;
  17. // Parameter: discrete_input1
  18. uint8_t discrete_input1:1;
  19. // Parameter: discrete_input2
  20. uint8_t discrete_input2:1;
  21. // Parameter: discrete_input3
  22. uint8_t discrete_input3:1;
  23. // Parameter: discrete_input4
  24. uint8_t discrete_input4:1;
  25. // Parameter: discrete_input5
  26. uint8_t discrete_input5:1;
  27. // Parameter: discrete_input6
  28. uint8_t discrete_input6:1;
  29. // Parameter: discrete_input7
  30. uint8_t discrete_input7:1;
  31. uint8_t discrete_input_port1:8;
  32. } discrete_reg_params_t;
  33. #pragma pack(pop)
  34. #pragma pack(push, 1)
  35. typedef struct
  36. {
  37. // Parameter: Coil 0 : Coil0
  38. uint8_t coil0:1;
  39. // Parameter: Coil 1 : Coil1
  40. uint8_t coil1:1;
  41. // Parameter: Coil 2 : Coil2
  42. uint8_t coil2:1;
  43. // Parameter: Coil 3 : Coil3
  44. uint8_t coil3:1;
  45. // Parameter: Coil 4 : Coil4
  46. uint8_t coil4:1;
  47. // Parameter: Coil 5 : Coil5
  48. uint8_t coil5:1;
  49. // Parameter: Coil 6 : Coil6
  50. uint8_t coil6:1;
  51. // Parameter: Coil 7 : Coil7
  52. uint8_t coil7:1;
  53. // Coils port 1
  54. uint8_t coil_port1:8;
  55. } coil_reg_params_t;
  56. #pragma pack(pop)
  57. #pragma pack(push, 1)
  58. typedef struct
  59. {
  60. // Parameter: Data channel 0 : data_chan0 : NV Address: 0
  61. float data_chan0;
  62. // Parameter: Data channel 1 : data_chan1 : NV Address: 0
  63. float data_chan1;
  64. // Parameter: Data channel 2 : data_chan2 : NV Address: 0
  65. float data_chan2;
  66. // Parameter: Data channel 3 : data_chan3 : NV Address: 0
  67. float data_chan3;
  68. } input_reg_params_t;
  69. #pragma pack(pop)
  70. //See register map for more information.
  71. #pragma pack(push, 1)
  72. typedef struct
  73. {
  74. // Parameter: Data channel 0 : DataChan0
  75. float data_chan0;
  76. // Parameter: Data channel 1 : DataChan1
  77. float data_chan1;
  78. // Parameter: Data channel 2 : DataChan2
  79. float data_chan2;
  80. // Parameter: Data channel 3 : DataChan3
  81. float data_chan3;
  82. // Parameter: Protocol version : protocol_version
  83. uint16_t protocol_version;
  84. // Parameter: Hardware version : hardware_version
  85. uint16_t hardware_version;
  86. // Parameter: Software Version : software_version
  87. uint16_t software_version;
  88. // Parameter: Software Revision : software_revision
  89. uint16_t software_revision;
  90. // Parameter: Device Type : deviceType :
  91. uint16_t deviceType;
  92. // Parameter: Modbus Network Address : modbus_address
  93. uint16_t modbus_address;
  94. // Parameter: Modbus Baudrate : modbus_baud
  95. uint16_t modbus_baud;
  96. // Parameter: Modbus parity : modbus_parity
  97. uint16_t modbus_parity;
  98. // Parameter: Modbus stopbit : modbus_stop_bits
  99. uint16_t modbus_stop_bits;
  100. // Parameter: Brace control : modbus_brace_ctrl
  101. uint16_t modbus_brace_ctrl;
  102. // Parameter: Serial number : serial_number
  103. uint32_t serial_number;
  104. // Parameter: Up time : up_time
  105. uint32_t up_time;
  106. // Parameter: Device state : device_state
  107. uint16_t device_state;
  108. // Parameter: Test Float0 : test_float0
  109. float test_float0;
  110. // Parameter: Test Float1 : test_float1
  111. float test_float1;
  112. // Parameter: Test Float2 : test_float2
  113. float test_float2;
  114. // Parameter: Test Float3 : test_float3
  115. float test_float3;
  116. // Parameter: Test String : string_test
  117. uint8_t string_test[A24_ARR_SIZE];
  118. } holding_reg_params_t;
  119. #pragma pack(pop)
  120. extern holding_reg_params_t holding_reg_params;
  121. extern input_reg_params_t input_reg_params;
  122. extern coil_reg_params_t coil_reg_params;
  123. extern discrete_reg_params_t discrete_reg_params;
  124. #endif // !defined(_DEVICE_PARAMS)