internalComm.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * internalComm.h
  3. *
  4. * Created on: 2019年5月7日
  5. * Author: foluswen
  6. */
  7. #ifndef _INTERNAL_COMM_H_
  8. #define _INTERNAL_COMM_H_
  9. //------------------------------------------------------------------------------
  10. #include <stdint.h>
  11. //------------------------------------------------------------------------------
  12. //address
  13. #define ADDR_AUX (0x01)
  14. #define ADDR_FAN (0x02)
  15. #if defined DD360Tcci || defined DD360Audi || defined DD360ComBox || defined DD360UCar
  16. #define ADDR_RELAY (0x09)
  17. #else
  18. #define ADDR_RELAY (0x03)
  19. #endif //defined DD360Tcci || defined DD360Audi || defined DD360ComBox
  20. #define ADDR_AC_PLUG (0x05)
  21. #define ADDR_LED (0x06)
  22. #define ADDR_BROADCAST (0xFF)
  23. //command
  24. #define CMD_QUERY_FW_VER (0x01)
  25. #define CMD_QUERY_HW_VER (0x02)
  26. #define CMD_QUERY_PRESENT_IN_VOL (0x03)
  27. #define CMD_QUERY_PRESENT_OUT_VOL (0x04)
  28. #define CMD_QUERY_FAN_SPEED (0x05)
  29. #define CMD_QUERY_TEMPERATURE (0x06)
  30. #define CMD_QUERY_AUX_POWER_VOL (0x07)
  31. #define CMD_QUERY_RELAY_OUTPUT (0x08)
  32. #define CMD_QUERY_GFD_ADC (0x09)
  33. #define CMD_QUERY_GPIO_IN (0x0a)
  34. #define CMD_QUERY_MODEL_NAME (0x24)
  35. #define CMD_QUERY_AC_OUTPUT_CURRENT (0x27)
  36. #define CMD_QUERY_AC_STATUS (0x28)
  37. #define CMD_QUERY_AC_ALARM_CODE (0x29)
  38. #define CMD_QUERY_AC_OUTPUT_ENERGY (0x2C)
  39. #define CMD_CONFIG_FAN_SPEED (0x81)
  40. #define CMD_CONFIG_MODEL_NAME (0x83)
  41. #define CMD_CONFIG_RELAY_OUTPUT (0x85)
  42. #define CMD_CONFIG_GPIO_OUTPUT (0x86)
  43. #define CMD_CONFIG_RTC_DATA (0x87)
  44. #define CMD_CONFIG_AC_LED_STATUS (0x88)
  45. #define CMD_CONFIG_AC_DUTY (0x89)
  46. #define CMD_CONFIG_LEGACY_REQ (0x8A)
  47. #define CMD_CONFIG_GDF_VALUE (0x8B)
  48. #define CMD_CONFIG_RESET_MCU (0x8C)
  49. #define CMD_CONFIG_CSU_MODE (0x90)
  50. #define CMD_CONFIG_LEN_COLOR (0x93)
  51. #define CMD_UPDATE_START (0xe0)
  52. #define CMD_UPDATE_ABORT (0xe1)
  53. #define CMD_UPDATE_TRANSFER (0xe2)
  54. #define CMD_UPDATE_FINISH (0xe3)
  55. //------------------------------------------------------------------------------
  56. typedef struct Verion {
  57. char Version_FW[9];
  58. char Version_HW[9];
  59. } Ver;
  60. typedef struct PRESENTINPUTVOLTAGE {
  61. uint8_t inputType; // 0x00: Line to Line 0x01: Line to Neutral
  62. double L1N_L12;
  63. double L2N_L23;
  64. double L3N_L31;
  65. } PresentInputVoltage;
  66. typedef struct PRESENTOUTPUTVOLTAGE {
  67. double behindFuse_Voltage_C1;
  68. double behindRelay_Voltage_C1;
  69. double behindFuse_Voltage_C2;
  70. double behindRelay_Voltage_C2;
  71. } PresentOutputVoltage;
  72. typedef struct FANSPEED {
  73. uint16_t speed[8];
  74. } FanSpeed;
  75. typedef struct TEMPERATURE {
  76. uint8_t temperature[8];
  77. } Temperature;
  78. typedef struct AUXPOWER {
  79. uint8_t voltage[8];
  80. } AuxPower;
  81. typedef struct RELAY {
  82. union {
  83. uint8_t relay_status[8];
  84. struct {
  85. uint8_t AC_Contactor : 1; //bit 0
  86. uint8_t CCS_Precharge : 1; //bit 1
  87. uint8_t : 1; //bit 2 reserved
  88. uint8_t : 1; //bit 3 reserved
  89. uint8_t : 1; //bit 4 reserved
  90. uint8_t : 1; //bit 5 reserved
  91. uint8_t : 1; //bit 6 reserved
  92. uint8_t : 1; //bit 7 reserved
  93. uint8_t Gun1_N : 1; //bit 0
  94. uint8_t Gun1_P : 1; //bit 1
  95. uint8_t Gun1_Parallel_N : 1; //bit 2
  96. uint8_t Gun1_Parallel_P : 1; //bit 3
  97. uint8_t : 1; //bit 4 reserved
  98. uint8_t : 1; //bit 5 reserved
  99. uint8_t : 1; //bit 6 reserved
  100. uint8_t : 1; //bit 7 reserved
  101. uint8_t Gun2_N : 1; //bit 0
  102. uint8_t Gun2_P : 1; //bit 1
  103. uint8_t : 1; //bit 2 reserved
  104. uint8_t : 1; //bit 3 reserved
  105. uint8_t : 1; //bit 4 reserved
  106. uint8_t : 1; //bit 5 reserved
  107. uint8_t : 1; //bit 6 reserved
  108. uint8_t : 1; //bit 7 reserved
  109. } bits;
  110. } relay_event;
  111. } Relay;
  112. typedef struct GFD {
  113. unsigned short Resister_conn1;
  114. unsigned short voltage_conn1;
  115. uint8_t result_conn1;
  116. uint8_t rb_step_1;
  117. unsigned short Resister_conn2;
  118. unsigned short voltage_conn2;
  119. uint8_t result_conn2;
  120. uint8_t rb_step_2;
  121. } Gfd;
  122. typedef struct Gfd_CONFIG {
  123. uint8_t index;
  124. uint8_t state;
  125. } Gfd_config;
  126. typedef struct GPIO_IN {
  127. uint8_t AC_Connector; // bit 0
  128. uint8_t AC_MainBreaker; // bit 1
  129. uint8_t SPD; // bit 2
  130. uint8_t Door_Open; // bit 3
  131. uint8_t GFD[2]; // bit 4,5
  132. uint8_t AC_Drop; // bit 6
  133. uint8_t Emergency_IO; // bit 0
  134. uint8_t Button_Emergency_Press; // bit 0
  135. uint8_t Button_On_Press; // bit 1
  136. uint8_t Button_Off_Press; // bit 2
  137. uint8_t Key_1_Press; // bit 3
  138. uint8_t Key_2_Press; // bit 4
  139. uint8_t Key_3_Press; // bit 5
  140. uint8_t Key_4_Press; // bit 6
  141. } Gpio_in;
  142. typedef struct GPIO_OUT {
  143. uint8_t AC_Connector;
  144. uint8_t Button_LED[2];
  145. uint8_t System_LED[4];
  146. } Gpio_out;
  147. typedef struct RTC {
  148. uint8_t RtcData[14];
  149. } Rtc;
  150. typedef struct LED_Color {
  151. uint8_t Connect_1_Red;
  152. uint8_t Connect_1_Green;
  153. uint8_t Connect_1_Blue;
  154. uint8_t Connect_2_Red;
  155. uint8_t Connect_2_Green;
  156. uint8_t Connect_2_Blue;
  157. } Led_Color;
  158. typedef struct AC_Status {
  159. uint8_t CpStatus;
  160. unsigned short CurLimit;
  161. short PilotVol_P;
  162. short PilotVol_N;
  163. uint8_t LockStatus;
  164. uint8_t RelayStatus;
  165. uint8_t ShutterStatus;
  166. uint8_t MeterStatus;
  167. uint8_t PpStatus;
  168. uint8_t MaxCurrent;
  169. uint8_t RotateSwitchStatus;
  170. } Ac_Status;
  171. typedef struct AC_LED_Status {
  172. uint8_t ActionMode;
  173. unsigned long AcAlarmCode;
  174. } Ac_Led_Status;
  175. typedef struct AC_Alarm_Code {
  176. uint32_t AcAlarmCode;
  177. } Ac_Alarm_code;
  178. typedef struct AC_Charging_Energy {
  179. uint32_t Energy;
  180. } Ac_Charging_energy;
  181. typedef struct AC_Charging_Current {
  182. unsigned short OuputCurrentL1;
  183. unsigned short OuputCurrentL2;
  184. unsigned short OuputCurrentL3;
  185. } Ac_Charging_current;
  186. int Query_FW_Ver(uint8_t fd, uint8_t targetAddr, Ver *Ret_Buf);
  187. int Query_HW_Ver(uint8_t fd, uint8_t targetAddr, Ver *Ret_Buf);
  188. int Query_Present_InputVoltage(uint8_t fd, uint8_t targetAddr, PresentInputVoltage *Ret_Buf);
  189. int Query_Present_OutputVoltage(uint8_t fd, uint8_t targetAddr, PresentOutputVoltage *Ret_Buf);
  190. int Query_Fan_Speed(uint8_t fd, uint8_t targetAddr, FanSpeed *Ret_Buf);
  191. int Query_Temperature(uint8_t fd, uint8_t targetAddr, Temperature *Ret_Buf);
  192. int Query_Aux_PowerVoltage(uint8_t fd, uint8_t targetAddr, AuxPower *Ret_Buf);
  193. int Query_Relay_Output(uint8_t fd, uint8_t targetAddr, Relay *Ret_Buf);
  194. int Query_Gfd_Adc(uint8_t fd, uint8_t targetAddr, Gfd *Ret_Buf);
  195. int Query_Gpio_Input(uint8_t fd, uint8_t targetAddr, Gpio_in *Ret_Buf);
  196. int Query_Model_Name(uint8_t fd, uint8_t targetAddr, uint8_t *modelname);
  197. int Query_AC_Status(uint8_t fd, uint8_t targetAddr, Ac_Status *Ret_Buf);
  198. int Query_AC_Alarm_Code(uint8_t fd, uint8_t targetAddr, Ac_Alarm_code *Ret_Buf);
  199. int Query_Charging_Energy(uint8_t fd, uint8_t targetAddr, Ac_Charging_energy *Ret_Buf);
  200. int Query_Charging_Current(uint8_t fd, uint8_t targetAddr, Ac_Charging_current *Ret_Buf);
  201. int Config_Fan_Speed(uint8_t fd, uint8_t targetAddr, FanSpeed *Set_Buf);
  202. int Config_Relay_Output(uint8_t fd, uint8_t targetAddr, Relay *Set_Buf);
  203. int Config_Gpio_Output(uint8_t fd, uint8_t targetAddr, Gpio_out *Set_Buf);
  204. int Config_Gfd_Value(uint8_t fd, uint8_t targetAddr, Gfd_config *Set_Buf);
  205. int Config_Model_Name(uint8_t fd, uint8_t targetAddr, uint8_t *modelname);
  206. int Config_Rtc_Data(uint8_t fd, uint8_t targetAddr, Rtc *Set_Buf);
  207. int Config_LED_Status(uint8_t fd, uint8_t targetAddr, Ac_Led_Status *Ret_Buf);
  208. int Config_Legacy_Req(uint8_t fd, uint8_t targetAddr, uint8_t _switch);
  209. int Config_Ac_Duty(uint8_t fd, uint8_t targetAddr, uint8_t _value);
  210. int Config_CSU_Mode(uint8_t fd, uint8_t targetAddr);
  211. int Config_Reset_MCU(uint8_t fd, uint8_t targetAddr);
  212. int Config_Led_Color(uint8_t fd, uint8_t targetAddr, Led_Color *Ret_Buf);
  213. int Update_Start(uint8_t fd, uint8_t targetAddr, uint32_t crc32);
  214. int Update_Abord(uint8_t fd, uint8_t targetAddr);
  215. int Update_Transfer(uint8_t fd, uint8_t targetAddr, uint32_t startAddr, uint8_t *data, uint16_t length);
  216. int Update_Finish(uint8_t fd, uint8_t targetAddr);
  217. #endif /* _INTERNAL_COMM_H_ */