1.5wuling_zhuanjietou/HARDWARE/CAN/CanDrvCtrl.h

112 lines
5.2 KiB
C
Raw Normal View History

2024-10-17 01:06:51 +00:00
#ifndef __CANDRVCTRL_H__
#define __CANDRVCTRL_H__
/*********************************************************************************************************************
//CANDRVCTRL <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD>can<61><6E><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><E3A3AC>Ϊһ<CEAA><D2BB>Ŧ<EFBFBD><C5A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//
//////////////////////////////////////////////////////////////////////////////////////////////////////
// CAN<41><4E><EFBFBD><EFBFBD><------> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//////////////////////////////////////////////////////////////////////////////////////////////////////
//canͨ<6E><CDA8>id<69><64>can<61><6E>Ϣ֡id<69><64><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD>canid<69><64><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>׳<EFBFBD><D7B3>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD>chan<61><6E>ʾcanͨ<6E><CDA8>
// <20><>frmid<69><64>ʾcan<61><6E>Ϣ֡id
//
//
//can<61><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E3BDAB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƵĽӿ<C4BD>ͨ<EFBFBD><CDA8>st_cancb * RegisterCanIF(st_canif *if) <20>ӿڴ<D3BF><DAB4><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
//st_cancb * RegisterCanIF(st_canif *if) <09><><EFBFBD><EFBFBD><EFBFBD>㽫ij<E3BDAB>ӿڵĿ<DAB5><C4BF><EFBFBD>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>CanDrvCtrlģ<6C><C4A3>
//<2F><><EFBFBD><EFBFBD>st_canif <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳһ<CDB3><D2BB><EFBFBD><EFBFBD>CanDrvCtrl <20>Ľӿ<C4BD><D3BF>б<EFBFBD>,<2C><><EFBFBD><EFBFBD>ConfigCan ,canSend<6E><64>canid<69><64><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD>ػص<D8BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>
*********************************************************************************************************************/
#include "porting.h"
typedef struct{
unsigned char chan; //can<61>ӿڱ<D3BF>ʶ
bool (*ConfigCan)(unsigned char chan,unsigned short krate, bool highdomain,bool listen);
unsigned char (*canSend)(unsigned char chan,unsigned int canid,unsigned char *data,unsigned char len);//<2F><><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>can msg<73><67><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>Ϣ<EFBFBD><CFA2>ˮ<EFBFBD><CBAE>,0xFFFFFFFFΪʧ<CEAA><CAA7>
bool (*canClose)(unsigned char chan);
bool (*canHwPowerDown)(unsigned char chan);
bool (*canHwPowerUp)(unsigned char chan);
bool (*canBusFilterInit) (unsigned char chan ,unsigned int *filterID_array, unsigned short filterID_total);
bool (*canCloseFilter) (unsigned char chan);
}st_canif;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>Ҫ<EFBFBD><D2AA>can<61><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㡱ʵ<E3A1B1>֡<EFBFBD>hdlRemoteFrm<72><6D>ΪNULL<4C><4C><EFBFBD>򲻽<EFBFBD><F2B2BBBD><EFBFBD>Զ<EFBFBD><D4B6>֡.
typedef struct{
void (*SendSuccessCb)(unsigned char chan,unsigned int index); //ij<><C4B3><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>ͳɹ<CDB3>
void (*BusErrorCb)(unsigned char chan,bool sending); //<2F><><EFBFBD>ߴ<EFBFBD><DFB4><EFBFBD>
void (*BusErrorStsCb)(unsigned char chan,bool sending); //<2F><><EFBFBD>ߴ<EFBFBD><DFB4><EFBFBD>״̬<D7B4>ı<EFBFBD>
void (*BusOffCb)(unsigned char chan); //<2F><><EFBFBD>߽<EFBFBD><DFBD><EFBFBD>BUS OFF <20>Ļص<C4BB>
bool (*hdlFrmReceve)(unsigned char chan,unsigned int canid, const unsigned char *data,unsigned char len); //len = 0<><30>ʾԶ<CABE><D4B6>֡
}st_cancb;
st_cancb * RegisterCanIF(const st_canif *IF);
/*********************************************************************************************************************
//CANDRVCTRL <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD>can<61><6E><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD><E3A3AC>Ϊһ<CEAA><D2BB>Ŧ<EFBFBD><C5A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//
//////////////////////////////////////////////////////////////////////////////////////////////////////
// <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><------> <20><><EFBFBD><EFBFBD>Э<EFBFBD><D0AD> **************************
//////////////////////////////////////////////////////////////////////////////////////////////////////
//bool InstallProtocalToIF(unsigned char canid, st_pl* pif, st_cl * pcanif); <20><>ij<EFBFBD><C4B3><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD>Э<EFBFBD><D0AD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// ͬһʱ<D2BB>һ<E4A3AC><D2BB><EFBFBD>ӿڽ<D3BF><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD>st_pl<70><6C> <20><>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>Ľӿڣ<D3BF><DAA3><EFBFBD>Щ<EFBFBD><D0A9>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>CANDRVCTRL<52><4C><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD>st_cl, <09><>CANDRVCTRL <20><EFBFBD>Ľӿڣ<D3BF> Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>Щ<EFBFBD>ӿڽ<D3BF><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݷ<EFBFBD><DDB7>͵<EFBFBD>
*********************************************************************************************************************/
//<2F><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><E1B9A9>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD>Ľӿ<C4BD>
typedef struct{
//void(*cb)(unsigned int result) result :#define _SUCCESS 0 #define _FAILURE 1 #define _OVERTIME 2 #define _ABANDON 3
bool (*SEND)(unsigned char chan,unsigned int frmid,unsigned char *data,unsigned char len,unsigned int msgident,void(*cb)(unsigned int msgident,unsigned int result));//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Զ<EFBFBD><D4B6>֡<EFBFBD><D6A1>
bool (*REC)(unsigned char chan,unsigned int* frmid,unsigned char *data,unsigned char* len);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Զ<EFBFBD><D4B6>֡<EFBFBD><D6A1>
unsigned int (*GetCurrentLinkSts)(unsigned char chan); //<2F><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0>״̬
bool (*ConfigBus)(unsigned char chan,unsigned short krate, bool highdomain,bool listen);
bool (*canBusFilterInit) (unsigned char chan,unsigned int *filterID_array, unsigned short filterID_total);
bool (*CloseLink)(unsigned char chan);
}st_cl;
#define CAN_SEND_FASET_MODE 1
//Э<><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>ӿ<EFBFBD>
#define CAN_FLG_SYNCRECEIVE 1 //<2F><><EFBFBD>պ<EFBFBD><D5BA><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>hdlRecCanMsg<73>ӿڷ<D3BF><DAB7>ظ<EFBFBD>Ӧ<EFBFBD>ò<EFBFBD>
//<2F><><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8>REC<45>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD>ֶ<EFBFBD><D6B6><EFBFBD>ȡ
typedef enum
{
e_sts_empty=0, //<2F>˽ӿ<CBBD><D3BF><EFBFBD><EFBFBD>ǿ<EFBFBD>δ<EFBFBD>нӿ<D0BD><D3BF><EFBFBD><EFBFBD><EFBFBD>ƥ<EFBFBD><C6A5>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>RegisterCanIF<49><46><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>unused
e_sts_unused,
e_sts_closed,
e_sts_working, //<2F><>ǰ<EFBFBD><C7B0><EFBFBD>ڹ<EFBFBD><DAB9><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>
e_sts_needsend, //<2F><>ǰ<EFBFBD><C7B0><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD>
e_err_receive=0x80,
e_err_sending,
e_err_overfllow,
e_err_bussoff,
}e_link_sts;
typedef struct{
char prompt[32]; //<2F><>ʾ
unsigned int flg; //bit0 = can<61><6E>Ϣ<EFBFBD><CFA2><EFBFBD>շ<EFBFBD>ʽ
unsigned char resendTimes; //<2F><><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>
unsigned char msgNumber; //<2F><><EFBFBD>ա<EFBFBD><D5A1><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><D0B8><EFBFBD>
void (*hdlRecCanMsg)(unsigned int id, const unsigned char *data,unsigned char len); //len<65><6E>0<EFBFBD><30>ʾ<EFBFBD><CABE>Զ<EFBFBD><D4B6>֡
void (*hdlBusError)(e_link_sts err);
void (*hdlCommSent)(unsigned int msgident, unsigned int result); //ͨ<>÷<EFBFBD><C3B7>ͽ<EFBFBD><CDBD><EFBFBD><EFBFBD>Ļص<C4BB>
}st_pl;
//st_pl* ppl, st_cl * pcl <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>ռ<EFBFBD><D5BC>ķ<EFBFBD><C4B7><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ʱ<EFBFBD><CAB1>
bool InstallProtocalToIF(unsigned char chan, st_pl* ppl, st_cl * pcl);
bool UninstallProtocalToIF(unsigned char chan, st_pl* ppl);
//<2F>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>һЩ<D2BB><D0A9>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void hdlCanCtrlMsg(e_link_sts msg,unsigned char chan);
void InitCanDrvCtrlMode(void);
#endif