Module_EvComm.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. }EvCmd;
  33. typedef union
  34. {
  35. unsigned int EvMessage;
  36. struct
  37. {
  38. unsigned int SlaveAddress:8;
  39. unsigned int MessageID:8;
  40. unsigned int Rsv:11;
  41. unsigned int Dir:1;
  42. unsigned int res:4;
  43. }EvBdBits;
  44. }EvFrame;
  45. extern struct Ev_Cmd_Dir
  46. {
  47. unsigned short master_to_slave;
  48. unsigned short slave_to_master;
  49. }Ev_Dir;
  50. struct timeval _id_assign_time;
  51. // Send msg to can-bus
  52. void SetTargetAddr(byte *target_number, byte index);
  53. void GetFirmwareVersion(byte gun_index, byte toId);
  54. void SyncRtcInfo(byte gun_index, byte toId, int epoch);
  55. void SetConnectInfo(byte type, byte toId);
  56. void GetHardwareVersion(byte gun_index, byte toId);
  57. void SetChargingPermission(byte gun_index, byte permissionStatus, float aOutputPw, float aOutputVol, short aOutputCur, byte toId);
  58. void SetPresentOutputPower(short outputVol_b1, short outputCur_b1, short outputVol_b2, short outputCur_b2);
  59. void SetPresentOutputCapacity(short aOutputPw_b1, short aOutputCur_b1, short aOutputPw_b2, short aOutputCur_b2);
  60. void GetOutputReq(byte gun_index, byte toId);
  61. void GetEvccIdReq(byte gun_index, byte toId);
  62. void GetEvBatteryInfo(byte gun_index, byte toId);
  63. void GetMiscellaneousInfo(byte gun_index, byte relayStatus, float power, float voltage, byte toId);
  64. void SetIsolationStatus(byte gun_index, byte result, byte toId);
  65. void SetEvsePrechargeInfo(byte gun_index, byte result, byte toId);
  66. // 發送電樁主動停止充電結果及原因
  67. void EvseStopChargingEvent(byte stopResult, byte *stopReason, byte toId);
  68. // Receive msg From can-bus.
  69. enum EV_LOG_INDEX
  70. {
  71. EV_LOG_OUTPUT_CAP_POW = 0,
  72. EV_LOG_OUTPUT_CAP_CUR = 1,
  73. EV_LOG_NOW_OUTPUT_VOL = 2,
  74. EV_LOG_NOW_OUTPUT_CUR = 3,
  75. EV_LOG_EVSE_MAX_VOL = 4,
  76. EV_LOG_EVSE_MAX_CUR = 5,
  77. EV_LOG_MAX_BATT_VOL = 6,
  78. EV_LOG_REAL_CAP_POW = 7,
  79. EV_LOG_SOC = 8
  80. };
  81. #endif /* MODULE_EVCOMM_H_ */