1 /* 2 * CAN driver for PEAK System PCAN-USB Pro adapter 3 * Derived from the PCAN project file driver/src/pcan_usbpro_fw.h 4 * 5 * Copyright (C) 2003-2011 PEAK System-Technik GmbH 6 * Copyright (C) 2011-2012 Stephane Grosjean <s.grosjean@peak-system.com> 7 * 8 * This program is free software; you can redistribute it and/or modify it 9 * under the terms of the GNU General Public License as published 10 * by the Free Software Foundation; version 2 of the License. 11 * 12 * This program is distributed in the hope that it will be useful, but 13 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * General Public License for more details. 16 */ 17 #ifndef PCAN_USB_PRO_H 18 #define PCAN_USB_PRO_H 19 20 /* 21 * USB Vendor request data types 22 */ 23 #define PCAN_USBPRO_REQ_INFO 0 24 #define PCAN_USBPRO_REQ_FCT 2 25 26 /* Vendor Request value for XXX_INFO */ 27 #define PCAN_USBPRO_INFO_BL 0 28 #define PCAN_USBPRO_INFO_FW 1 29 30 /* Vendor Request value for XXX_FCT */ 31 #define PCAN_USBPRO_FCT_DRVLD 5 /* tell device driver is loaded */ 32 33 /* PCAN_USBPRO_INFO_BL vendor request record type */ 34 struct __packed pcan_usb_pro_blinfo { 35 u32 ctrl_type; 36 u8 version[4]; 37 u8 day; 38 u8 month; 39 u8 year; 40 u8 dummy; 41 u32 serial_num_hi; 42 u32 serial_num_lo; 43 u32 hw_type; 44 u32 hw_rev; 45 }; 46 47 /* PCAN_USBPRO_INFO_FW vendor request record type */ 48 struct __packed pcan_usb_pro_fwinfo { 49 u32 ctrl_type; 50 u8 version[4]; 51 u8 day; 52 u8 month; 53 u8 year; 54 u8 dummy; 55 u32 fw_type; 56 }; 57 58 /* 59 * USB Command record types 60 */ 61 #define PCAN_USBPRO_SETBTR 0x02 62 #define PCAN_USBPRO_SETBUSACT 0x04 63 #define PCAN_USBPRO_SETSILENT 0x05 64 #define PCAN_USBPRO_SETFILTR 0x0a 65 #define PCAN_USBPRO_SETTS 0x10 66 #define PCAN_USBPRO_GETDEVID 0x12 67 #define PCAN_USBPRO_SETLED 0x1C 68 #define PCAN_USBPRO_RXMSG8 0x80 69 #define PCAN_USBPRO_RXMSG4 0x81 70 #define PCAN_USBPRO_RXMSG0 0x82 71 #define PCAN_USBPRO_RXRTR 0x83 72 #define PCAN_USBPRO_RXSTATUS 0x84 73 #define PCAN_USBPRO_RXTS 0x85 74 #define PCAN_USBPRO_TXMSG8 0x41 75 #define PCAN_USBPRO_TXMSG4 0x42 76 #define PCAN_USBPRO_TXMSG0 0x43 77 78 /* record structures */ 79 struct __packed pcan_usb_pro_btr { 80 u8 data_type; 81 u8 channel; 82 u16 dummy; 83 u32 CCBT; 84 }; 85 86 struct __packed pcan_usb_pro_busact { 87 u8 data_type; 88 u8 channel; 89 u16 onoff; 90 }; 91 92 struct __packed pcan_usb_pro_silent { 93 u8 data_type; 94 u8 channel; 95 u16 onoff; 96 }; 97 98 struct __packed pcan_usb_pro_filter { 99 u8 data_type; 100 u8 dummy; 101 u16 filter_mode; 102 }; 103 104 struct __packed pcan_usb_pro_setts { 105 u8 data_type; 106 u8 dummy; 107 u16 mode; 108 }; 109 110 struct __packed pcan_usb_pro_devid { 111 u8 data_type; 112 u8 channel; 113 u16 dummy; 114 u32 serial_num; 115 }; 116 117 struct __packed pcan_usb_pro_setled { 118 u8 data_type; 119 u8 channel; 120 u16 mode; 121 u32 timeout; 122 }; 123 124 struct __packed pcan_usb_pro_rxmsg { 125 u8 data_type; 126 u8 client; 127 u8 flags; 128 u8 len; 129 u32 ts32; 130 u32 id; 131 132 u8 data[8]; 133 }; 134 135 #define PCAN_USBPRO_STATUS_ERROR 0x0001 136 #define PCAN_USBPRO_STATUS_BUS 0x0002 137 #define PCAN_USBPRO_STATUS_OVERRUN 0x0004 138 #define PCAN_USBPRO_STATUS_QOVERRUN 0x0008 139 140 struct __packed pcan_usb_pro_rxstatus { 141 u8 data_type; 142 u8 channel; 143 u16 status; 144 u32 ts32; 145 u32 err_frm; 146 }; 147 148 struct __packed pcan_usb_pro_rxts { 149 u8 data_type; 150 u8 dummy[3]; 151 u32 ts64[2]; 152 }; 153 154 struct __packed pcan_usb_pro_txmsg { 155 u8 data_type; 156 u8 client; 157 u8 flags; 158 u8 len; 159 u32 id; 160 u8 data[8]; 161 }; 162 163 union pcan_usb_pro_rec { 164 u8 data_type; 165 struct pcan_usb_pro_btr btr; 166 struct pcan_usb_pro_busact bus_act; 167 struct pcan_usb_pro_silent silent_mode; 168 struct pcan_usb_pro_filter filter_mode; 169 struct pcan_usb_pro_setts ts; 170 struct pcan_usb_pro_devid dev_id; 171 struct pcan_usb_pro_setled set_led; 172 struct pcan_usb_pro_rxmsg rx_msg; 173 struct pcan_usb_pro_rxstatus rx_status; 174 struct pcan_usb_pro_rxts rx_ts; 175 struct pcan_usb_pro_txmsg tx_msg; 176 }; 177 178 #endif 179