Config.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. /*
  2. * Config.h
  3. *
  4. * Created on: 2019年4月23日
  5. * Author: foluswen
  6. */
  7. #ifndef CONFIG_H_
  8. #define CONFIG_H_
  9. #include <stdbool.h>
  10. typedef unsigned char byte;
  11. #define TOTAL_QUANTITY_GUN 4 //Max Count
  12. #define MODE_BOOT 0
  13. #define MODE_IDLE 1
  14. #define MODE_AUTHORIZING 2
  15. #define MODE_REASSIGN_CHECK 3
  16. #define MODE_REASSIGN 4
  17. #define MODE_PRECHARGE 5
  18. #define MODE_PREPARE_FOR_EV 6
  19. #define MODE_PREPARE_FOR_EVSE 7
  20. #define MODE_CHARGING 8
  21. #define MODE_TERMINATING 9
  22. #define MODE_COMPLETE 10
  23. #define MODE_ALARM 11
  24. #define MODE_FAULT 12
  25. #define MODE_RESERVATION 13
  26. #define MODE_BOOKING 14
  27. #define MODE_MAINTAIN 15
  28. #define MODE_DEBUG 16
  29. #define MODE_CCS_PRECHARGE_STEP0 17 // ready for ccs precharge processing, For D+ relay to precharge relay
  30. #define MODE_CCS_PRECHARGE_STEP1 18 // waitting for ev board inform to enter to charging, For precharge relay to D+ relay
  31. #define MODE_UPDATE 19
  32. #define GFD_WAIT 0
  33. #define GFD_PASS 1
  34. #define GFD_FAIL 2
  35. #define GFD_WARNING 3
  36. #define PRECHARGE_WAIT 0
  37. #define PRECHARGE_READY 1
  38. #define PRECHARGE_PRERELAY_PASS 2
  39. #define PRECHARGE_CHARELAY_PASS 3
  40. #define BOOTTING 0
  41. #define BOOT_COMPLETE 1
  42. #define uSEC_VAL 1000000
  43. #define mSEC_VAL 1000
  44. #define MAX_GROUP_QUANTITY 4
  45. #define MAX_PSU_MODULE_QUANTITY 62
  46. #define MAX_MODULE_PER_GROUP 12
  47. #define SM_ChargerInfoKey 3000
  48. // ********** Audi ********** //
  49. // Model Name: DOYC182000D2AD
  50. // ********** e4you ********** //
  51. // Model Name: DKYE182000D1E4
  52. // ********** xpeng ********** //
  53. // Model Name: DOYE362000D2XP
  54. enum _SYSTEM_STATUS
  55. {
  56. S_BOOTING = 0,
  57. S_IDLE,
  58. S_AUTHORIZING,
  59. S_REASSIGN_CHECK,
  60. S_REASSIGN,
  61. S_PREPARNING,
  62. S_PREPARING_FOR_EV,
  63. S_PREPARING_FOR_EVSE,
  64. S_CHARGING,
  65. S_TERMINATING,
  66. S_COMPLETE,
  67. S_ALARM,
  68. S_FAULT,
  69. S_RESERVATION,
  70. S_BOOKING,
  71. S_MAINTAIN,
  72. S_DEBUG,
  73. S_CCS_PRECHARGE_ST0,
  74. S_CCS_PRECHARGE_ST1,
  75. S_UPDATE,
  76. S_NONE,
  77. };
  78. enum _AC_SYSTEM_STATUS
  79. {
  80. AC_SYS_NONE = 0,
  81. AC_SYS_A,
  82. AC_SYS_B,
  83. AC_SYS_C,
  84. AC_SYS_D,
  85. AC_SYS_E
  86. };
  87. #define STR_GUN_TYPE_CHADEMO "CHAdeMO"
  88. #define STR_GUN_TYPE_CCS "CCS"
  89. #define STR_GUN_TYPE_GBT "GBT"
  90. #define STR_GUN_TYPE_AC "AC"
  91. #define STR_GUN_TYPE_UNKNOWN "Unknown Type"
  92. enum _GUN_TYPE
  93. {
  94. _Type_Chademo = 0,
  95. _Type_CCS_2,
  96. _Type_GB,
  97. _Type_AC,
  98. _Type_Unknown = 0xFF
  99. };
  100. enum _LCM_INDEX
  101. {
  102. _LCM_INIT = 0x00,
  103. _LCM_IDLE = 0x01,
  104. _LCM_AUTHORIZING = 0x02,
  105. _LCM_AUTHORIZ_COMP = 0x03,
  106. _LCM_AUTHORIZ_FAIL = 0x04,
  107. _LCM_WAIT_FOR_PLUG = 0x05,
  108. _LCM_PRE_CHARGE = 0x06,
  109. _LCM_CHARGING = 0x07,
  110. _LCM_COMPLETE = 0x08,
  111. _LCM_FIX = 0x09,
  112. _LCM_NONE = 0xFF,
  113. };
  114. enum _DispenserAuthorizeStatus
  115. {
  116. _AuthorizeStatus_Idle = 0x00,
  117. _AuthorizeStatus_Wait = 0x01,
  118. _AuthorizeStatus_Busy = 0x02,
  119. _AuthorizeStatus_Done = 0x03,
  120. _AuthorizeStatus_End = 0x04,
  121. };
  122. enum _ConnectorAuthorizeResult
  123. {
  124. _AuthResult_None = 0x00,
  125. _AuthResult_Valid = 0x01,
  126. _AuthResult_Invalid = 0x02,
  127. };
  128. enum _AuthorizedType
  129. {
  130. _AuthType_None = 0x00,
  131. _AuthType_RFID = 0x01,
  132. _AuthType_RemoteStart = 0x02,
  133. };
  134. enum _SELF_TEST_SEQ
  135. {
  136. _STEST_VERSION = 0x00,
  137. _STEST_AC_CONTACTOR = 0x01,
  138. _STEST_PSU_DETECT = 0x02,
  139. _STEST_PSU_CAP = 0x03,
  140. _STEST_FAIL = 0x04,
  141. _STEST_COMPLETE = 0xEE,
  142. };
  143. enum _MODULE_PSU_WORK_STEP
  144. {
  145. INITIAL_START = 0,
  146. GET_PSU_COUNT = 1,
  147. GET_SYS_CAP = 2,
  148. BOOTING_COMPLETE = 3,
  149. _WORK_CHARGING = 10,
  150. _TEST_MODE = 20,
  151. _NO_WORKING = 254,
  152. _INIT_PSU_STATUS = 255
  153. };
  154. enum _OFFLINE_POLICY
  155. {
  156. _OFFLINE_POLICY_LOCAL_LIST = 0x00,
  157. _OFFLINE_POLICY_PHIHONG_RFID_TAG = 0x01,
  158. _OFFLINE_POLICY_FREE_CHARGING = 0x02,
  159. _OFFLINE_POLICY_NO_CHARGING = 0x03,
  160. };
  161. enum _REASSIGNED_RESOURCE_STEP
  162. {
  163. _REASSIGNED_NONE = 0, //
  164. _REASSIGNED_PREPARE_M_TO_A = 1, // 系統收到需要降載需求 (輸出總電流降低),PSU Task 收到將狀態切換至下個狀態
  165. _REASSIGNED_GET_NEW_CAP = 2, // 充電中的重新取得屬於自己火線上的總能量並透過小板通知車端 - 超過10秒直接跳下一步
  166. _REASSIGNED_ADJUST_M_TO_A = 3, // 模塊重新分配完成
  167. _REASSIGNED_RELAY_M_TO_A = 4, // 切斷橋接的 Relay
  168. _REASSIGNED_PREPARE_A_TO_M = 11,
  169. _REASSIGNED_ADJUST_A_TO_M = 12, // 模塊升壓
  170. _REASSIGNED_RELAY_A_TO_M = 13, // 搭接橋接的 Relay
  171. _REASSIGNED_WAITING = 14,
  172. _REASSIGNED_COMP = 15
  173. };
  174. enum _MAIN_CHARGING_MODE
  175. {
  176. _MAIN_CHARGING_MODE_MAX = 0,
  177. _MAIN_CHARGING_MODE_AVER = 1,
  178. };
  179. enum _EXTRA_ERR_PROCESS
  180. {
  181. _EXTRA_ERR_PROCESS_NONE = 0,
  182. _EXTRA_ERR_PROCESS_INUVP = 1,
  183. _EXTRA_ERR_PROCESS_INOVP = 2,
  184. _EXTRA_ERR_PROCESS_PRIMARY = 3,
  185. };
  186. enum _CHARGER_TYPE
  187. {
  188. _CHARGER_TYPE_IEC = 0,
  189. _CHARGER_TYPE_UL = 1,
  190. };
  191. enum _SYS_WIFI_MODE
  192. {
  193. _SYS_WIFI_MODE_DISABLE = 0,
  194. _SYS_WIFI_MODE_STATION = 1,
  195. _SYS_WIFI_MODE_AP = 2
  196. };
  197. enum _LED_INTENSITY_LV
  198. {
  199. _LED_INTENSITY_DARKEST = 0,
  200. _LED_INTENSITY_MEDIUM = 1,
  201. _LED_INTENSITY_BRIGHTEST = 2
  202. };
  203. enum _CCS_COMM_PROTOCOL
  204. {
  205. _CCS_COMM_V2GMessage_DIN70121 = 0x01,
  206. _CCS_COMM_V2GMessage_ISO15118_2014 = 0x02,
  207. _CCS_COMM_V2GMessage_ISO15118_2018 = 0x03
  208. };
  209. enum _ETHERNET_USAGE
  210. {
  211. _ETHERNET_USAGE_NONE = 0,
  212. _ETHERNET_USAGE_LAN,
  213. _ETHERNET_USAGE_WIFI,
  214. _ETHERNET_USAGE_3G_4g
  215. };
  216. enum _CONN_STATUS
  217. {
  218. _Connnection_Disable = 0,
  219. _Connnection_Connected = 1,
  220. _Connnection_Disconnected = 2,
  221. };
  222. enum _LED_INDICATION_STATUS
  223. {
  224. _LED_INDICATION_OFF = 0, // all led off
  225. _LED_INDICATION_RUN = 1, // green led on, red led off
  226. _LED_INDICATION_FAULT = 2, // green led off, red led on
  227. _LED_INDICATION_ON = 3, // all led on
  228. _LED_INDICATION_GREEN_TOGGLE = 4, // green led toggle
  229. _LED_INDICATION_RED_TOGGLE = 5, // red led toggle
  230. };
  231. enum _STANDARD_INDICATION_STATUS
  232. {
  233. _STANDARD_LED_None = 0,
  234. _STANDARD_LED_Disconnection = 1,
  235. _STANDARD_LED_Running = 2,
  236. _STANDARD_LED_Alarm = 3,
  237. };
  238. enum _E4YOU_INDICATION_STATUS
  239. {
  240. _E4YOU_LED_None = 0,
  241. _E4YOU_LED_Disconnection = 1,
  242. _E4YOU_LED_Idle = 2,
  243. _E4YOU_LED_Charging = 3,
  244. _E4YOU_LED_Alarm = 4,
  245. };
  246. enum _QR_MODE
  247. {
  248. _QR_MODE_Default = 0,
  249. _QR_MODE_Customized = 1,
  250. _QR_MODE_ChargeBoxId = 2, // for audi
  251. };
  252. typedef union
  253. {
  254. unsigned int CtrlValue;
  255. struct
  256. {
  257. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  258. unsigned int PrimaryDisable:1; // 0: primary enable, 1: primary disable
  259. unsigned int RelayBoardDisable:1; // 0: relay board enable, 1: relay board disable
  260. unsigned int FanBoardDisable:1; // 0: fan board enable, 1: fan board disable
  261. unsigned int LedBoardDisable:1; // 0: led board enable, 1: led board disable
  262. unsigned int SecondRelayBoardEnable:1; // 0: second relay disable, 1: second relay enable
  263. unsigned int StandardLedIndication:1; // 0: no led indication, 1: enable standard led indication
  264. unsigned int E4YOULedIndication:1; // 0: no led indication, 1: enable e4you led indication
  265. unsigned int res:24;
  266. }bits;
  267. }SystemControl;
  268. typedef union
  269. {
  270. unsigned int AuthFlag;
  271. struct
  272. {
  273. unsigned int AutoStartEnable:1; // 0: disable, 1: enable auto charging after plug in
  274. unsigned int APPEnable:1; // 0: disable, 1: app auth enable
  275. unsigned int QRCodeEnable:1; // 0: disable, 1: qr code auth enable
  276. unsigned int RFIDEnable:1; // 0: disable, 1: rfid auth enable
  277. unsigned int res:24;
  278. }bits;
  279. }AuthModeInfo;
  280. typedef struct
  281. {
  282. AuthModeInfo AuthMode;
  283. unsigned char QRCodeMode; // 0: default, 1: customized, 2: audi type
  284. unsigned char res[3];
  285. }SystemAuthInfoData;
  286. typedef union
  287. {
  288. unsigned int CtrlValue;
  289. struct
  290. {
  291. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  292. unsigned int DisableDoorSensor:1; // 0: door sensor enable, 1: door sensor disable
  293. unsigned int DisableEmergencyButton:1; // 0: emergency button enable, 1: emergency button disable
  294. unsigned int DoorSensorReverse:1; // 0: the same as ds's, 1: status is different from ds's
  295. unsigned int AcContactorReverse:1; // 0: the same as ds's, 1: status is different from ds's
  296. unsigned int res:27;
  297. }bits;
  298. }PrimaryControl;
  299. typedef union
  300. {
  301. unsigned int CtrlValue;
  302. struct
  303. {
  304. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  305. unsigned int AcContactor:1; // 0: ac contactor off, 1: ac contactor on
  306. unsigned int AcContactorOffByPsu:1; // 0: no effect, 1: ac contactor off
  307. unsigned int AcContactorOffByEmergency:1; // 0: no effect, 1: ac contactor off
  308. unsigned int StandbyCountdown:1; // 0: charger is using, 1: start countdown
  309. unsigned int res:27;
  310. }bits;
  311. }RelayControl;
  312. typedef union
  313. {
  314. unsigned int CtrlValue;
  315. struct
  316. {
  317. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  318. unsigned int res:31;
  319. }bits;
  320. }FanControl;
  321. typedef union
  322. {
  323. unsigned int CtrlValue;
  324. struct
  325. {
  326. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  327. unsigned int res:31;
  328. }bits;
  329. }LedFanControl;
  330. typedef union
  331. {
  332. unsigned int CtrlValue;
  333. struct
  334. {
  335. unsigned int SelfTestOK:1; // 0: self test not completed, 1: self test ok
  336. unsigned int FailureResume:1; // 0: no error, 1: psu failure, need resume
  337. unsigned int res:30;
  338. }bits;
  339. }PsuControl;
  340. typedef struct
  341. {
  342. SystemControl SysCtrl;
  343. PrimaryControl PrimaryCtrl;
  344. RelayControl RelayCtrl;
  345. FanControl FanCtrl;
  346. LedFanControl LedCtrl;
  347. PsuControl PsuCtrl;
  348. }SysControl;
  349. // ************************************************************************************************* //
  350. typedef struct
  351. {
  352. bool CheckIn;
  353. unsigned char Address;
  354. unsigned char GroupNo;
  355. unsigned char Index;
  356. }PsuAddressInfoData;
  357. typedef struct
  358. {
  359. unsigned char GroupPsuQuantity;
  360. unsigned char PsuSN[MAX_MODULE_PER_GROUP];
  361. }GroupInfoData;
  362. typedef struct
  363. {
  364. bool PsuLocationInit;
  365. bool ReInitPsuLocation;
  366. unsigned char TotalPsuQuantity;
  367. GroupInfoData GroupLocationInfo[MAX_GROUP_QUANTITY];
  368. PsuAddressInfoData PsuAddressInfo[MAX_PSU_MODULE_QUANTITY];
  369. }PsuPositionInfoData;
  370. // ************************************************************************************************* //
  371. typedef enum
  372. {
  373. _GROLE_IDLE = 0,
  374. _GROLE_MASTER = 1,
  375. _GROLE_SLAVE = 2,
  376. _GROLE_SWITCH_TO_IDLE = 10,
  377. _GROLE_SWITCH_IDLE_OK = 11,
  378. _GROLE_SWITCH_TO_MASTER = 20,
  379. _GROLE_SWITCH_MASTER_OK = 21,
  380. _GROLE_SWITCH_TO_SLAVE = 30,
  381. _GROLE_SWITCH_SLAVE_OK = 31,
  382. }_GROUP_ROLE;
  383. typedef struct
  384. {
  385. unsigned char Index;
  386. unsigned char Role;
  387. unsigned char Location;
  388. unsigned char GroupMemberQuantity;
  389. unsigned char GroupMember[MAX_GROUP_QUANTITY];
  390. unsigned char TargetGroup; // group index + 1
  391. }PsuGroupCollectionData;
  392. typedef struct
  393. {
  394. byte Location[MAX_GROUP_QUANTITY];
  395. byte Layout[MAX_GROUP_QUANTITY];
  396. PsuGroupCollectionData GroupCollection[MAX_GROUP_QUANTITY];
  397. }PsuGroupingInfoData;
  398. // ************************************************************************************************* //
  399. typedef struct
  400. {
  401. SystemAuthInfoData AuthInfo;
  402. SysControl Control;
  403. PsuPositionInfoData PsuPosition;
  404. PsuGroupingInfoData PsuGrouping;
  405. }ChargerInfoData;
  406. #endif /* CONFIG_H_ */