pcan_usb_pro.h revision f14e22435a27ef183bbfa78f77ad86644c0b354c
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#define PCAN_USBPRO_FCT_DRVLD_REQ_LEN 16 33 34/* PCAN_USBPRO_INFO_BL vendor request record type */ 35struct __packed pcan_usb_pro_blinfo { 36 u32 ctrl_type; 37 u8 version[4]; 38 u8 day; 39 u8 month; 40 u8 year; 41 u8 dummy; 42 u32 serial_num_hi; 43 u32 serial_num_lo; 44 u32 hw_type; 45 u32 hw_rev; 46}; 47 48/* PCAN_USBPRO_INFO_FW vendor request record type */ 49struct __packed pcan_usb_pro_fwinfo { 50 u32 ctrl_type; 51 u8 version[4]; 52 u8 day; 53 u8 month; 54 u8 year; 55 u8 dummy; 56 u32 fw_type; 57}; 58 59/* 60 * USB Command record types 61 */ 62#define PCAN_USBPRO_SETBTR 0x02 63#define PCAN_USBPRO_SETBUSACT 0x04 64#define PCAN_USBPRO_SETSILENT 0x05 65#define PCAN_USBPRO_SETFILTR 0x0a 66#define PCAN_USBPRO_SETTS 0x10 67#define PCAN_USBPRO_GETDEVID 0x12 68#define PCAN_USBPRO_SETLED 0x1C 69#define PCAN_USBPRO_RXMSG8 0x80 70#define PCAN_USBPRO_RXMSG4 0x81 71#define PCAN_USBPRO_RXMSG0 0x82 72#define PCAN_USBPRO_RXRTR 0x83 73#define PCAN_USBPRO_RXSTATUS 0x84 74#define PCAN_USBPRO_RXTS 0x85 75#define PCAN_USBPRO_TXMSG8 0x41 76#define PCAN_USBPRO_TXMSG4 0x42 77#define PCAN_USBPRO_TXMSG0 0x43 78 79/* record structures */ 80struct __packed pcan_usb_pro_btr { 81 u8 data_type; 82 u8 channel; 83 u16 dummy; 84 u32 CCBT; 85}; 86 87struct __packed pcan_usb_pro_busact { 88 u8 data_type; 89 u8 channel; 90 u16 onoff; 91}; 92 93struct __packed pcan_usb_pro_silent { 94 u8 data_type; 95 u8 channel; 96 u16 onoff; 97}; 98 99struct __packed pcan_usb_pro_filter { 100 u8 data_type; 101 u8 dummy; 102 u16 filter_mode; 103}; 104 105struct __packed pcan_usb_pro_setts { 106 u8 data_type; 107 u8 dummy; 108 u16 mode; 109}; 110 111struct __packed pcan_usb_pro_devid { 112 u8 data_type; 113 u8 channel; 114 u16 dummy; 115 u32 serial_num; 116}; 117 118struct __packed pcan_usb_pro_setled { 119 u8 data_type; 120 u8 channel; 121 u16 mode; 122 u32 timeout; 123}; 124 125struct __packed pcan_usb_pro_rxmsg { 126 u8 data_type; 127 u8 client; 128 u8 flags; 129 u8 len; 130 u32 ts32; 131 u32 id; 132 133 u8 data[8]; 134}; 135 136#define PCAN_USBPRO_STATUS_ERROR 0x0001 137#define PCAN_USBPRO_STATUS_BUS 0x0002 138#define PCAN_USBPRO_STATUS_OVERRUN 0x0004 139#define PCAN_USBPRO_STATUS_QOVERRUN 0x0008 140 141struct __packed pcan_usb_pro_rxstatus { 142 u8 data_type; 143 u8 channel; 144 u16 status; 145 u32 ts32; 146 u32 err_frm; 147}; 148 149struct __packed pcan_usb_pro_rxts { 150 u8 data_type; 151 u8 dummy[3]; 152 u32 ts64[2]; 153}; 154 155struct __packed pcan_usb_pro_txmsg { 156 u8 data_type; 157 u8 client; 158 u8 flags; 159 u8 len; 160 u32 id; 161 u8 data[8]; 162}; 163 164union pcan_usb_pro_rec { 165 u8 data_type; 166 struct pcan_usb_pro_btr btr; 167 struct pcan_usb_pro_busact bus_act; 168 struct pcan_usb_pro_silent silent_mode; 169 struct pcan_usb_pro_filter filter_mode; 170 struct pcan_usb_pro_setts ts; 171 struct pcan_usb_pro_devid dev_id; 172 struct pcan_usb_pro_setled set_led; 173 struct pcan_usb_pro_rxmsg rx_msg; 174 struct pcan_usb_pro_rxstatus rx_status; 175 struct pcan_usb_pro_rxts rx_ts; 176 struct pcan_usb_pro_txmsg tx_msg; 177}; 178 179#endif 180