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 
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     uint8_t discrete_input0:1;
16     uint8_t discrete_input1:1;
17     uint8_t discrete_input2:1;
18     uint8_t discrete_input3:1;
19     uint8_t discrete_input4:1;
20     uint8_t discrete_input5:1;
21     uint8_t discrete_input6:1;
22     uint8_t discrete_input7:1;
23     uint8_t discrete_input_port1:8;
24 } discrete_reg_params_t;
25 #pragma pack(pop)
26 
27 #pragma pack(push, 1)
28 typedef struct
29 {
30     uint8_t coils_port0;
31     uint8_t coils_port1;
32 } coil_reg_params_t;
33 #pragma pack(pop)
34 
35 #pragma pack(push, 1)
36 typedef struct
37 {
38     float input_data0; // 0
39     float input_data1; // 2
40     float input_data2; // 4
41     float input_data3; // 6
42     uint16_t data[150]; // 8 + 150 = 158
43     float input_data4; // 158
44     float input_data5;
45     float input_data6;
46     float input_data7;
47 } input_reg_params_t;
48 #pragma pack(pop)
49 
50 #pragma pack(push, 1)
51 typedef struct
52 {
53     float holding_data0;
54     float holding_data1;
55     float holding_data2;
56     float holding_data3;
57     uint16_t test_regs[150];
58     float holding_data4;
59     float holding_data5;
60     float holding_data6;
61     float holding_data7;
62 } holding_reg_params_t;
63 #pragma pack(pop)
64 
65 extern holding_reg_params_t holding_reg_params;
66 extern input_reg_params_t input_reg_params;
67 extern coil_reg_params_t coil_reg_params;
68 extern discrete_reg_params_t discrete_reg_params;
69 
70 #endif // !defined(_DEVICE_PARAMS)
71