Module_EvComm.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef MODULE_EVCOMM_H_
  2. #define MODULE_EVCOMM_H_
  3. #include <stdbool.h>
  4. int CanFd;
  5. typedef unsigned char byte;
  6. typedef enum
  7. {
  8. EV_Slave_Address_Broadcast = 0xFF,
  9. EV_Slave_Address_Bd1 = 0x01,
  10. EV_Slave_Address_Bd2 = 0x02
  11. }EvSlaveAddr;
  12. typedef enum
  13. {
  14. EV_Command_AddressReq = 0x01,
  15. EV_Command_AddressAssignment = 0x02,
  16. EV_Command_EvStatusNotification = 0x03,
  17. EV_Command_GetFwVersion = 0x04,
  18. EV_Command_GetHwVersion = 0x05,
  19. EV_Command_ChargingPermission = 0x06,
  20. EV_Command_PresentOutputPow = 0x07,
  21. EV_Command_PresentOutputCap = 0x08,
  22. EV_Command_GetOutputReq = 0x09,
  23. EV_Command_GetBetteryInfo = 0x0A,
  24. EV_Command_EvStopNotification = 0x0B,
  25. EV_Command_EvseStopCharging = 0x0C,
  26. EV_Command_GetMiscellaneous = 0x0D,
  27. EV_Command_IsolationStatus = 0x12,
  28. EV_Command_CCSconnectorInfo = 0x13,
  29. EV_Command_SyncRtcInfo = 0x14,
  30. EV_Command_EvsePrechargeInfo = 0x15,
  31. EV_Command_EvccidReq = 0x16,
  32. EV_Command_VincodeData = 0xEB,
  33. EV_Command_VincodeInfo = 0xEC
  34. }EvCmd;
  35. typedef union
  36. {
  37. unsigned int EvMessage;
  38. struct
  39. {
  40. unsigned int SlaveAddress:8;
  41. unsigned int MessageID:8;
  42. unsigned int Rsv:11;
  43. unsigned int Dir:1;
  44. unsigned int res:4;
  45. }EvBdBits;
  46. }EvFrame;
  47. extern struct Ev_Cmd_Dir
  48. {
  49. unsigned short master_to_slave;
  50. unsigned short slave_to_master;
  51. }Ev_Dir;
  52. struct timeval _id_assign_time;
  53. // Send msg to can-bus
  54. void SetTargetAddr(byte *target_number, byte index);
  55. void GetFirmwareVersion(byte gun_index, byte toId);
  56. void SyncRtcInfo(byte gun_index, byte toId, int epoch);
  57. void SetConnectInfo(byte type, byte toId);
  58. void GetHardwareVersion(byte gun_index, byte toId);
  59. void SetChargingPermission(byte gun_index, byte permissionStatus, float aOutputPw, float aOutputVol, short aOutputCur, byte toId);
  60. void SetPresentOutputPower(short outputVol_b1, short outputCur_b1, short outputVol_b2, short outputCur_b2);
  61. void SetPresentOutputCapacity(short aOutputPw_b1, short aOutputCur_b1, short aOutputPw_b2, short aOutputCur_b2);
  62. void GetOutputReq(byte gun_index, byte toId);
  63. void GetEvccIdReq(byte gun_index, byte toId);
  64. void GetEvBatteryInfo(byte gun_index, byte toId);
  65. void GetMiscellaneousInfo(byte gun_index, byte relayStatus, float power, float voltage, byte toId);
  66. void SetIsolationStatus(byte gun_index, byte result, byte toId);
  67. void SetEvsePrechargeInfo(byte gun_index, byte result, byte toId);
  68. // 發送電樁主動停止充電結果及原因
  69. void EvseStopChargingEvent(byte stopResult, byte *stopReason, byte toId);
  70. // Receive msg From can-bus.
  71. enum EV_LOG_INDEX
  72. {
  73. EV_LOG_OUTPUT_CAP_POW = 0,
  74. EV_LOG_OUTPUT_CAP_CUR = 1,
  75. EV_LOG_NOW_OUTPUT_VOL = 2,
  76. EV_LOG_NOW_OUTPUT_CUR = 3,
  77. EV_LOG_EVSE_MAX_VOL = 4,
  78. EV_LOG_EVSE_MAX_CUR = 5,
  79. EV_LOG_MAX_BATT_VOL = 6,
  80. EV_LOG_REAL_CAP_POW = 7,
  81. EV_LOG_SOC = 8
  82. };
  83. #endif /* MODULE_EVCOMM_H_ */