pci9420.h
来自「CAN通讯的测试软件,数据可发送及接收,并能设置时间」· C头文件 代码 · 共 90 行
H
90 行
#include <windows.h>
// define data structure used in PCCAN
// used for config card
struct PORT_CONFIG
{
WORD workMode; // 0 for 11-bit(CAN2.0A);
// 1 for 29-bit(CAN2.0B)
WORD filterMode; // 0 for single filter mode,
// 1 for dual filter mode;
DWORD accCode; // accept code
DWORD accMask; // accept mask
BYTE timer0; // timer0 register (set baudrate)
BYTE timer1; // timer1 register
BYTE control; // enable interrupt
};
// used for select one port of card
struct PORT_STRUCT
{
BYTE card; // index of card(start from 0)
BYTE channel; // select one of channel(start from 0)
};
// CAN Packet used for sending/receiving data
struct CAN_PACKET
{
DWORD CAN_ID; // CAN ID field (32-bit unsigned integer)
BYTE rtr; // CAN RTR bit.
BYTE length; // Length of data field.
BYTE data[8]; // Data (8 bytes maximum)
DWORD time; // Reserved for future use
BYTE reserved; // Reserved byte
};
struct CAN_PACKET1000
{
WORD num;
CAN_PACKET packet[1000];
};
// used for select one port of card
struct PORT_REG
{
BYTE card; // index of card(start from 0)
BYTE reg; // one of register in SJA1000
BYTE value; // for Reading: value read from one register
// for writting: value want to write to one register // reserved
};
#ifdef __cplusplus
extern "C" {
#endif
BOOL WINAPI CAN_Open(void);
// Initialize and set IRQ function
BOOL WINAPI CAN_Init(PORT_STRUCT *ptrStuct,PORT_CONFIG *ptrConfig);
// read function
BOOL WINAPI CAN_Inquiry_Rece(PORT_STRUCT *ptrStruct);
BOOL WINAPI CAN_Rece(PORT_STRUCT *ptrStruct,CAN_PACKET *ptrPacket);
BOOL WINAPI CAN_Clear_RxBuffer(PORT_STRUCT *ptrStruct);
BOOL WINAPI CAN_Get_RxBufferCount(PORT_STRUCT *ptrStruct);
BOOL WINAPI CAN_Read_RxBuffer(PORT_STRUCT *ptrStruct,CAN_PACKET1000 *ptrPacket1000);
// send function
BOOL WINAPI CAN_Inquiry_Trans(PORT_STRUCT *ptrStruct);
BOOL WINAPI CAN_Trans(PORT_STRUCT *ptrStruct,CAN_PACKET *ptrPacket);
// read/write function
BOOL WINAPI CAN_Read_Register(PORT_REG *ptrPortReg);
BOOL WINAPI CAN_Write_Register(PORT_REG *ptrPortReg);
// enable/disable receive
BOOL WINAPI CAN_Enable_Receive(PORT_STRUCT *ptrStruct);
BOOL WINAPI CAN_Disable_Receive(PORT_STRUCT *ptrStruct);
BOOL WINAPI CAN_Inquiry_Status(PORT_STRUCT *ptrStruct);
// Attach event to specified card
BOOL WINAPI CAN_Intr_Attach(HANDLE pEventHdl, BYTE card);
// reset and close function
BOOL WINAPI CAN_Soft_Reset(PORT_STRUCT *ptrStruct);
BOOL WINAPI CAN_Hard_Reset(PORT_STRUCT *ptrStruct);
BOOL WINAPI CAN_Close(void);
#ifdef __cplusplus
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?