source: pacpussensors/trunk/CanGateway/driver/kvaser/linux/canevt.h@ 109

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

add include files for kvaser

File size: 8.9 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#ifndef _CANEVT_H_
54#define _CANEVT_H_
55
56#include <pshpack1.h>
57
58#define CANEVT_NO_COMMAND 0
59
60 // Events
61#define CANEVT_RECEIVE_MSG 1
62#define CANEVT_STATISTIC_STD 2
63#define CANEVT_STATISTIC_EXT 3
64#define CANEVT_CHIP_STATE 4
65#define CANEVT_CLOCK_OVERFLOW 5
66#define CANEVT_TRIGGER 6
67#define CANEVT_ERROR 7
68#define CANEVT_TIMER 8
69#define CANEVT_TRANSCEIVER 9
70
71 // Commands
72#define CANEVT_TRANSMIT_MSG 10
73#define CANEVT_SET_TIMER 11
74#define CANEVT_RESET_CLOCK 12
75#define CANEVT_INIT_CHIP 13
76#define CANEVT_START_CHIP 14
77#define CANEVT_STOP_CHIP 15
78#define CANEVT_RESET_CHIP 16
79#define CANEVT_SET_ACCEPTANCE 17
80//#define CANEVT_SET_DRIVERMODE 18
81#define CANEVT_GET_STATISTIC 19
82#define CANEVT_GET_CHIP_STATE 20
83#define CANEVT_SET_OUTPUT_MODE 21
84#define CANEVT_FUNCTION 22
85#define CANEVT_GET_TRANSCEIVER 23
86#define CANEVT_GET_TRANSCEIVER_RESP 24
87#define CANEVT_SET_TRANSCEIVER 25
88// 26, 27, 28 reserved
89#define CANEVT_INIT_HARDWARE 29
90#define CANEVT_EXIT_HARDWARE 30
91#define CANEVT_READ_CLOCK 31
92
93// TODO: Change to 64 for CAN FD
94#define MAX_MSG_LEN 8
95#define EXT_MSG 0x80000000 // signs an extended identifier
96
97#define MSGFLAG_ERROR_FRAME 0x01 // Msg is a bus error
98#define MSGFLAG_OVERRUN 0x02 // Msgs following this has been lost
99#define MSGFLAG_NERR 0x04 // NERR active during this msg
100#define MSGFLAG_WAKEUP 0x08 // Msg rcv'd in wakeup mode
101#define MSGFLAG_REMOTE_FRAME 0x10 // Msg is a remote frame
102#define MSGFLAG_RESERVED_1 0x20 // Reserved for future usage
103#define MSGFLAG_TX 0x40 // TX acknowledge
104#define MSGFLAG_TXRQ 0x80 // TX request
105
106typedef struct {
107 unsigned long id;
108 unsigned char flags;
109 unsigned char dlc;
110 unsigned char data[MAX_MSG_LEN];
111} CanEventMessage;
112
113
114#define CHIPSTAT_BUSOFF 0x01
115#define CHIPSTAT_ERROR_PASSIVE 0x02
116#define CHIPSTAT_ERROR_WARNING 0x04
117#define CHIPSTAT_ERROR_ACTIVE 0x08
118
119typedef struct {
120 unsigned char busStatus;
121 unsigned char txErrorCounter;
122 unsigned char rxErrorCounter;
123} CanEventChipState;
124
125typedef struct {
126 unsigned long stdData;
127 unsigned long stdRemote;
128 unsigned long errFrame;
129 unsigned short busLoad; // 0.00-100.00%
130} CanEventStatisticsStd;
131
132typedef struct {
133 unsigned long extData;
134 unsigned long extRemote;
135 unsigned long ovrFrame;
136} CanEventStatisticsExt;
137
138typedef struct {
139 unsigned char code; // qqq
140} CanEventErrorCode;
141
142//------------------------------------------------------------------------------
143// commands
144//------------------------------------------------------------------------------
145
146typedef struct {
147 unsigned long code;
148 unsigned long mask;
149} CanEventAcceptanceFilter;
150
151typedef struct {
152 unsigned char mode;
153} CanEventDriverMode;
154
155typedef struct {
156 unsigned long rate;
157} CanEventSetTimer;
158
159typedef struct {
160 unsigned char level;
161} CanEventSetDebugLevel;
162
163#define OUTPUT_MODE_SILENT 0
164#define OUTPUT_MODE_NORMAL 1
165
166typedef struct {
167 unsigned char mode;
168} CanEventSetOutputMode;
169
170typedef struct {
171 unsigned char code;
172} CanEventFunction;
173
174// The following definitions are copied from lapcmds.h !!
175
176#define TRANSCEIVER_EVENT_ERROR 1
177#define TRANSCEIVER_EVENT_CHANGED 2
178
179// event
180#define TRANSCEIVER_EVENT_NONE 0
181#define TRANSCEIVER_EVENT_NERR 1
182#define TRANSCEIVER_EVENT_REMOVED 2
183#define TRANSCEIVER_EVENT_DETECTED 3
184
185// type
186#define TRANSCEIVER_TYPE_NONE 0
187#define TRANSCEIVER_TYPE_251 1
188#define TRANSCEIVER_TYPE_252 2
189#define TRANSCEIVER_TYPE_DNOPTO 3
190#define TRANSCEIVER_TYPE_W210 4
191#define TRANSCEIVER_TYPE_SWC_PROTO 5 // Prototype. Driver may latch-up.
192#define TRANSCEIVER_TYPE_SWC 6
193
194
195// lineMode
196#define TRANSCEIVER_LINEMODE_NA 0
197#define TRANSCEIVER_LINEMODE_TWO_LINE 1
198#define TRANSCEIVER_LINEMODE_CAN_H 2
199#define TRANSCEIVER_LINEMODE_CAN_L 3
200#define TRANSCEIVER_LINEMODE_SWC_SLEEP 4 // SWC Sleep Mode.
201#define TRANSCEIVER_LINEMODE_SWC_NORMAL 5 // SWC Normal Mode.
202#define TRANSCEIVER_LINEMODE_SWC_FAST 6 // SWC High-Speed Mode.
203#define TRANSCEIVER_LINEMODE_SWC_WAKEUP 7 // SWC Wakeup Mode.
204#define TRANSCEIVER_LINEMODE_SLEEP 8
205#define TRANSCEIVER_LINEMODE_NORMAL 9
206
207
208// resNet
209#define TRANSCEIVER_RESNET_NA 0
210#define TRANSCEIVER_RESNET_MASTER 1
211#define TRANSCEIVER_RESNET_MASTER_STBY 2
212#define TRANSCEIVER_RESNET_SLAVE 3
213
214typedef struct {
215 unsigned char event; // TRANSCEIVER_EVENT_xxx
216} CanEventTransceiver;
217
218typedef struct {
219 unsigned char type; // TRANSCEIVER_TYPE_xxx
220 unsigned char lineMode; // TRANSCEIVER_LINEMODE_xxx
221 unsigned char resNet; // TRANSCEIVER_RESNET_xxx
222} CanEventGetTransceiverResponse;
223
224typedef struct {
225 unsigned char type; // TRANSCEIVER_TYPE_xxx
226 unsigned char lineMode; // TRANSCEIVER_LINEMODE_xxx
227 unsigned char resNet; // TRANSCEIVER_RESNET_xxx
228} CanEventSetTransceiver;
229
230
231typedef union {
232 CanEventMessage canEventMessage;
233 CanEventChipState canEventChipState;
234 CanEventStatisticsStd canEventStatisticsStd;
235 CanEventStatisticsExt canEventStatisticsExt;
236 CanEventErrorCode canEventErrorCode;
237 CanEventAcceptanceFilter canEventAcceptanceFilter;
238 CanEventDriverMode canEventDriverMode;
239 CanEventSetTimer canEventSetTimer;
240 CanEventSetDebugLevel canEventSetDebugLevel;
241 CanEventSetOutputMode canEventSetOutputMode;
242 CanEventFunction canEventFunction;
243 CanEventTransceiver canEventTransceiver;
244 CanEventGetTransceiverResponse canEventGetTransceiverResponse;
245 CanEventSetTransceiver canEventSetTransceiver;
246} CanEventUnion;
247
248
249typedef struct {
250 unsigned char tag;
251 unsigned char chanIndex;
252 unsigned char _internal1;
253 unsigned char _internal2;
254 unsigned long timeStamp;
255 CanEventUnion x;
256} CanEvent, *PCanEvent;
257
258
259#include <poppack.h>
260
261#endif
262
Note: See TracBrowser for help on using the repository browser.