EE445M RTOS
Taken at the University of Texas Spring 2015
can.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // can.h - Defines and Macros for the CAN controller.
4 //
5 // Copyright (c) 2006-2014 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Redistribution and use in source and binary forms, with or without
9 // modification, are permitted provided that the following conditions
10 // are met:
11 //
12 // Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 //
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
18 // distribution.
19 //
20 // Neither the name of Texas Instruments Incorporated nor the names of
21 // its contributors may be used to endorse or promote products derived
22 // from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __DRIVERLIB_CAN_H__
41 #define __DRIVERLIB_CAN_H__
42 
43 //*****************************************************************************
44 //
47 //
48 //*****************************************************************************
49 
50 //*****************************************************************************
51 //
52 // If building with a C++ compiler, make all of the definitions in this header
53 // have a C binding.
54 //
55 //*****************************************************************************
56 #ifdef __cplusplus
57 extern "C"
58 {
59 #endif
60 
61 //*****************************************************************************
62 //
63 // Miscellaneous defines for Message ID Types
64 //
65 //*****************************************************************************
66 
67 //*****************************************************************************
68 //
69 // These are the flags used by the tCANMsgObject.ui32Flags value when calling
70 // the CANMessageSet() and CANMessageGet() functions.
71 //
72 //*****************************************************************************
73 
74 //
76 //
77 #define MSG_OBJ_TX_INT_ENABLE 0x00000001
78 
79 //
81 //
82 #define MSG_OBJ_RX_INT_ENABLE 0x00000002
83 
84 //
86 //
87 #define MSG_OBJ_EXTENDED_ID 0x00000004
88 
89 //
92 //
93 #define MSG_OBJ_USE_ID_FILTER 0x00000008
94 
95 //
97 //
98 #define MSG_OBJ_NEW_DATA 0x00000080
99 
100 //
103 //
104 #define MSG_OBJ_DATA_LOST 0x00000100
105 
106 //
110 //
111 #define MSG_OBJ_USE_DIR_FILTER (0x00000010 | MSG_OBJ_USE_ID_FILTER)
112 
113 //
117 //
118 #define MSG_OBJ_USE_EXT_FILTER (0x00000020 | MSG_OBJ_USE_ID_FILTER)
119 
120 //
122 //
123 #define MSG_OBJ_REMOTE_FRAME 0x00000040
124 
125 //
128 //
129 #define MSG_OBJ_FIFO 0x00000200
130 
131 //
133 //
134 #define MSG_OBJ_NO_FLAGS 0x00000000
135 
136 //*****************************************************************************
137 //
140 //
141 //*****************************************************************************
142 #define MSG_OBJ_STATUS_MASK (MSG_OBJ_NEW_DATA | MSG_OBJ_DATA_LOST)
143 
144 //*****************************************************************************
145 //
148 //
149 //*****************************************************************************
150 typedef struct
151 {
152  //
154  //
155  uint32_t ui32MsgID;
156 
157  //
159  //
160  uint32_t ui32MsgIDMask;
161 
162  //
165  //
166  uint32_t ui32Flags;
167 
168  //
170  //
171  uint32_t ui32MsgLen;
172 
173  //
175  //
176  uint8_t *pui8MsgData;
177 }
179 
180 //*****************************************************************************
181 //
185 //
186 //*****************************************************************************
187 typedef struct
188 {
189  //
193  //
195 
196  //
199  //
200  uint32_t ui32Phase2Seg;
201 
202  //
205  //
206  uint32_t ui32SJW;
207 
208  //
211  //
213 }
215 
216 //*****************************************************************************
217 //
220 //
221 //*****************************************************************************
222 typedef enum
223 {
224  //
226  //
228 
229  //
231  //
233 }
235 
236 //*****************************************************************************
237 //
240 //
241 //*****************************************************************************
242 typedef enum
243 {
244  //
246  //
248 
249  //
252  //
254 
255  //
257  //
259 
260  //
262  //
264 }
265 tCANStsReg;
266 
267 //*****************************************************************************
268 //
269 // These definitions are used to specify interrupt sources to CANIntEnable()
270 // and CANIntDisable().
271 //
272 //*****************************************************************************
273 //
276 //
277 #define CAN_INT_ERROR 0x00000008
278 
279 //
282 //
283 #define CAN_INT_STATUS 0x00000004
284 
285 //
289 //
290 #define CAN_INT_MASTER 0x00000002
291 
292 //*****************************************************************************
293 //
296 //
297 //*****************************************************************************
298 typedef enum
299 {
300  //
302  //
304 
305  //
307  //
309 
310  //
312  //
314 
315  //
317  //
319 
320  //
322  //
324 }
326 
327 //*****************************************************************************
328 //
329 // The following enumeration contains all error or status indicators that can
330 // be returned when calling the CANStatusGet() function.
331 //
332 //*****************************************************************************
333 //
335 //
336 #define CAN_STATUS_BUS_OFF 0x00000080
337 
338 //
340 //
341 #define CAN_STATUS_EWARN 0x00000040
342 
343 //
345 //
346 #define CAN_STATUS_EPASS 0x00000020
347 
348 //
350 //
351 #define CAN_STATUS_RXOK 0x00000010
352 
353 //
356 //
357 #define CAN_STATUS_TXOK 0x00000008
358 
359 //
361 //
362 #define CAN_STATUS_LEC_MSK 0x00000007
363 
364 //
366 //
367 #define CAN_STATUS_LEC_NONE 0x00000000
368 
369 //
371 //
372 #define CAN_STATUS_LEC_STUFF 0x00000001
373 
374 //
376 //
377 #define CAN_STATUS_LEC_FORM 0x00000002
378 
379 //
381 //
382 #define CAN_STATUS_LEC_ACK 0x00000003
383 
384 //
386 //
387 #define CAN_STATUS_LEC_BIT1 0x00000004
388 
389 //
391 //
392 #define CAN_STATUS_LEC_BIT0 0x00000005
393 
394 //
396 //
397 #define CAN_STATUS_LEC_CRC 0x00000006
398 
399 //
401 //
402 #define CAN_STATUS_LEC_MASK 0x00000007
403 
404 //*****************************************************************************
405 //
406 // Close the Doxygen group.
408 //
409 //*****************************************************************************
410 
411 //*****************************************************************************
412 //
413 // API Function prototypes
414 //
415 //*****************************************************************************
416 extern void CANBitTimingGet(uint32_t ui32Base, tCANBitClkParms *psClkParms);
417 extern void CANBitTimingSet(uint32_t ui32Base, tCANBitClkParms *psClkParms);
418 extern uint32_t CANBitRateSet(uint32_t ui32Base, uint32_t ui32SourceClock,
419  uint32_t ui32BitRate);
420 extern void CANDisable(uint32_t ui32Base);
421 extern void CANEnable(uint32_t ui32Base);
422 extern bool CANErrCntrGet(uint32_t ui32Base, uint32_t *pui32RxCount,
423  uint32_t *pui32TxCount);
424 extern void CANInit(uint32_t ui32Base);
425 extern void CANIntClear(uint32_t ui32Base, uint32_t ui32IntClr);
426 extern void CANIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
427 extern void CANIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
428 extern void CANIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
429 extern uint32_t CANIntStatus(uint32_t ui32Base, tCANIntStsReg eIntStsReg);
430 extern void CANIntUnregister(uint32_t ui32Base);
431 extern void CANMessageClear(uint32_t ui32Base, uint32_t ui32ObjID);
432 extern void CANMessageGet(uint32_t ui32Base, uint32_t ui32ObjID,
433  tCANMsgObject *psMsgObject, bool bClrPendingInt);
434 extern void CANMessageSet(uint32_t ui32Base, uint32_t ui32ObjID,
435  tCANMsgObject *psMsgObject, tMsgObjType eMsgType);
436 extern bool CANRetryGet(uint32_t ui32Base);
437 extern void CANRetrySet(uint32_t ui32Base, bool bAutoRetry);
438 extern uint32_t CANStatusGet(uint32_t ui32Base, tCANStsReg eStatusReg);
439 
440 //*****************************************************************************
441 //
442 // Mark the end of the C bindings section for C++ compilers.
443 //
444 //*****************************************************************************
445 #ifdef __cplusplus
446 }
447 #endif
448 
449 #endif // __DRIVERLIB_CAN_H__
void CANEnable(uint32_t ui32Base)
Definition: can.c:424
uint32_t ui32Phase2Seg
Definition: can.h:200
void CANIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: can.c:944
bool CANRetryGet(uint32_t ui32Base)
Definition: can.c:1193
uint32_t ui32MsgLen
This value is the number of bytes of data in the message object.
Definition: can.h:171
void CANMessageGet(uint32_t ui32Base, uint32_t ui32ObjID, tCANMsgObject *psMsgObject, bool bClrPendingInt)
Definition: can.c:1838
uint32_t ui32MsgID
The CAN message identifier used for 11 or 29 bit identifiers.
Definition: can.h:155
uint32_t ui32SyncPropPhase1Seg
Definition: can.h:194
void CANInit(uint32_t ui32Base)
Definition: can.c:325
uint8_t * pui8MsgData
This is a pointer to the message object's data.
Definition: can.h:176
void CANBitTimingGet(uint32_t ui32Base, tCANBitClkParms *psClkParms)
Definition: can.c:483
tCANIntStsReg
Definition: can.h:222
void CANIntUnregister(uint32_t ui32Base)
Definition: can.c:855
uint32_t ui32QuantumPrescaler
Definition: can.h:212
void CANBitTimingSet(uint32_t ui32Base, tCANBitClkParms *psClkParms)
Definition: can.c:713
uint32_t ui32MsgIDMask
The message identifier mask used when identifier filtering is enabled.
Definition: can.h:160
Receive message object.
Definition: can.h:313
uint32_t ui32SJW
Definition: can.h:206
Transmit remote request message object.
Definition: can.h:308
void CANDisable(uint32_t ui32Base)
Definition: can.c:453
bool CANErrCntrGet(uint32_t ui32Base, uint32_t *pui32RxCount, uint32_t *pui32TxCount)
Definition: can.c:1364
uint32_t CANStatusGet(uint32_t ui32Base, tCANStsReg eStatusReg)
Definition: can.c:1276
Transmit message object.
Definition: can.h:303
tCANStsReg
Definition: can.h:242
void CANMessageSet(uint32_t ui32Base, uint32_t ui32ObjID, tCANMsgObject *psMsgObject, tMsgObjType eMsgType)
Definition: can.c:1477
void CANIntRegister(uint32_t ui32Base, void(*pfnHandler)(void))
Definition: can.c:813
uint32_t ui32Flags
Definition: can.h:166
uint32_t CANBitRateSet(uint32_t ui32Base, uint32_t ui32SourceClock, uint32_t ui32BitRate)
Definition: can.c:554
void CANIntClear(uint32_t ui32Base, uint32_t ui32IntClr)
Definition: can.c:1084
Read the full CAN controller status.
Definition: can.h:247
void CANRetrySet(uint32_t ui32Base, bool bAutoRetry)
Definition: can.c:1144
Read the CAN interrupt status information.
Definition: can.h:227
Read the full 32-bit mask of message objects that are enabled.
Definition: can.h:263
Read a message object's interrupt status.
Definition: can.h:232
uint32_t CANIntStatus(uint32_t ui32Base, tCANIntStsReg eIntStsReg)
Definition: can.c:995
Read the full 32-bit mask of message objects with new data available.
Definition: can.h:258
Receive remote request message object.
Definition: can.h:318
tMsgObjType
Definition: can.h:298
Remote frame receive remote, with auto-transmit message object.
Definition: can.h:323
void CANIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
Definition: can.c:912
void CANMessageClear(uint32_t ui32Base, uint32_t ui32ObjID)
Definition: can.c:2083