first commit
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
#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
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef NETWORK_H
|
||||
#define NETWORK_H
|
||||
|
||||
#include "OsSample.h"
|
||||
#include "SocketSample.h"
|
||||
|
||||
#define PKG_LEN 73 //报文长度
|
||||
|
||||
#define PKG_HEART 0xFF //心跳包索引
|
||||
#define PKG_OPEN_CAN 0x00 //打开CAN
|
||||
#define PKG_CLOSE_CAN 0x01 //关闭CAN
|
||||
#define PKG_CTRL_CAN 0x02 //收发CAN
|
||||
|
||||
#define PHEAD 0x55 //报文头
|
||||
#define PEND 0xAA //报文尾
|
||||
|
||||
Status NetProcessInit(uint32_t Port);
|
||||
Status CanFuncOpen(uint8_t chnl);
|
||||
|
||||
#endif
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#ifndef WORK_H
|
||||
#define WORK_H
|
||||
|
||||
#include "OsSample.h"
|
||||
|
||||
#define LISTEN_PORT 12345 //监听端口
|
||||
#define SEND_PORT 54321 //发送端口
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t canFd; //是否CAN_FD
|
||||
uint8_t status; //开关状态
|
||||
uint8_t product; //当前厂商
|
||||
uint8_t chnlNum; //通道个数
|
||||
}WORK_STATUS,*WORK_STATUS_PTR;
|
||||
|
||||
extern WORK_STATUS work;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user