pcan_usb_pro.h 3.7 KB

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