modbus_params.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // This file defines structure of modbus parameters which reflect correspond modbus address space
  10. // for each modbus register type (coils, discreet inputs, holding registers, input registers)
  11. #pragma pack(push, 1)
  12. typedef struct
  13. {
  14. uint8_t discrete_input0:1;
  15. uint8_t discrete_input1:1;
  16. uint8_t discrete_input2:1;
  17. uint8_t discrete_input3:1;
  18. uint8_t discrete_input4:1;
  19. uint8_t discrete_input5:1;
  20. uint8_t discrete_input6:1;
  21. uint8_t discrete_input7:1;
  22. uint8_t discrete_input_port1:8;
  23. } discrete_reg_params_t;
  24. #pragma pack(pop)
  25. #pragma pack(push, 1)
  26. typedef struct
  27. {
  28. uint8_t coils_port0;
  29. uint8_t coils_port1;
  30. } coil_reg_params_t;
  31. #pragma pack(pop)
  32. #pragma pack(push, 1)
  33. typedef struct
  34. {
  35. float input_data0;
  36. float input_data1;
  37. float input_data2;
  38. float input_data3;
  39. } input_reg_params_t;
  40. #pragma pack(pop)
  41. #pragma pack(push, 1)
  42. typedef struct
  43. {
  44. float holding_data0;
  45. float holding_data1;
  46. float holding_data2;
  47. float holding_data3;
  48. uint16_t test_regs[150];
  49. } holding_reg_params_t;
  50. #pragma pack(pop)
  51. extern holding_reg_params_t holding_reg_params;
  52. extern input_reg_params_t input_reg_params;
  53. extern coil_reg_params_t coil_reg_params;
  54. extern discrete_reg_params_t discrete_reg_params;
  55. #endif // !defined(_DEVICE_PARAMS)