233 lines
6.7 KiB
C
233 lines
6.7 KiB
C
|
#ifndef CAN_DRV_H
|
||
|
#define CAN_DRV_H
|
||
|
|
||
|
/******************************************************************************
|
||
|
Macro definitions
|
||
|
******************************************************************************/
|
||
|
#define R_CAN_GRAMINIT_ON (0x8UL)
|
||
|
#define R_CAN_GSLPSTS_ON (0x4UL)
|
||
|
#define R_CAN_GRSTSTS_ON (0x1UL)
|
||
|
#define R_CAN_CSLPSTS_ON (0x4UL)
|
||
|
#define R_CAN_CHLTSTS_ON (0x2UL)
|
||
|
#define R_CAN_CRSTSTS_ON (0x1UL)
|
||
|
#define R_CAN_TMTRM_ON (0x8U)
|
||
|
#define R_CAN_TMTR_ON (0x1U)
|
||
|
#define R_CAN_AFLDAE_ON (0x100UL)
|
||
|
#define R_CAN_GSLPR_MASK (0x4UL)
|
||
|
#define R_CAN_GMDC_MASK (0x3UL)
|
||
|
#define R_CAN_CSLPR_MASK (0x4UL)
|
||
|
#define R_CAN_CHMDC_MASK (0x3UL)
|
||
|
|
||
|
/******************************************************************************
|
||
|
Exported global variables and functions (to be accessed by other files)
|
||
|
******************************************************************************/
|
||
|
//void R_CAN_Init( void );
|
||
|
//bool R_CAN_Send_TxBuf0(uint32_t can_id, uint8_t dlc, uint8_t msg[8]);
|
||
|
//bool R_CAN_Receive_RxBuf0(uint32_t * p_can_id, uint8_t * p_dlc, uint8_t msg[8]);
|
||
|
|
||
|
/***************************************************/
|
||
|
/*** Compressor CAN0 signals ****/
|
||
|
/***** RX *****/
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned int COMP_CompressorVoltage:16;
|
||
|
|
||
|
unsigned int COMP_CompressorCurrent:8;
|
||
|
|
||
|
unsigned int COMP_CompressorSpeed:16;
|
||
|
|
||
|
unsigned int COMP_CompressorState:2;
|
||
|
|
||
|
unsigned int COMP_InternalVoltageFault:1;
|
||
|
unsigned int COMP_UnderVoltageFault:1;
|
||
|
unsigned int COMP_OverVoltageFault:1;
|
||
|
unsigned int COMP_OverCurrentFault:1;
|
||
|
unsigned int COMP_TemperatureFault:1;
|
||
|
unsigned int COMP_BusOff:1;
|
||
|
unsigned int COMP_LossCommunicationWithAC:1;
|
||
|
}COMP_Information_t;
|
||
|
|
||
|
/***** TX *****/
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
unsigned int AC_CompressorControlCommand:1;
|
||
|
unsigned int AC_CompressorTargetSpeed:16;
|
||
|
}AC_COMP_Control_t;
|
||
|
|
||
|
/***************************************************/
|
||
|
/*** MAIN CAN signals ****/
|
||
|
/***** TX *****/
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned int AC_AcState:1;
|
||
|
unsigned int AC_PtcRelayDriveState:1;
|
||
|
unsigned int AC_DefrostState:2;
|
||
|
unsigned int AC_DemistState:2;
|
||
|
unsigned int AC_IntakeAirState:2;
|
||
|
unsigned int AC_BlowerLevelState:3;
|
||
|
unsigned int AC_PTCHighTemperatureSelfProtectionState:1;
|
||
|
}AC_CurrentStatus_t;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned int AC_COMP_CompressorVoltage:16;
|
||
|
|
||
|
unsigned int AC_COMP_CompressorCurrent:8;
|
||
|
|
||
|
unsigned int AC_COMP_CompressorSpeed:16;
|
||
|
|
||
|
unsigned int AC_COMP_CompressorState:2;
|
||
|
}AC_COMP_Information_t;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned int AC_SleepConditionsReady_Reserved:1;
|
||
|
unsigned int AC_Stayawake_reasons1_Reserved:1;
|
||
|
unsigned int AC_Stayawake_reasons2_Reserved:1;
|
||
|
unsigned int AC_Stayawake_reasons3_Reserved:1;
|
||
|
unsigned int AC_Stayawake_reasons4_Reserved:1;
|
||
|
unsigned int AC_Stayawake_reasons5_Reserved:1;
|
||
|
}AC_NM_t;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned int AC_DiagEvaporatorTemperatureSensorShortCircuit:1;
|
||
|
unsigned int AC_DiagEvaporatorTemperatureSensorOpenCircuit :1;
|
||
|
unsigned int AC_DiagServoMotorShortCircuit :1;
|
||
|
unsigned int AC_DiagServoMotorPositionFault :1;
|
||
|
unsigned int AC_DiagLoopMotorShortCircuit :1;
|
||
|
unsigned int AC_DiagLoopMotorPositionFault :1;
|
||
|
unsigned int AC_DiagBlowermotorShortCircuit :1;
|
||
|
unsigned int AC_DiagBlowermotorOpenCircuit :1;
|
||
|
unsigned int AC_DiagPTC_PressureSensorShortCircuit :1;
|
||
|
unsigned int AC_DiagPTC_PressureSensorOpenCircuit :1;
|
||
|
unsigned int AC_DiagPressureSensorShortCircuit :1;
|
||
|
unsigned int AC_DiagPressureSensorOpenCircuit :1;
|
||
|
unsigned int AC_DiagCoolingPressureTooHight :1;
|
||
|
unsigned int AC_DiagCoolingPressureTooLow :1;
|
||
|
unsigned int AC_DiagCompressorFault :1;
|
||
|
unsigned int AC_DiagCommunicationLostWithVCU :1;
|
||
|
unsigned int AC_DiagCommunicationLostWithHMI :1;
|
||
|
unsigned int AC_DiagCommunicationLostWithComp :1;
|
||
|
unsigned int AC_DiagBusOff :1;
|
||
|
unsigned int AC_DiagCOMP_InternalVoltageFault :1;
|
||
|
unsigned int AC_DiagCOMP_UnderVoltageFault :1;
|
||
|
unsigned int AC_DiagCOMP_OverVoltageFault :1;
|
||
|
unsigned int AC_DiagCOMP_OverCurrentFault :1;
|
||
|
unsigned int AC_DiagCOMP_TemperatureFault :1;
|
||
|
unsigned int AC_DiagCOMP_BusOff :1;
|
||
|
unsigned int AC_DiagCOMP_LossCommunicationWithAC :1;
|
||
|
|
||
|
unsigned char AC_SoftwareVersion;
|
||
|
unsigned char AC_HardwareVersion;
|
||
|
}AC_Diagnosis_t;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned char Data[8];
|
||
|
}AC_DiagResp_t;
|
||
|
|
||
|
/***** RX *****/
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned int VCU_AC_EnableCommand:1;
|
||
|
}VCU_DisplayInfo_t;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned int HMI_AcKeyState:3;
|
||
|
unsigned int HMI_BlowerLevelKey:2;
|
||
|
unsigned int HMI_IntakeAirKey:1;
|
||
|
}HMI_ControlCommand_t;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned char Data[8];
|
||
|
}TEST_AC_DiagReq_t;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int RcvId:11;
|
||
|
unsigned int RcvDLC:4;
|
||
|
|
||
|
unsigned char Data[8];
|
||
|
}TEST_Func_DiagReq_t;
|
||
|
|
||
|
|
||
|
typedef struct {
|
||
|
unsigned int lword[4];
|
||
|
}can_cre_type;
|
||
|
|
||
|
//#define CAN_RX_RULE_NUM 5
|
||
|
#define CAN_PAGE_RX_RULE_IDX_MASK 0xfU
|
||
|
#define CAN_RX_RULE_PAGE_IDX_BIT_POS 4U
|
||
|
/***************************************************/
|
||
|
/**********************CAN FRAME********************/
|
||
|
typedef struct
|
||
|
{
|
||
|
unsigned int ID;
|
||
|
unsigned int * addr;
|
||
|
}Can_Frame_Format;
|
||
|
|
||
|
|
||
|
|
||
|
#define COMP_Information_ID 0x300
|
||
|
#define AC_COMP_Control_ID 0x200
|
||
|
#define AC_CurrentStatus_ID 0x32B
|
||
|
#define AC_COMP_Information_ID 0x35B
|
||
|
#define AC_NM_ID 0x409
|
||
|
#define AC_Diagnosis_ID 0x609
|
||
|
#define AC_DiagResp_ID 0x75B//0x7CE
|
||
|
#define AC_DiagResp_PeriodicDid_ID 0x7AA
|
||
|
#define VCU_DisplayInfo_ID 0x310
|
||
|
#define HMI_ControlCommand_ID 0x348
|
||
|
#define TEST_AC_DiagReq_ID 0x74B//0x7C6
|
||
|
#define TEST_Func_DiagReq_ID 0x7DF
|
||
|
|
||
|
extern volatile COMP_Information_t COMP_Information ;
|
||
|
extern volatile AC_COMP_Control_t AC_COMP_Control ;
|
||
|
extern volatile AC_CurrentStatus_t AC_CurrentStatus ;
|
||
|
extern volatile AC_COMP_Information_t AC_COMP_Information ;
|
||
|
extern volatile AC_NM_t AC_NM ;
|
||
|
extern volatile AC_Diagnosis_t AC_Diagnosis ;
|
||
|
extern volatile AC_DiagResp_t AC_DiagResp ;
|
||
|
extern volatile AC_DiagResp_t AC_DiagResp_PeriodicDid;
|
||
|
extern volatile VCU_DisplayInfo_t VCU_DisplayInfo ;
|
||
|
extern volatile HMI_ControlCommand_t HMI_ControlCommand ;
|
||
|
extern volatile TEST_AC_DiagReq_t TEST_AC_DiagReq ;
|
||
|
extern volatile TEST_Func_DiagReq_t TEST_Func_DiagReq ;
|
||
|
extern const Can_Frame_Format CanBufDsc[];
|
||
|
|
||
|
#endif
|