RTEMS
6.1-rc2
Loading...
Searching...
No Matches
bsps
include
grlib
occan.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
9
/*
10
* COPYRIGHT (c) 2007.
11
* Cobham Gaisler AB.
12
*
13
* Redistribution and use in source and binary forms, with or without
14
* modification, are permitted provided that the following conditions
15
* are met:
16
* 1. Redistributions of source code must retain the above copyright
17
* notice, this list of conditions and the following disclaimer.
18
* 2. Redistributions in binary form must reproduce the above copyright
19
* notice, this list of conditions and the following disclaimer in the
20
* documentation and/or other materials provided with the distribution.
21
*
22
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*/
34
35
#ifndef __OCCAN_DRIVER_H__
36
#define __OCCAN_DRIVER_H__
37
38
#ifdef __cplusplus
39
extern
"C"
{
40
#endif
41
42
/* CAN MESSAGE */
43
typedef
struct
{
44
char
extended;
/* 1= Extended Frame (29-bit id), 0= STD Frame (11-bit id) */
45
char
rtr;
/* RTR - Remote Transmission Request */
46
char
sshot;
/* single shot */
47
unsigned
char
len;
48
unsigned
char
data[8];
49
unsigned
int
id;
50
}
CANMsg
;
51
52
typedef
struct
{
53
/* tx/rx stats */
54
unsigned
int
rx_msgs;
55
unsigned
int
tx_msgs;
56
57
/* Error Interrupt counters */
58
unsigned
int
err_warn;
59
unsigned
int
err_dovr;
60
unsigned
int
err_errp;
61
unsigned
int
err_arb;
62
unsigned
int
err_bus;
63
64
/**** BUS ERRORS (err_arb) ****/
65
66
/* ALC 4-0 */
67
unsigned
int
err_arb_bitnum[32];
/* At what bit arbitration is lost */
68
69
/******************************/
70
71
/**** BUS ERRORS (err_bus) ****/
72
73
/* ECC 7-6 */
74
unsigned
int
err_bus_bit;
/* Bit error */
75
unsigned
int
err_bus_form;
/* Form Error */
76
unsigned
int
err_bus_stuff;
/* Stuff Error */
77
unsigned
int
err_bus_other;
/* Other Error */
78
79
/* ECC 5 */
80
unsigned
int
err_bus_rx;
/* Errors during Reception */
81
unsigned
int
err_bus_tx;
/* Errors during Transmission */
82
83
/* ECC 4:0 */
84
unsigned
int
err_bus_segs[32];
/* Segment (Where in frame error occured)
85
* See OCCAN_SEG_* defines for indexes
86
*/
87
88
/******************************/
89
90
91
/* total number of interrupts */
92
unsigned
int
ints;
93
94
/* software monitoring hw errors */
95
unsigned
int
tx_buf_error;
96
97
/* Software fifo overrun */
98
unsigned
int
rx_sw_dovr;
99
100
}
occan_stats
;
101
102
/* indexes into occan_stats.err_bus_segs[index] */
103
#define OCCAN_SEG_ID28 0x02
/* ID field bit 28:21 */
104
#define OCCAN_SEG_ID20 0x06
/* ID field bit 20:18 */
105
#define OCCAN_SEG_ID17 0x07
/* ID field bit 17:13 */
106
#define OCCAN_SEG_ID12 0x0f
/* ID field bit 12:5 */
107
#define OCCAN_SEG_ID4 0x0e
/* ID field bit 4:0 */
108
109
#define OCCAN_SEG_START 0x03
/* Start of Frame */
110
#define OCCAN_SEG_SRTR 0x04
/* Bit SRTR */
111
#define OCCAN_SEG_IDE 0x05
/* Bit IDE */
112
#define OCCAN_SEG_RTR 0x0c
/* Bit RTR */
113
#define OCCAN_SEG_RSV0 0x09
/* Reserved bit 0 */
114
#define OCCAN_SEG_RSV1 0x0d
/* Reserved bit 1 */
115
116
#define OCCAN_SEG_DLEN 0x0b
/* Data Length code */
117
#define OCCAN_SEG_DFIELD 0x0a
/* Data Field */
118
119
#define OCCAN_SEG_CRC_SEQ 0x08
/* CRC Sequence */
120
#define OCCAN_SEG_CRC_DELIM 0x18
/* CRC Delimiter */
121
122
#define OCCAN_SEG_ACK_SLOT 0x19
/* Acknowledge slot */
123
#define OCCAN_SEG_ACK_DELIM 0x1b
/* Acknowledge delimiter */
124
#define OCCAN_SEG_EOF 0x1a
/* End Of Frame */
125
#define OCCAN_SEG_INTERMISSION 0x12
/* Intermission */
126
#define OCCAN_SEG_ACT_ERR 0x11
/* Active error flag */
127
#define OCCAN_SEG_PASS_ERR 0x16
/* Passive error flag */
128
#define OCCAN_SEG_DOMINANT 0x13
/* Tolerate dominant bits */
129
#define OCCAN_SEG_EDELIM 0x17
/* Error delimiter */
130
#define OCCAN_SEG_OVERLOAD 0x1c
/* overload flag */
131
132
133
#define CANMSG_OPT_RTR 0x40
/* RTR Frame */
134
#define CANMSG_OPT_EXTENDED 0x80
/* Exteneded frame */
135
#define CANMSG_OPT_SSHOT 0x01
/* Single Shot, no retry */
136
137
#define OCCAN_IOC_START 1
138
#define OCCAN_IOC_STOP 2
139
140
#define OCCAN_IOC_GET_CONF 3
141
#define OCCAN_IOC_GET_STATS 4
142
#define OCCAN_IOC_GET_STATUS 5
143
144
#define OCCAN_IOC_SET_SPEED 6
145
#define OCCAN_IOC_SPEED_AUTO 7
146
#define OCCAN_IOC_SET_LINK 8
147
#define OCCAN_IOC_SET_FILTER 9
148
#define OCCAN_IOC_SET_BLK_MODE 10
149
#define OCCAN_IOC_SET_BUFLEN 11
150
#define OCCAN_IOC_SET_BTRS 12
151
152
153
struct
occan_afilter
{
154
unsigned
char
code
[4];
155
unsigned
char
mask[4];
156
int
single_mode;
157
};
158
159
#define OCCAN_STATUS_RESET 0x01
160
#define OCCAN_STATUS_OVERRUN 0x02
161
#define OCCAN_STATUS_WARN 0x04
162
#define OCCAN_STATUS_ERR_PASSIVE 0x08
163
#define OCCAN_STATUS_ERR_BUSOFF 0x10
164
#define OCCAN_STATUS_QUEUE_ERROR 0x80
165
166
#define OCCAN_BLK_MODE_RX 0x1
167
#define OCCAN_BLK_MODE_TX 0x2
168
169
void
occan_register_drv (
void
);
170
171
172
#define OCCAN_SPEED_500K 500000
173
#define OCCAN_SPEED_250K 250000
174
#define OCCAN_SPEED_125K 125000
175
#define OCCAN_SPEED_75K 75000
176
#define OCCAN_SPEED_50K 50000
177
#define OCCAN_SPEED_25K 25000
178
#define OCCAN_SPEED_10K 10000
179
180
#ifdef __cplusplus
181
}
182
#endif
183
184
#endif
CANMsg
Definition:
grcan.h:142
code
Definition:
inftrees.h:24
occan_afilter
Definition:
occan.h:153
occan_stats
Definition:
occan.h:52
Generated by
1.9.6