internalComm.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. /*
  2. * internalComm.h
  3. *
  4. * Created on: 2019年5月7日
  5. * Author: foluswen
  6. */
  7. #ifndef INTERNALCOMM_H_
  8. #define INTERNALCOMM_H_
  9. extern struct Address
  10. {
  11. unsigned char Aux;
  12. unsigned char Fan;
  13. unsigned char Relay;
  14. unsigned char AcPlug;
  15. unsigned char Led;
  16. unsigned char DO360_RC1;
  17. unsigned char DO360_RC2;
  18. unsigned char DD360_Relay;
  19. unsigned char Broadcast;
  20. }Addr;
  21. extern struct Command
  22. {
  23. unsigned char query_FW_Ver; //0x01
  24. unsigned char query_HW_Ver; //0x02
  25. unsigned char query_Present_InputVoltage; //0x03
  26. unsigned char query_Present_OutputVoltage; //0x04
  27. unsigned char query_Fan_Speed; //0x05
  28. unsigned char query_Temperature; //0x06
  29. unsigned char query_Aux_PowerVoltage; //0x07
  30. unsigned char query_Relay_Output; //0x08
  31. unsigned char query_Gfd_Adc; //0x09
  32. unsigned char query_Gpio_In; //0x0a
  33. unsigned char query_Model_Name; //0x24
  34. unsigned char query_ac_output_current; //0x27
  35. unsigned char query_ac_status; //0x28
  36. unsigned char query_ac_alarm_code; //0x29
  37. unsigned char query_ac_output_energy; //0x2C
  38. unsigned char config_Fan_Speed; //0x81
  39. unsigned char config_Model_Name; //0x83
  40. unsigned char config_Relay_Output; //0x85
  41. unsigned char config_Gpio_Output; //0x86
  42. unsigned char config_Rtc_Data; //0x87
  43. unsigned char config_ac_led_status; //0x88
  44. unsigned char config_ac_duty; //0x89
  45. unsigned char config_Legacy_Req; //0x8A
  46. unsigned char config_Gfd_Value; //0x8B
  47. unsigned char config_reset_mcu; //0x8C
  48. unsigned char config_csu_mode; //0x90
  49. unsigned char config_led_color; //0x93
  50. unsigned char update_Start; //0xe0
  51. unsigned char update_Abort; //0xe1
  52. unsigned char update_Transfer; //0xe2
  53. unsigned char update_Finish; //0xe3
  54. }Cmd;
  55. typedef struct Verion
  56. {
  57. char Version_FW[9];
  58. char Version_HW[9];
  59. }Ver;
  60. typedef struct PRESENTINPUTVOLTAGE
  61. {
  62. unsigned char inputType; // 0x00: Line to Line 0x01: Line to Neutral
  63. double L1N_L12;
  64. double L2N_L23;
  65. double L3N_L31;
  66. }PresentInputVoltage;
  67. typedef struct PRESENTOUTPUTVOLTAGE
  68. {
  69. double behindFuse_Voltage_C1;
  70. double behindRelay_Voltage_C1;
  71. double behindFuse_Voltage_C2;
  72. double behindRelay_Voltage_C2;
  73. }PresentOutputVoltage;
  74. typedef struct FANSPEED
  75. {
  76. unsigned short int speed[8];
  77. }FanSpeed;
  78. typedef struct TEMPERATURE
  79. {
  80. unsigned char temperature[8];
  81. }Temperature;
  82. typedef struct AUXPOWER
  83. {
  84. unsigned char voltage[8];
  85. }AuxPower;
  86. typedef union
  87. {
  88. unsigned char relay_status;
  89. struct
  90. {
  91. unsigned char Gun_N:1; // 0: gun_n off, 1: gun_n on
  92. unsigned char Gun_P:1; // 0: gun_p off, 1: gun_p on
  93. unsigned char Gun_Parallel_N_P:1; // 0: gun_parallel off, 1: gun_parallel on
  94. unsigned char Gun_Parallel_P:1; // 0: gun_parallel off, 1: gun_parallel on
  95. unsigned char res:4;
  96. }bits;
  97. }RBRelayControl;
  98. typedef struct RELAY
  99. {
  100. union
  101. {
  102. unsigned char relay_status[8];
  103. struct
  104. {
  105. unsigned char AC_Contactor :1; //bit 0
  106. unsigned char CCS_Precharge :1; //bit 1
  107. unsigned char :1; //bit 2 reserved
  108. unsigned char :1; //bit 3 reserved
  109. unsigned char :1; //bit 4 reserved
  110. unsigned char :1; //bit 5 reserved
  111. unsigned char :1; //bit 6 reserved
  112. unsigned char :1; //bit 7 reserved
  113. unsigned char Gun1_N :1; //bit 0
  114. unsigned char Gun1_P :1; //bit 1
  115. unsigned char Gun1_Parallel_N :1; //bit 2
  116. unsigned char Gun1_Parallel_P :1; //bit 3
  117. unsigned char :1; //bit 4 reserved
  118. unsigned char :1; //bit 5 reserved
  119. unsigned char :1; //bit 6 reserved
  120. unsigned char :1; //bit 7 reserved
  121. unsigned char Gun2_N :1; //bit 0
  122. unsigned char Gun2_P :1; //bit 1
  123. unsigned char Gun2_Parallel_N :1; //bit 2
  124. unsigned char Gun2_Parallel_P :1; //bit 3
  125. unsigned char :1; //bit 4 reserved
  126. unsigned char :1; //bit 5 reserved
  127. unsigned char :1; //bit 6 reserved
  128. unsigned char :1; //bit 7 reserved
  129. }bits;
  130. }relay_event;
  131. }Relay;
  132. typedef union
  133. {
  134. unsigned char gfd_vlaue[6];
  135. struct
  136. {
  137. unsigned short Resister;
  138. unsigned short Voltage;
  139. unsigned char GFD_Result;
  140. unsigned char rb_step;
  141. }bits;
  142. }Connector_GFD;
  143. typedef struct GFD
  144. {
  145. unsigned short Resister_conn1;
  146. unsigned short voltage_conn1;
  147. unsigned char result_conn1;
  148. unsigned char rb_step_1;
  149. unsigned short Resister_conn2;
  150. unsigned short voltage_conn2;
  151. unsigned char result_conn2;
  152. unsigned char rb_step_2;
  153. }Gfd;
  154. typedef struct Gfd_CONFIG
  155. {
  156. unsigned char index;
  157. unsigned char state;
  158. }Gfd_config;
  159. typedef struct GPIO_IN
  160. {
  161. unsigned char AC_Connector; // bit 0
  162. unsigned char AC_MainBreaker; // bit 1
  163. unsigned char SPD; // bit 2
  164. unsigned char Door_Open; // bit 3
  165. unsigned char GFD[2]; // bit 4,5
  166. unsigned char AC_Drop; // bit 6
  167. unsigned char Emergency_IO; // bit 0
  168. unsigned char Button_Emergency_Press; // bit 0
  169. unsigned char Button_On_Press; // bit 1
  170. unsigned char Button_Off_Press; // bit 2
  171. unsigned char Key_1_Press; // bit 3
  172. unsigned char Key_2_Press; // bit 4
  173. unsigned char Key_3_Press; // bit 5
  174. unsigned char Key_4_Press; // bit 6
  175. }Gpio_in;
  176. typedef struct GPIO_OUT
  177. {
  178. unsigned char AC_Connector;
  179. unsigned char Button_LED[2];
  180. unsigned char System_LED[4];
  181. }Gpio_out;
  182. typedef struct RTC
  183. {
  184. unsigned char RtcData[14];
  185. }Rtc;
  186. typedef struct LED_Color
  187. {
  188. unsigned char Connect_1_Red;
  189. unsigned char Connect_1_Green;
  190. unsigned char Connect_1_Blue;
  191. unsigned char Connect_2_Red;
  192. unsigned char Connect_2_Green;
  193. unsigned char Connect_2_Blue;
  194. }Led_Color;
  195. typedef struct AC_Status
  196. {
  197. unsigned char CpStatus;
  198. unsigned short CurLimit;
  199. short PilotVol_P;
  200. short PilotVol_N;
  201. unsigned char LockStatus;
  202. unsigned char RelayStatus;
  203. unsigned char ShutterStatus;
  204. unsigned char MeterStatus;
  205. unsigned char PpStatus;
  206. unsigned char MaxCurrent;
  207. unsigned char RotateSwitchStatus;
  208. }
  209. Ac_Status;
  210. typedef struct AC_LED_Status
  211. {
  212. unsigned char ActionMode;
  213. unsigned long AcAlarmCode;
  214. }
  215. Ac_Led_Status;
  216. typedef struct AC_Alarm_Code
  217. {
  218. unsigned int AcAlarmCode;
  219. }
  220. Ac_Alarm_code;
  221. typedef struct AC_Charging_Energy
  222. {
  223. unsigned int Energy;
  224. }
  225. Ac_Charging_energy;
  226. typedef struct AC_Charging_Current
  227. {
  228. unsigned short OuputCurrentL1;
  229. unsigned short OuputCurrentL2;
  230. unsigned short OuputCurrentL3;
  231. }
  232. Ac_Charging_current;
  233. extern unsigned char Query_FW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
  234. extern unsigned char Query_HW_Ver(unsigned char fd, unsigned char targetAddr, Ver *Ret_Buf);
  235. extern unsigned char Query_Present_InputVoltage(unsigned char fd, unsigned char targetAddr, PresentInputVoltage *Ret_Buf);
  236. extern unsigned char Query_Present_OutputVoltage(unsigned char fd, unsigned char targetAddr, PresentOutputVoltage *Ret_Buf);
  237. extern unsigned char Query_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSpeed *Ret_Buf);
  238. extern unsigned char Query_Temperature(unsigned char fd, unsigned char targetAddr, Temperature *Ret_Buf);
  239. extern unsigned char Query_Aux_PowerVoltage(unsigned char fd, unsigned char targetAddr, AuxPower *Ret_Buf);
  240. extern unsigned char Query_Relay_Output(unsigned char fd, unsigned char targetAddr, Relay *Ret_Buf);
  241. extern unsigned char Query_Gfd_Adc(unsigned char fd, unsigned char targetAddr, Gfd *Ret_Buf);
  242. extern unsigned char Query_Gpio_Input(unsigned char fd, unsigned char targetAddr, Gpio_in *Ret_Buf);
  243. extern unsigned char Query_Model_Name(unsigned char fd, unsigned char targetAddr, unsigned char *modelname);
  244. extern unsigned char Config_Fan_Speed(unsigned char fd, unsigned char targetAddr, FanSpeed *Set_Buf);
  245. extern unsigned char Config_Relay_Output(unsigned char fd, unsigned char targetAddr, Relay *Set_Buf);
  246. extern unsigned char Config_Gpio_Output(unsigned char fd, unsigned char targetAddr, Gpio_out *Set_Buf);
  247. extern unsigned char Config_Gfd_Value(unsigned char fd, unsigned char targetAddr, Gfd_config *Set_Buf);
  248. extern unsigned char Config_Model_Name(unsigned char fd, unsigned char targetAddr, unsigned char *modelname);
  249. extern unsigned char Config_Rtc_Data(unsigned char fd, unsigned char targetAddr, Rtc *Set_Buf);
  250. extern unsigned char Update_Start(unsigned char fd, unsigned char targetAddr, unsigned int crc32);
  251. extern unsigned char Update_Abord(unsigned char fd, unsigned char targetAddr);
  252. extern unsigned char Update_Transfer(unsigned char fd, unsigned char targetAddr, unsigned int startAddr, unsigned char *data, unsigned short int length);
  253. extern unsigned char Update_Finish(unsigned char fd, unsigned char targetAddr);
  254. extern unsigned char Query_AC_Status(unsigned char fd, unsigned char targetAddr, Ac_Status *Ret_Buf);
  255. extern unsigned char Query_AC_Alarm_Code(unsigned char fd, unsigned char targetAddr, Ac_Alarm_code *Ret_Buf);
  256. extern unsigned char Query_Charging_Energy(unsigned char fd, unsigned char targetAddr, Ac_Charging_energy *Ret_Buf);
  257. extern unsigned char Query_Charging_Current(unsigned char fd, unsigned char targetAddr, Ac_Charging_current *Ret_Buf);
  258. extern unsigned char Config_LED_Status(unsigned char fd, unsigned char targetAddr, Ac_Led_Status *Ret_Buf);
  259. extern unsigned char Config_Legacy_Req(unsigned char fd, unsigned char targetAddr, unsigned char _switch);
  260. extern unsigned char Config_Ac_Duty(unsigned char fd, unsigned char targetAddr, unsigned char _value);
  261. extern unsigned char Config_CSU_Mode(unsigned char fd, unsigned char targetAddr);
  262. extern unsigned char Config_Reset_MCU(unsigned char fd, unsigned char targetAddr);
  263. extern unsigned char Config_Led_Color(unsigned char fd, unsigned char targetAddr, Led_Color *Ret_Buf);
  264. #endif /* INTERNALCOMM_H_ */