source: pacpussensors/trunk/CanGateway/driver/kvaser/linux/vcanevt.h@ 107

Last change on this file since 107 was 97, checked in by DHERBOMEZ Gérald, 9 years ago

add include files for kvaser

File size: 9.0 KB
Line 
1/*
2** Copyright 2012 by Kvaser AB, Mölndal, Sweden
3** http://www.kvaser.com
4**
5** This software is dual licensed under the following two licenses:
6** BSD-new and GPLv2. You may use either one. See the included
7** COPYING file for details.
8**
9** License: BSD-new
10** ===============================================================================
11** Redistribution and use in source and binary forms, with or without
12** modification, are permitted provided that the following conditions are met:
13** * Redistributions of source code must retain the above copyright
14** notice, this list of conditions and the following disclaimer.
15** * Redistributions in binary form must reproduce the above copyright
16** notice, this list of conditions and the following disclaimer in the
17** documentation and/or other materials provided with the distribution.
18** * Neither the name of the <organization> nor the
19** names of its contributors may be used to endorse or promote products
20** derived from this software without specific prior written permission.
21**
22** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
26** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32**
33**
34** License: GPLv2
35** ===============================================================================
36** This program is free software; you can redistribute it and/or
37** modify it under the terms of the GNU General Public License
38** as published by the Free Software Foundation; either version 2
39** of the License, or (at your option) any later version.
40**
41** This program is distributed in the hope that it will be useful,
42** but WITHOUT ANY WARRANTY; without even the implied warranty of
43** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44** GNU General Public License for more details.
45**
46** You should have received a copy of the GNU General Public License
47** along with this program; if not, write to the Free Software
48** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
49**
50** ---------------------------------------------------------------------------
51**/
52
53/* vcanevt.h: Defines for CAN driver event
54 * (CAN messages, timer events, statistic, ...)
55*/
56
57#ifndef VCANEVT_H
58#define VCANEVT_H
59
60# if !defined(__KERNEL__)
61# include <stdint.h>
62# else
63# include <linux/types.h>
64# endif
65
66/***************************************************************************/
67
68#include <pshpack1.h>
69
70/***************************************************************************/
71
72enum e_vevent_type {
73 V_NO_COMMAND = 1,
74 V_RECEIVE_MSG = 2,
75 V_STATISTIC_STD = 4,
76 V_STATISTIC_EXT = 8,
77 V_CHIP_STATE = 16,
78 V_TRANSCEIVER = 32,
79 V_TIMER = 64,
80 V_TRANSMIT_MSG = 128,
81 };
82
83typedef unsigned char VeventTag;
84
85
86/* Structure for V_RECEIVE_MSG, V_TRANSMIT_MSG */
87
88/* Message flags */
89#define MAX_MSG_LEN 128
90#define EXT_MSG 0x80000000 // signs an extended identifier
91#define VCAN_EXT_MSG_ID EXT_MSG
92
93#define VCAN_MSG_FLAG_ERROR_FRAME 0x01
94#define VCAN_MSG_FLAG_OVERRUN 0x02 /* Overrun in Driver or CAN Controller */
95 /* special case: OVERRUN combined with TIMER
96 * means the 32 bit timer has overrun
97 */
98#define VCAN_MSG_FLAG_NERR 0x04 /* Line Error on Lowspeed */
99#define VCAN_MSG_FLAG_WAKEUP 0x08 /* High Voltage Message on Single Wire CAN */
100#define VCAN_MSG_FLAG_REMOTE_FRAME 0x10
101#define VCAN_MSG_FLAG_RESERVED_1 0x20
102#define VCAN_MSG_FLAG_TX_NOTIFY 0x40 /* Message Transmitted */
103#define VCAN_MSG_FLAG_TXACK 0x40 /* Message Transmitted */
104#define VCAN_MSG_FLAG_TX_START 0x80 /* Transmit Message stored into Controller */
105#define VCAN_MSG_FLAG_TXRQ 0x80 /* Transmit Message stored into Controller */
106
107#define VCAN_MSG_FLAG_EDL 0x100 /* Extended Data Length (CAN FD) */
108#define VCAN_MSG_FLAG_BRS 0x200 /* Bit Rate Switch (CAN FD) */
109#define VCAN_MSG_FLAG_ESI 0x400 /* Error Status Indication (CAN FD) */
110
111
112
113struct s_vcan_msg { /* 14 Bytes */
114 uint32_t id;
115 unsigned short int flags;
116 unsigned char dlc;
117 unsigned char data[MAX_MSG_LEN];
118};
119
120
121/* Structure for V_CHIP_STATE */
122
123#define CHIPSTAT_BUSOFF 0x01
124#define CHIPSTAT_ERROR_PASSIVE 0x02
125#define CHIPSTAT_ERROR_WARNING 0x04
126#define CHIPSTAT_ERROR_ACTIVE 0x08
127
128struct s_vcan_chip_state {
129 unsigned char busStatus;
130 unsigned char txErrorCounter;
131 unsigned char rxErrorCounter;
132 };
133
134
135/* Structure for V_STATISTIC_STD */
136struct s_vcan_statistic_std {
137 uint32_t stdData;
138 uint32_t stdRemote;
139 uint32_t errFrame;
140 unsigned short busLoad; // 0.00-100.00%
141 };
142
143
144/* Structure for V_STATISTIC_EXT */
145struct s_vcan_statistic_ext {
146 uint32_t extData;
147 uint32_t extRemote;
148 uint32_t ovrFrame;
149 };
150
151
152/* Structure for V_ERROR */
153struct s_vcan_error {
154 unsigned char code;
155 };
156
157
158/* Structure for SET_OUTPUT_MODE */
159#define OUTPUT_MODE_SILENT 0
160#define OUTPUT_MODE_NORMAL 1
161
162
163/* Transceiver modes */
164#define TRANSCEIVER_EVENT_ERROR 1
165#define TRANSCEIVER_EVENT_CHANGED 2
166
167
168
169/* Transceiver modes */
170#define VCAN_TRANSCEIVER_LINEMODE_NA 0 // Not Affected/Not available.
171#define VCAN_TRANSCEIVER_LINEMODE_TWO_LINE 1 // W210 two-line.
172#define VCAN_TRANSCEIVER_LINEMODE_CAN_H 2 // W210 single-line CAN_H
173#define VCAN_TRANSCEIVER_LINEMODE_CAN_L 3 // W210 single-line CAN_L
174#define VCAN_TRANSCEIVER_LINEMODE_SWC_SLEEP 4 // SWC Sleep Mode.
175#define VCAN_TRANSCEIVER_LINEMODE_SWC_NORMAL 5 // SWC Normal Mode.
176#define VCAN_TRANSCEIVER_LINEMODE_SWC_FAST 6 // SWC High-Speed Mode.
177#define VCAN_TRANSCEIVER_LINEMODE_SWC_WAKEUP 7 // SWC Wakeup Mode.
178#define VCAN_TRANSCEIVER_LINEMODE_SLEEP 8 // Sleep mode for those supporting it.
179#define VCAN_TRANSCEIVER_LINEMODE_NORMAL 9 // Normal mode (the inverse of sleep mode) for those supporting it.
180#define VCAN_TRANSCEIVER_LINEMODE_STDBY 10 // Standby for those who support it
181#define VCAN_TRANSCEIVER_LINEMODE_TT_CAN_H 11 // Truck & Trailer: operating mode single wire using CAN high
182#define VCAN_TRANSCEIVER_LINEMODE_TT_CAN_L 12 // Truck & Trailer: operating mode single wire using CAN low
183#define VCAN_TRANSCEIVER_LINEMODE_OEM1 13 // Reserved for OEM apps
184#define VCAN_TRANSCEIVER_LINEMODE_OEM2 14 // Reserved for OEM apps
185#define VCAN_TRANSCEIVER_LINEMODE_OEM3 15 // Reserved for OEM apps
186#define VCAN_TRANSCEIVER_LINEMODE_OEM4 16 // Reserved for OEM apps
187
188
189#define VCAN_TRANSCEIVER_RESNET_NA 0
190#define VCAN_TRANSCEIVER_RESNET_MASTER 1
191#define VCAN_TRANSCEIVER_RESNET_MASTER_STBY 2
192#define VCAN_TRANSCEIVER_RESNET_SLAVE 3
193
194
195/* VCAN_EVENT structure */
196union s_vcan_tag_data {
197 struct s_vcan_msg msg;
198 struct s_vcan_chip_state chipState;
199 struct s_vcan_statistic_std statisticStd;
200 struct s_vcan_statistic_ext statisticExt;
201 struct s_vcan_error error;
202 };
203
204
205/* Event type definition */
206struct s_vcan_event {
207 VeventTag tag; // 1
208 unsigned char chanIndex; // 1
209 unsigned char transId; // 1
210 unsigned char unused_1; // 1 internal use only !!!!
211 uint32_t timeStamp; // 4
212 union s_vcan_tag_data
213 tagData; // 14 Bytes (_VMessage)
214 };
215 // --------
216 // 22 Bytes
217
218typedef struct s_vcan_event VCAN_EVENT, Vevent, *PVevent;
219
220
221typedef struct s_can_msg {
222 VeventTag tag;
223 unsigned char channel_index;
224 unsigned char user_data;
225 unsigned char unused_1;
226 uint32_t timestamp;
227 uint32_t id;
228 unsigned short int flags;
229 unsigned char length;
230 unsigned char data [MAX_MSG_LEN];
231} CAN_MSG;
232
233
234/*****************************************************************************/
235
236#include <poppack.h>
237
238/*****************************************************************************/
239
240#endif /* VCANEVT_H */
241
Note: See TracBrowser for help on using the repository browser.