📄 pcan_main.h
字号:
struct pcan_pccard; // forward declaration for ease of inclusiontypedef struct{ u32 dwPort; // the port of the transport layer u16 wIrq; // the associated irq int nChannel; // associated channel of the card struct pcan_pccard *card; // points to the associated pccard } PCCARD_PORT;#endif#ifdef USB_SUPPORTtypedef struct{ u64 ullCumulatedTicks; // sum of all ticks u64 ullOldCumulatedTicks; // old ... struct timeval StartTime; // time of first receive u16 wStartTicks; // ticks at first init u16 wLastTickValue; // Last aquired tick count u16 wOldLastTickValue; // old ... u8 ucLastTickValue; // the same for byte tick counts} PCAN_USB_TIME;typedef struct{ u8 ucNumber; // number (or address) of endpoint u16 wDataSz; // supported max data transfer length} PCAN_ENDPOINT;typedef struct{ struct usb_device *usb_dev; // the origin pointer to my USB device from kernel PCAN_ENDPOINT Endpoint[PCAN_USB_MAX_ENDPOINTS]; // current endpoint numbers and sizes u32 dwSerialNumber; // Serial number of device u8 ucHardcodedDevNr; // ascending number stored in device to distinguish after hotplug u8 ucRevision; // the revision number of the device wait_queue_head_t usb_wait_queue; // wait queue for usb transactions concerning this device atomic_t active_urbs; // note all active urbs for this device atomic_t param_xmit_finished; // flag set when parameter read is finished purb_t param_urb; // URB structure for parameter read purb_t read_data; // pointer to read data urb u8 *pucReadBuffer[2]; // read data transfer buffer for toggle u16 wReadBufferLength; // *used* read buffer length purb_t write_data; // pointer to write data urb u8 *pucWriteBuffer; // buffer for to write data (OUT) u32 dwTelegramCount; // counter for telegrams PCAN_USB_TIME *pUSBtime; // ptr to PCAN_USB_TIME} USB_PORT;#endif // USB_SUPPORTtypedef struct pcandev{ struct list_head list; // link anchor for list of devices int nOpenPaths; // number of open paths linked to the device u16 wInitStep; // device specific init state int nMinor; // the associated minor char *type; // the literal type of the device, info only u16 wType; // (number type) to distinguish sp and epp #ifdef NETDEV_SUPPORT struct net_device *netdev; // reference to net device for AF_CAN #endif union { DONGLE_PORT dng; // private data of the various ports ISA_PORT isa; PCI_PORT pci; #ifdef PCCARD_SUPPORT PCCARD_PORT pccard; #endif #ifdef USB_SUPPORT USB_PORT usb; #endif } port; struct chn_props props; // various channel properties u8 (*readreg)(struct pcandev *dev, u8 port); // read a register void (*writereg)(struct pcandev *dev, u8 port, u8 data); // write a register int (*cleanup)(struct pcandev *dev); // cleanup the interface int (*open)(struct pcandev *dev); // called at open of a path int (*release)(struct pcandev *dev); // called at release of a path#ifndef NO_RT int (*req_irq)(struct rtdm_dev_context *context); // install the interrupt handler #else int (*req_irq)(struct pcandev *dev); // install the interrupt handler#endif void (*free_irq)(struct pcandev *dev); // release the interrupt int (*device_open)(struct pcandev *dev, u16 btr0btr1, u8 bExtended, u8 bListenOnly); // open the device itself void (*device_release)(struct pcandev *dev); // release the device itself#ifndef NO_RT int (*device_write)(struct pcandev *dev, struct pcanctx_rt *ctx); // write the device#else int (*device_write)(struct pcandev *dev); // write the device#endif #ifdef NETDEV_SUPPORT int (*netdevice_write)(struct pcandev *dev, struct can_frame *cf); // write the device (netdevice only) #endif wait_queue_head_t read_queue; // read process wait queue anchor wait_queue_head_t write_queue; // write process wait queue anchor u8 bExtended; // if 0, no extended frames are accepted int nLastError; // last error written int busStatus; // follows error status of CAN-Bus u32 dwErrorCounter; // counts all fatal errors u32 dwInterruptCounter; // counts all interrupts u16 wCANStatus; // status of CAN chip u16 wBTR0BTR1; // the persistent storage for BTR0 and BTR1 u8 ucCANMsgType; // the persistent storage for 11 or 29 bit identifier u8 ucListenOnly; // the persistent storage for listen-only mode u8 ucPhysicallyInstalled; // the device is PhysicallyInstalled u8 ucActivityState; // follow the state of a channel activity atomic_t DataSendReady; // !=0 if all data are send FIFO_MANAGER readFifo; // manages the read fifo FIFO_MANAGER writeFifo; // manages the write fifo TPCANRdMsg rMsg[READ_MESSAGE_COUNT]; // all read messages TPCANMsg wMsg[WRITE_MESSAGE_COUNT]; // all write messages void *filter; // a ID filter - currently associated to device} PCANDEV;#ifndef NO_RTstruct pcanctx_rt{ struct pcandev *dev; // pointer to related device u8 pcReadBuffer[READBUFFER_SIZE]; // buffer used in read() call u8 *pcReadPointer; // points into current read data rest int nReadRest; // rest of data left to read int nTotalReadCount; // for test only u8 pcWriteBuffer[WRITEBUFFER_SIZE]; // buffer used in write() call u8 *pcWritePointer; // work pointer into buffer int nWriteCount; rtdm_irq_t irq_handle; rtdm_event_t in_event; rtdm_event_t out_event; rtdm_event_t empty_event; rtdm_lock_t in_lock; // read mutual exclusion lock rtdm_lock_t out_lock; // write mutual exclusion lock rtdm_lock_t sja_lock; // sja mutual exclusion lock unsigned int irq; // the associated irq level};#elsetypedef struct fileobj{ struct pcandev *dev; // pointer to related device u8 pcReadBuffer[READBUFFER_SIZE]; // buffer used in read() call u8 *pcReadPointer; // points into current read data rest int nReadRest; // rest of data left to read int nTotalReadCount; // for test only u8 pcWriteBuffer[WRITEBUFFER_SIZE]; // buffer used in write() call u8 *pcWritePointer; // work pointer into buffer int nWriteCount; // count of written data bytes} FILEOBJ;#endiftypedef struct driverobj{ int nMajor; // the major number of Pcan interfaces u16 wDeviceCount; // count of found devices u16 wInitStep; // driver specific init state struct timeval sInitTime; // time in usec when init was called struct list_head devices; // base of list of devices u8 *szVersionString; // pointer to the driver version string #ifdef PCCARD_SUPPORT #ifndef LINUX_24 struct pcmcia_driver pccarddrv; // pccard driver structure #endif #endif #ifdef USB_SUPPORT struct usb_driver usbdrv; // usb driver structure #endif #ifdef UDEV_SUPPORT #ifdef PCI_SUPPORT struct pci_driver pci_drv; // pci driver structure #endif #ifdef ISA_SUPPORT struct device_driver legacy_driver_isa; // legacy platform driver #endif #ifdef DONGLE_SUPPORT struct device_driver legacy_driver_dongle; // legacy platform driver #endif #endif // UDEV_SUPPORT} DRIVEROBJ;#ifndef NO_RTtypedef struct rt_device{ struct list_head list; struct rtdm_device *device;} RT_DEVICE;#endif//----------------------------------------------------------------------------// the global driver objectextern struct driverobj pcan_drv;#ifndef NO_RTextern struct list_head device_list;#endif//----------------------------------------------------------------------------// exported functions - not to Linux kernel!u32 get_mtime(void); // request time in msec, fastvoid get_relative_time(struct timeval *tv, struct timeval *tr); // request time from drivers startvoid timeval2pcan(struct timeval *tv, u32 *msecs, u16 *usecs); // convert to pcan timevoid pcan_soft_init(struct pcandev *dev, char *szType, u16 wType);void buffer_dump(u8 *pucBuffer, u16 wLineCount);void frame2msg(struct can_frame *cf, TPCANMsg *msg);void msg2frame(struct can_frame *cf, TPCANMsg *msg);int pcan_chardev_rx(struct pcandev *dev, struct can_frame *cf, struct timeval *tv);void dev_unregister(void);void remove_dev_list(void);#endif // __PCAN_MAIN_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -