pcan_usb_pro.h 3.7 KB

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