CsuCommAC.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. /*===========================================================================
  2. Combined Charging System (CCS): SECC
  3. CsuCommAC.h
  4. initiated by Joseph
  5. (since 2020/06/10)
  6. =============================================================================
  7. Merged from:
  8. - GIT Server: https://git.phihong.com.tw:30000/System_Integration/CSU3_AM335x/commits/AW-CCS
  9. - VERSION SHA: de7e1da3b9d219fbb8babf12d305e9423f1e8d94
  10. - VERSION Date: 2020-06-12
  11. =============================================================================*/
  12. typedef struct Verion
  13. {
  14. char Version_FW[32];
  15. char Version_HW[32];
  16. }Ver;
  17. typedef struct PRESENTINPUTVOLTAGE
  18. {
  19. unsigned char inputType; // 0x00: Line to Line 0x01: Line to Neutral
  20. double L1N_L12;
  21. double L2N_L23;
  22. double L3N_L31;
  23. }PresentInputVoltage;
  24. typedef struct PRESENTOUTPUTVOLTAGE
  25. {
  26. double behindFuse_Voltage_C1;
  27. double behindRelay_Voltage_C1;
  28. double behindFuse_Voltage_C2;
  29. double behindRelay_Voltage_C2;
  30. }PresentOutputVoltage;
  31. typedef struct FANSPEED
  32. {
  33. unsigned short int speed[4];
  34. }FanSpeed;
  35. typedef struct TEMPERATURE
  36. {
  37. unsigned char point[8];
  38. }Temperature;
  39. typedef struct AUXPOWER
  40. {
  41. unsigned char voltage[8];
  42. }AuxPower;
  43. typedef struct RELAY
  44. {
  45. unsigned char relay_status[2][8];
  46. }Relay;
  47. typedef struct GFD
  48. {
  49. unsigned short int adc_value_positive[2];
  50. unsigned short int adc_value_negative[2];
  51. }Gfd;
  52. typedef struct GPIO_IN
  53. {
  54. unsigned char AC_Connector;
  55. unsigned char AC_MainBreaker;
  56. unsigned char SPD;
  57. unsigned char Door_Open;
  58. unsigned char GFD[2];
  59. unsigned char Button[2];
  60. unsigned char Button_Emergency;
  61. }Gpio_in;
  62. typedef struct GPIO_OUT
  63. {
  64. unsigned char AC_Connector;
  65. unsigned char Button_LED[2];
  66. unsigned char System_LED[4];
  67. }Gpio_out;
  68. typedef struct ALARM_LOG
  69. {
  70. unsigned char logArea;
  71. unsigned int alarmIndex;
  72. unsigned char log[8];
  73. }Alarm_Log;
  74. typedef struct BLE_CONFIG_DATA
  75. {
  76. unsigned char isLogin:1;
  77. unsigned char isRequestStart:1;
  78. unsigned char isRequestStop:1;
  79. }Ble_Config_Data;
  80. typedef struct BLE_LONGIN_CENTRAL_ID
  81. {
  82. unsigned char id[32];
  83. }Ble_Login_Central_Id;
  84. typedef struct RTC
  85. {
  86. unsigned short int year;
  87. unsigned char month;
  88. unsigned char day;
  89. unsigned char hour;
  90. unsigned char min;
  91. unsigned char sec;
  92. }Rtc;
  93. typedef struct PRESENTOUTPUTCURRENT
  94. {
  95. double L1N_L12[2];
  96. double L2N_L23[2];
  97. double L3N_L31[2];
  98. }Presentoutputcurrent;
  99. typedef struct AC_PRIMARY_MCU
  100. {
  101. unsigned char cp_state;
  102. unsigned int current_limit;
  103. float cp_voltage_positive;
  104. float cp_voltage_negtive;
  105. unsigned char locker_state;
  106. unsigned char relay_state;
  107. unsigned char shutter_state;
  108. unsigned char meter_state;
  109. unsigned char pp_state;
  110. unsigned char rating_current;
  111. unsigned char rotatory_switch;
  112. Relay relayState;
  113. }Ac_Primary_Mcu;
  114. typedef struct AC_PRIMARY_MCU_ALARM
  115. {
  116. union
  117. {
  118. unsigned long InputAlarmCode;
  119. struct
  120. {
  121. unsigned long OVP_L1:1;
  122. unsigned long UVP_L1:1;
  123. unsigned long OCP_L1:1;
  124. unsigned long OTP:1;
  125. unsigned long gmi_fault:1;
  126. unsigned long cp_fault:1;
  127. unsigned long ac_leak:1;
  128. unsigned long dc_leak:1;
  129. unsigned long mcu_selftest_fail:1;
  130. unsigned long handshaking_timeout:1;
  131. unsigned long emergency_stop:1;
  132. unsigned long relay_welding:1;
  133. unsigned long leak_module_fail:1;
  134. unsigned long shutter_fault:1;
  135. unsigned long locker_fault:1;
  136. unsigned long power_drop:1;
  137. unsigned long rotate_switch_fault:1;
  138. unsigned long short_circuit_L1:1;
  139. unsigned long relay_drive_fault:1;
  140. unsigned long comm_timeout:1;
  141. unsigned long OVP_L2:1;
  142. unsigned long UVP_L2:1;
  143. unsigned long OCP_L2:1;
  144. unsigned long OVP_L3:1;
  145. unsigned long UVP_L3:1;
  146. unsigned long OCP_L3:1;
  147. unsigned long short_circuit_L2:1;
  148. unsigned long short_circuit_L3:1;
  149. }bits;
  150. };
  151. }Ac_Primary_Mcu_Alarm;
  152. typedef struct AC_PRIMARY_MCU_LED
  153. {
  154. unsigned char mode;
  155. unsigned long alarm_code;
  156. }Ac_Primary_Mcu_Led;
  157. typedef struct EVSE_ID
  158. {
  159. unsigned char model_name[14];
  160. unsigned char serial_number[12];
  161. }Evse_Id;
  162. typedef struct AC_PRIMARY_MCU_CP_PWM_DUTY
  163. {
  164. unsigned int max_current;
  165. }Ac_Primary_Mcu_Cp_Pwm_Duty;
  166. typedef struct LEGACY_REQUEST
  167. {
  168. unsigned char isLegacyRequest:1;
  169. uint8_t isRelayOn:1;
  170. }Legacy_Request;
  171. typedef struct POWER_CONSUMPTION
  172. {
  173. uint32_t power_consumption;
  174. uint32_t power_consumption_at_start;
  175. }Power_Consumption;
  176. typedef struct MCU_OP_FLAG
  177. {
  178. unsigned char isSetModePass:1;
  179. unsigned char isSetSerialNumberPass:1;
  180. unsigned char isSetModelNamePass:1;
  181. unsigned char isReadFwVerPass:1;
  182. unsigned char isMcuUpgradeReq:1;
  183. unsigned char isSetCpPwmDuty:1;
  184. }Mcu_Op_Flag;
  185. typedef struct SYSTEM_ALARM_CODE
  186. {
  187. unsigned long SystemAlarmCode;
  188. }System_Alarm_Code;
  189. typedef struct OTHER_ALARM_CODE
  190. {
  191. unsigned long isHandshakingTimeOut:1;
  192. unsigned long isDcLeakage:1;
  193. unsigned long isACLeakage:1;
  194. }Other_Alarm_Code;
  195. typedef struct PILOT_VOLTAGE
  196. {
  197. float PilotVoltagePositive;
  198. float PilotVoltageNegative;
  199. }Pilot_Voltage;
  200. typedef struct FW_UPGRADE_INFO
  201. {
  202. int fwType;
  203. char modelName[17];
  204. char location[384];
  205. }Fw_Upgrade_Info;
  206. typedef struct GUN_PLUGIN_TIMES
  207. {
  208. uint32_t GunPluginTimes;
  209. }Gun_Plugin_Times;
  210. typedef struct MCU_RESET_REQUEST
  211. {
  212. unsigned char isMcuResetRequest:1;
  213. }Mcu_Reset_Request;
  214. typedef struct TIMEOUT_SPEC
  215. {
  216. int Setting_Timeout_Spec;
  217. int Present_Timeout_Spec;
  218. }Timeout_Spec;
  219. typedef struct SET_BREATHE_LED_TIMING
  220. {
  221. uint16_t set_Led_Action_Connected_Fade_In;
  222. uint16_t set_Led_Action_Connected_Fade_Out;
  223. uint16_t set_Led_Action_Authed_Fade_In;
  224. uint16_t set_Led_Action_Authed_Fade_Out;
  225. uint16_t Set_Led_Action_Chaging_Fade_In;
  226. uint16_t set_Led_Action_Chaging_Fade_Out;
  227. }Set_Breathe_Led_Timing;
  228. typedef struct SET_LED_BRIGHTNESS
  229. {
  230. uint8_t sector_1; // 0~1 AM and 1~2 AM
  231. uint8_t sector_2; // 2~3 AM and 3~4 AM
  232. uint8_t sector_3; // 4~5 AM and 5~6 AM
  233. uint8_t sector_4; // 6~7 AM and 7~8 AM
  234. uint8_t sector_5; // 8~9 AM and 9~10 AM
  235. uint8_t sector_6; // 10~11 AM and 11~12 AM
  236. uint8_t sector_7; // 12~13 PM and 13~14 PM
  237. uint8_t sector_8; // 14~15 PM and 15~16 PM
  238. uint8_t sector_9; // 16~17 PM and 17~18 PM
  239. uint8_t sector_10; // 18~19 PM and 19~20 PM
  240. uint8_t sector_11; // 20~21 PM and 21~22 PM
  241. uint8_t sector_12; // 22~23 PM and 23~24 PM
  242. }Set_Led_Brightness;
  243. typedef struct CCS_INFO
  244. {
  245. uint8_t BatteryChargeType; /*0x00: AC charging, 0x01: DC charging*/
  246. uint8_t PresentMsgFlowStatus;
  247. /* ISO15118_2018
  248. 0: Idle(wait B2 state),
  249. 1: CM_SLAC_PARM.REQ,
  250. 2: CM_SLAC_PARM.CNF,
  251. 3: CM_START_ATTEN_CHAR.IND
  252. 4: CM_MNBC_SOUND.IND,
  253. 5: CM_ATTEN_CHAR.IND,
  254. 6: CM_ATTEN_CHAR.RSP,
  255. 7: CM_VALIDATE.REQ
  256. 8: CM_VALIDATE.CNF,
  257. 9: CM_SLAC_MATCH.REQ,
  258. 10: CM_SLAC_MATCH.CNF,
  259. 11: CM_AMP_MAP.REQ
  260. 12: CM_AMP_MAP.CNF,
  261. 13: SLACC/SDP/TCP connection,
  262. 16: SupportedAppProtocolRequest,
  263. 17: SupportedAppProtocolResponse,
  264. 18: SessionSetupRequest
  265. 19: SessionSetupResponse,
  266. 20: ServiceDiscoveryRequest,
  267. 21: ServiceDiscoveryResponse
  268. 22: ServiceDetailRequest,
  269. 23: ServiceDetailResponse
  270. 24:ServiceAndPaymentSelectionRequest/ServiceSelectionRequest,
  271. 25: ServiceAndPaymentSelectionResponse/ServiceSelectionResponse
  272. 26: PaymentDetailsRequest/IdentificationDetailsRequest;,
  273. 27: PaymentDetailsResponse/IdentificationDetailsResponse,
  274. 28: AuthorizationRequest,
  275. 29: AuthorizationResponse,
  276. 30: CertificateUpdateRequest,
  277. 31: CertificateUpdateResponse,
  278. 32:CertificateInstallationRequest,
  279. 33: CertificateInstallationResponse
  280. 34: ChargeParameterDiscoveryRequest,
  281. 35: ChargeParameterDiscoveryResponse
  282. 36: CableCheckRequest,
  283. 37: CableCheckResponse,
  284. 38: PreChargeRequest,
  285. 39: PreChargeResponse
  286. 40: PowerDeliveryRequest start,
  287. 41: PowerDeliveryResponse start,
  288. 42: ChargingStatusRequest,
  289. 43: ChargingStatusResponse
  290. 44:CurrentDemandRequest,
  291. 45:CurrentDemandResponse,
  292. 46:MeteringReceiptRequest,
  293. 47: MeteringReceiptResponse
  294. 48: PowerDeliveryRequest end,
  295. 49: PowerDeliveryRequest end,
  296. 50: WeldingDetectionRequest,
  297. 51: WeldingDetectionResponse,
  298. 52: SessionStopRequest,
  299. 53: SessionStopResponse
  300. 253: Performance Timeout,
  301. 254: Sequence Timeout,
  302. 255: Fault
  303. */
  304. float ConnectorTemperature1; /*unit: 1°C*/
  305. float ConnectorTemperature2; /*unit: 1°C*/
  306. uint16_t ChargingRemainTime; /*0x0000: 0 sec ~ 0xFFFF: 65535 sec, unit: 1 second*/
  307. float TotalBatteryCapacity; /*unit: Wh*/
  308. float BatteryMaximumVoltage; /*unit: 1 volt*/
  309. float BatteryMaximumCurrent; /*unit: 1 amp*/
  310. uint8_t EVCCID[8];
  311. uint8_t EVSEID[40];
  312. uint8_t CCSLibRev[32];
  313. uint8_t EVSEModelName[32];
  314. uint32_t CSUAlarmStatusCode;
  315. uint16_t CCSAlarmStatusCode;
  316. uint8_t PaymentOption; /* 0x00 EIM, 0x01 Pnc */
  317. float EVSEMaxCurrent; /*unit: 1 amp*/
  318. float EVSEMinCurrent; /*unit: 1 amp*/
  319. float GridVoltage[3]; /*unit: 1 volt*/
  320. uint8_t MeterID[32]; /*unit: 1 amp*/
  321. float MeterReadingValue; /*unit: 1Wh*/
  322. uint8_t EVOperation; /*0:Charge, 1:Discharge*/
  323. uint8_t EVChargeProgress; /*0: Stop
  324. 1: Start
  325. 2: Renegotiate
  326. 3: Standby */
  327. uint8_t CpSetPWMDuty; /*unit: 1%
  328. 0: 0%
  329. 5: 5%
  330. 100: 100%*/
  331. uint8_t CpSetStateE; /*0:disable, 1:enable*/
  332. uint8_t CpPresentPWMDuty; /*unit:1%*/
  333. uint8_t CpPresentState; /*1: A (12V, no PWM)
  334. 2: B1 (9V, no PWM)
  335. 3: B2 (9V, with PWM)
  336. 4: C (6V, with PWM)
  337. 5: D (3V, with PWM)
  338. 6: E (0V, no PWM)
  339. 7: F (-12V, no PWM)
  340. 8: G (>12V)
  341. 9: H (<12V)*/
  342. float CpPositiveVoltage; /*uint: 1V*/
  343. float CpNegativeVoltage; /*uint: 1V*/
  344. uint32_t CcsHeartBeat; /*unit: 1*/
  345. float EVSEPresentCurrent[3]; //unit: 1A
  346. float AvailableChargingPower; //1KW
  347. uint8_t EVSENotification; //0:none, 1:StopCharging, 2:RenNgotiation
  348. uint16_t ChargingPermission:1; /*0x00: Not ready yet, stay in idle mode or go into terminating process.
  349. 0x01: start charging process*/
  350. uint16_t ConnectorLockerStatus:1; /*0x00: released
  351. 0x01: locked*/
  352. uint16_t RcdStatus:1; /* 0x00 no error
  353. 0x01 an error */
  354. uint16_t OutputRelayStatus:1; /*0: OFF
  355. 1: ON*/
  356. uint16_t TempFlag4:1;
  357. uint16_t TempFlag5:1;
  358. uint16_t TempFlag6:1;
  359. uint16_t TempFlag7:1;
  360. uint16_t TempFlag8:1;
  361. uint16_t TempFlag9:1;
  362. uint16_t TempFlag10:1;
  363. uint16_t TempFlag11:1;
  364. uint16_t TempFlag12:1;
  365. uint16_t TempFlag13:1;
  366. uint16_t TempFlag14:1;
  367. uint16_t TempFlag15:1;
  368. }Ac_Ccs_Info;
  369. typedef struct GUN_INFO
  370. {
  371. Ver ver;
  372. PresentInputVoltage inputVoltage;
  373. Presentoutputcurrent outputCurrent;
  374. Temperature temperature;
  375. Ble_Config_Data bleConfigData;
  376. Ble_Login_Central_Id bleLoginCentralId;
  377. Rtc rtc;
  378. Ac_Primary_Mcu primaryMcuState;
  379. Ac_Primary_Mcu_Alarm primaryMcuAlarm;
  380. Ac_Primary_Mcu_Led primaryMcuLed;
  381. Mcu_Op_Flag mcuFlag;
  382. Power_Consumption powerConsumption;
  383. Legacy_Request legacyRequest;
  384. System_Alarm_Code systemAlarmCode;
  385. Ac_Primary_Mcu_Cp_Pwm_Duty primaryMcuCp_Pwn_Duty;
  386. Other_Alarm_Code otherAlarmCode;
  387. Pilot_Voltage PilotVoltage;
  388. Gun_Plugin_Times gunPluginTimes;
  389. Mcu_Reset_Request mcuResetRequest;
  390. Set_Breathe_Led_Timing setBreatheLedTiming;
  391. Set_Led_Brightness setLedBrightness;
  392. Ac_Ccs_Info acCcsInfo;
  393. uint8_t ccsHandshakeState;
  394. uint8_t PreviousEVChargeProgress;
  395. uint8_t chargingMode;
  396. uint16_t targetCurrent;
  397. uint16_t isAuthPassEnd:1;
  398. uint16_t rfidReq:1;
  399. uint16_t isGunPlugged:1;
  400. uint16_t isInitialPass:1;
  401. uint16_t isSetBreatheLedTiming:1;
  402. uint16_t isSetLedBrightness:1;
  403. uint16_t isUnlockerConnetor:1;
  404. uint16_t isOperactive:1;
  405. uint16_t isCCSWaitChangeDuty:1;
  406. uint16_t isCCSStartTransation:1;
  407. }Gun_Info;
  408. //struct Charger
  409. struct InternalCommAC
  410. {
  411. Ver ver;
  412. Evse_Id evseId;
  413. Gun_Info gun_info[2];
  414. Fw_Upgrade_Info fwUpgradeInfo;
  415. Timeout_Spec timeoutSpec;
  416. uint8_t gun_selectd;
  417. uint8_t speaker_type;
  418. uint8_t isSpeakerOn:1;
  419. uint8_t isUpdateSuccess:1;
  420. };