⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 can200.h

📁 This version 0.2 of driver for a simple CAN bus interface. 一个CAN 总线接口程序
💻 H
字号:
#ifndef CAN200_H#define CAN200_H#include <linux/ioctl.h>#define DEVICE_NAME "can200"#define DRIVER_VERSION "0.2"#define CAN_MAJOR 60/* Device and Driver Declarations **************************** */#define LP_PORT 0x278#define LP_PORT_SIZE 8#define LP_IRQ 5#define LP_RESET_ON  0x00#define LP_RESET_OFF 0x04#define LP_IRQ_ENA   0x10/* * This is the CAN message */typedef struct {        unsigned char info;      /* EFF RTR 0 0 DLC.3 DLC.2 DLC.1 DLC.0 */        unsigned char id0;        unsigned char id1;        unsigned char id2;       /* not present in standard frames */        unsigned char id3;       /* not present in standard frames */        unsigned char data[8];        unsigned char pad;       /* pad to even address */        unsigned short status;   /* TBD */        unsigned long timestamp; /* jiffies at receive */} can_msg_t;#define CAN_INFO_EFF 0x80#define CAN_INFO_RTR 0x40#define CAN_INFO_LEN_MASK 0x0F#define CAN_ID1_MASK 0xE0        /* ID20 ID19 ID18 0 0 0 0 0 *//*--- Remote Request ---------------------------------*//*    Notes:	RTR is Bit 5 in TXDES1. */#ifndef CAN_ID1_RTR#define CAN_ID1_RTR 0x10#endif#define CAN_MSG_LEN (sizeof( can_msg_t ) )/* CAN operating modes */enum {CAN_RESET=-1, CAN_10K, CAN_20K, CAN_40K, CAN_50K, CAN_100K, CAN_125K };#define SUCCESS 0/* Set the message of the device driver */#define IOCTL_SET_SPEED _IOR(CAN_MAJOR, 0, int)/* _IOR means that we're creating an ioctl command * number for passing information from a user process * to the kernel module. * * The first arguments, CAN_MAJOR, is the major device * number we're using. * * The second argument is the number of the command * (there could be several with different meanings). * * The third argument is the type we want to get from * the process to the kernel. *//* Get the n'th byte of the message *///#define IOCTL_GET_NTH_BYTE _IOWR(CAN_MAJOR, 2, int) /* The IOCTL is used for both input and output. It  * receives from the user a number, n, and returns  * Message[n]. */#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -