43 lines
1.0 KiB
C
43 lines
1.0 KiB
C
#ifndef CAN_DRIVER_H
|
|
#define CAN_DRIVER_H
|
|
|
|
#include "OsSample.h"
|
|
|
|
#define SC_HHS 0 //四川和华盛的USB CAN
|
|
#define ZLG_USB_CAN_II 1 //周立功的USB CAN II & PRO
|
|
#define GC_USB_CAN_II 2 //广诚科技的USB CAN II
|
|
|
|
// CAN包长度
|
|
#define CAN_DATA_LEN 8
|
|
#define CANFD_DATA_LEN 64
|
|
|
|
// CAN包结构体
|
|
typedef struct
|
|
{
|
|
char data[CANFD_DATA_LEN];
|
|
}CAN_PKG,*CAN_PKG_PTR;
|
|
|
|
typedef struct
|
|
{
|
|
// 扫描通道,返回通道数量或状态
|
|
uint8_t (*ScanCanChnl)(void);
|
|
// 初始化硬件
|
|
uint8_t (*InitCan)(uint8_t);
|
|
// 打开/启动 CAN
|
|
uint8_t (*OpenCan)(uint8_t);
|
|
// 关闭 CAN
|
|
uint8_t (*CloseCan)(uint8_t);
|
|
// 复位 CAN
|
|
uint8_t (*ResetCan)(uint8_t);
|
|
// 发送数据包
|
|
uint8_t (*SendCan)(uint8_t chnl, CAN_PKG_PTR canPkg);
|
|
// 接收数据包
|
|
uint8_t (*RecvCan)(uint8_t chnl, CAN_PKG_PTR canPkg);
|
|
}CAN_DRIVER,*CAN_DRIVER_PTR;
|
|
|
|
Status CanProcessInit(void);
|
|
Status CanFuncRegister(uint8_t DeviceType);
|
|
|
|
extern CAN_DRIVER can;
|
|
|
|
#endif |