Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
pcan_usb_core.h
Go to the documentation of this file.
1 /*
2  * CAN driver for PEAK System USB adapters
3  * Derived from the PCAN project file driver/src/pcan_usb_core.c
4  *
5  * Copyright (C) 2003-2010 PEAK System-Technik GmbH
6  * Copyright (C) 2010-2012 Stephane Grosjean <[email protected]>
7  *
8  * Many thanks to Klaus Hitschler <[email protected]>
9  *
10  * This program is free software; you can redistribute it and/or modify it
11  * under the terms of the GNU General Public License as published
12  * by the Free Software Foundation; version 2 of the License.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  */
19 #ifndef PCAN_USB_CORE_H
20 #define PCAN_USB_CORE_H
21 
22 /* PEAK-System vendor id. */
23 #define PCAN_USB_VENDOR_ID 0x0c72
24 
25 /* supported device ids. */
26 #define PCAN_USB_PRODUCT_ID 0x000c
27 #define PCAN_USBPRO_PRODUCT_ID 0x000d
28 
29 #define PCAN_USB_DRIVER_NAME "peak_usb"
30 
31 /* number of urbs that are submitted for rx/tx per channel */
32 #define PCAN_USB_MAX_RX_URBS 4
33 #define PCAN_USB_MAX_TX_URBS 10
34 
35 /* usb adapters maximum channels per usb interface */
36 #define PCAN_USB_MAX_CHANNEL 2
37 
38 /* maximum length of the usb commands sent to/received from the devices */
39 #define PCAN_USB_MAX_CMD_LEN 32
40 
41 struct peak_usb_device;
42 
43 /* PEAK-System USB adapter descriptor */
45  char *name;
47  struct can_clock clock;
49  unsigned int ctrl_count;
50 
52 
59  struct can_bittiming *bt);
62  int (*dev_decode_buf)(struct peak_usb_device *dev, struct urb *urb);
64  u8 *obuf, size_t *size);
68  u8 *buf);
75 
79 };
80 
81 extern struct peak_usb_adapter pcan_usb;
82 extern struct peak_usb_adapter pcan_usb_pro;
83 
84 struct peak_time_ref {
85  struct timeval tv_host_0, tv_host;
90 };
91 
96  struct urb *urb;
97 };
98 
99 #define PCAN_USB_STATE_CONNECTED 0x00000001
100 #define PCAN_USB_STATE_STARTED 0x00000002
101 
102 /* PEAK-System USB device */
104  struct can_priv can;
106  unsigned int ctrl_idx;
109 
111 
112  struct usb_device *udev;
114 
116  struct usb_anchor tx_submitted;
118 
120  struct usb_anchor rx_submitted;
121 
124 
127 
129 
132 };
133 
134 void pcan_dump_mem(char *prompt, void *p, int l);
135 
136 /* common timestamp management */
137 void peak_usb_init_time_ref(struct peak_time_ref *time_ref,
138  struct peak_usb_adapter *adapter);
139 void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
140 void peak_usb_set_ts_now(struct peak_time_ref *time_ref, u32 ts_now);
141 void peak_usb_get_ts_tv(struct peak_time_ref *time_ref, u32 ts,
142  struct timeval *tv);
143 
144 void peak_usb_async_complete(struct urb *urb);
146 #endif