#ifndef MODULE_EVCOMM_H_
#define MODULE_EVCOMM_H_

#include 	<stdbool.h>

int CanFd;

typedef unsigned char 		byte;

extern struct Ev_Board_Cmd
{
	int none;
	int address_assignment;
	int get_firmware_ver;
	int get_hardware_ver;
	int charging_permission;
	int present_output_power;
	int present_output_cap;
	int get_output_req;
	int get_battery_info;
	int evse_stop_charging;
	int get_miscellaneous_info;

	int download_req;
	int start_block_transfer;
	int data_transfer;
	int download_finish;

	int isolation_status;
	int evse_precharge_info;
}Ev_Cmd;

extern struct Ev_Cmd_Dir
{
	unsigned short master_to_slave;
	unsigned short slave_to_master;
}Ev_Dir;

struct timeval _id_assign_time;

// Send msg to can-bus
void SetTargetAddr(byte *target_number, byte index);

void GetFirmwareVersion(byte gun_index, byte toId);
void GetHardwareVersion(byte gun_index, byte toId);
void SetChargingPermission(byte gun_index, byte permissionStatus, short aOutputPw, short aOutputVol, short aOutputCur, byte toId);
void SetPresentOutputPower(short outputVol_b1, short outputCur_b1, short outputVol_b2, short outputCur_b2);
void SetPresentOutputCapacity(short aOutputPw_b1, short aOutputCur_b1, short aOutputPw_b2, short aOutputCur_b2);
void GetOutputReq(byte gun_index, byte toId);
void GetEvBatteryInfo(byte gun_index, byte toId);
void GetMiscellaneousInfo(byte gun_index, byte toId);
void SetIsolationStatus(byte gun_index, byte result, byte toId);
void SetEvsePrechargeInfo(byte gun_index, byte result, byte toId);
// �o�e�q�ΥD�ʰ���R�q���G�έ�]
void EvseStopChargingEvent(byte stopResult, byte *stopReason, byte toId);

// Receive msg From can-bus.

enum Receieve_PSU_msgf
{
	// ���ݥD��
	ADDRESS_REQ = 						0x080001FF,
	NOTIFICATION_EV_STATUS = 			0x08000300,
	NOTIFICATION_EV_STOP = 				0x08000B00,

	// ���ݦ^��
	ACK_EV_FW_VERSION = 				0x08000400,
	ACK_EV_HW_VERSION = 				0x08000500,
	ACK_GET_OUTPUT_REQ =				0x08000900,
	ACK_GET_EV_BATTERY_INFO =			0x08000A00,
	ACK_GET_MISCELLANEOUS_INFO = 		0x08000D00,
	ACK_EVSE_ISOLATION_STATUS = 		0x08001200,
	ACK_EVSE_PRECHAGE_INFO = 			0x08001500,
};

#endif /* MODULE_EVCOMM_H_ */