PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
Main Page
Modules
Data Structures
Files
File List
Globals
can.h
Go to the documentation of this file.
1
/*******************************************************************************
2
* Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3
*
4
* This software is owned and published by:
5
* Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6
*
7
* BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8
* BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9
*
10
* This software contains source code for use with Spansion
11
* components. This software is licensed by Spansion to be adapted only
12
* for use in systems utilizing Spansion components. Spansion shall not be
13
* responsible for misuse or illegal use of this software for devices not
14
* supported herein. Spansion is providing this software "AS IS" and will
15
* not be responsible for issues arising from incorrect user implementation
16
* of the software.
17
*
18
* SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19
* REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20
* ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21
* WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22
* WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23
* WARRANTY OF NONINFRINGEMENT.
24
* SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25
* NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27
* LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28
* INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29
* INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30
* SAVINGS OR PROFITS,
31
* EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32
* YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33
* INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34
* FROM, THE SOFTWARE.
35
*
36
* This software may be replicated in part or whole for the licensed use,
37
* with the restriction that this Disclaimer and Copyright notice must be
38
* included with each copy of this software, whether used in part or whole,
39
* at all times.
40
*/
41
/******************************************************************************/
51
#ifndef __CAN_H__
52
#define __CAN_H__
53
54
/******************************************************************************/
55
/* Include files */
56
/******************************************************************************/
57
#include "
pdl.h
"
58
59
#if (defined(PDL_PERIPHERAL_CAN_ACTIVE))
60
61
/* C binding of definitions if building with C++ compiler */
62
#ifdef __cplusplus
63
extern
"C"
64
{
65
#endif
66
102
103
/******************************************************************************
104
* Global definitions
105
******************************************************************************/
106
107
#define CAN0 (*((volatile stc_cann_t *) FM4_CAN0_BASE))
108
#define CAN1 (*((volatile stc_cann_t *) FM4_CAN1_BASE))
109
#define CANPRE (*((volatile uint8_t *) FM4_CANPRES_BASE))
110
112
#define CAN_MESSAGE_DATA_BUFFER_SIZE 8
113
115
#define CAN_MESSAGE_BUFFER_COUNT 32
116
118
#define CAN_BITRATE_TSEG1_MIN 2
119
120
#define CAN_BITRATE_TSEG1_MAX 16
121
123
#define CAN_BITRATE_TSEG2_MIN 1
124
125
#define CAN_BITRATE_TSEG2_MAX 8
126
127
129
#define CAN_BITRATE_SYNC_JUMP_WIDTH_MIN 1
130
131
#define CAN_BITRATE_SYNC_JUMP_WIDTH_MAX 4
132
134
#define CAN_BITRATE_PRESCALER_MIN 1
135
136
#define CAN_BITRATE_PRESCALER_MAX 64
137
139
#define CAN_MAX_CLK 16000000
140
141
/******************************************************************************
142
* Global type definitions
143
******************************************************************************/
144
149
typedef
struct
stc_can_ctrlr
150
{
151
__IO
uint16_t
INIT
: 1;
152
__IO
uint16_t
IE
: 1;
153
__IO
uint16_t
SIE
: 1;
154
__IO
uint16_t
EIE
: 1;
155
uint16_t
RESERVED1
: 1;
156
__IO
uint16_t
DAR
: 1;
157
__IO
uint16_t
CCE
: 1;
158
__IO
uint16_t
TEST
: 1;
159
}
stc_can_ctrlr_t
;
160
165
typedef
struct
stc_can_statr
166
{
167
__IO
uint16_t
LEC
: 3;
168
__IO
uint16_t
TXOK
: 1;
169
__IO
uint16_t
RXOK
: 1;
170
__IO
uint16_t
EPASS
: 1;
171
__IO
uint16_t
EWARN
: 1;
172
__IO
uint16_t
BOFF
: 1;
173
}
stc_can_statr_t
;
174
179
typedef
struct
stc_can_errcnt
180
{
181
__IO
uint16_t
TEC0
: 1;
182
__IO
uint16_t
TEC1
: 1;
183
__IO
uint16_t
TEC2
: 1;
184
__IO
uint16_t
TEC3
: 1;
185
__IO
uint16_t
TEC4
: 1;
186
__IO
uint16_t
TEC5
: 1;
187
__IO
uint16_t
TEC6
: 1;
188
__IO
uint16_t
TEC7
: 1;
189
__IO
uint16_t
REC0
: 1;
190
__IO
uint16_t
REC1
: 1;
191
__IO
uint16_t
REC2
: 1;
192
__IO
uint16_t
REC3
: 1;
193
__IO
uint16_t
REC4
: 1;
194
__IO
uint16_t
REC5
: 1;
195
__IO
uint16_t
REC6
: 1;
196
__IO
uint16_t
RP
: 1;
197
}
stc_can_errcnt_t
;
198
203
typedef
struct
stc_can_intr
204
{
205
__IO
uint16_t
INTID0
: 1;
206
__IO
uint16_t
INTID1
: 1;
207
__IO
uint16_t
INTID2
: 1;
208
__IO
uint16_t
INTID3
: 1;
209
__IO
uint16_t
INTID4
: 1;
210
__IO
uint16_t
INTID5
: 1;
211
__IO
uint16_t
INTID6
: 1;
212
__IO
uint16_t
INTID7
: 1;
213
__IO
uint16_t
INTID8
: 1;
214
__IO
uint16_t
INTID9
: 1;
215
__IO
uint16_t
INTID10
: 1;
216
__IO
uint16_t
INTID11
: 1;
217
__IO
uint16_t
INTID12
: 1;
218
__IO
uint16_t
INTID13
: 1;
219
__IO
uint16_t
INTID14
: 1;
220
__IO
uint16_t
INTID15
: 1;
221
}
stc_can_intr_t
;
222
227
typedef
struct
stc_can_testr
228
{
229
uint16_t
RESERVED1
: 2;
230
__IO
uint16_t
BASIC
: 1;
231
__IO
uint16_t
SILENT
: 1;
232
__IO
uint16_t
LBACK
: 1;
233
__IO
uint16_t
TX0
: 1;
234
__IO
uint16_t
TX1
: 1;
235
__IO
uint16_t
RX
: 1;
236
}
stc_can_testr_t
;
237
242
typedef
struct
stc_can_brper
243
{
244
__IO
uint16_t
BRPE0
: 1;
245
__IO
uint16_t
BRPE1
: 1;
246
__IO
uint16_t
BRPE2
: 1;
247
__IO
uint16_t
BRPE3
: 1;
248
}
stc_can_brper_t
;
249
254
typedef
struct
stc_can_ifncreq
255
{
256
uint16_t
RESERVED1
: 15;
257
__IO
uint16_t
BUSY
: 1;
258
}
stc_can_ifncreq_t
;
259
264
typedef
struct
stc_can_ifncmsk
265
{
266
__IO
uint16_t
DATAB
: 1;
267
__IO
uint16_t
DATAA
: 1;
268
__IO
uint16_t
NEWDAT
: 1;
269
__IO
uint16_t
CIP
: 1;
270
__IO
uint16_t
CONTROL
: 1;
271
__IO
uint16_t
ARB
: 1;
272
__IO
uint16_t
MASK
: 1;
273
__IO
uint16_t
WRRD
: 1;
274
}
stc_can_ifncmsk_t
;
275
280
typedef
struct
stc_can_ifnmsk
281
{
282
__IO
uint32_t
MSK
: 29;
283
uint32_t
RESERVED1
: 1;
284
__IO
uint32_t
MDIR
: 1;
285
__IO
uint32_t
MXTD
: 1;
286
}
stc_can_ifnmsk_t
;
287
292
typedef
struct
stc_can_ifnmsk2
293
{
294
uint16_t
RESERVED1
: 14;
295
__IO
uint16_t
MDIR
: 1;
296
__IO
uint16_t
MXTD
: 1;
297
}
stc_can_ifnmsk2_t
;
298
303
typedef
struct
stc_can_ifnarb
304
{
305
__IO
uint32_t
ID
: 29;
306
__IO
uint32_t
DIR
: 1;
307
__IO
uint32_t
XTD
: 1;
308
__IO
uint32_t
MSGVAL
: 1;
309
}
stc_can_ifnarb_t
;
310
315
typedef
struct
stc_can_ifnarb2
316
{
317
uint16_t
RESERVED1
: 13;
318
__IO
uint16_t
DIR
: 1;
319
__IO
uint16_t
XTD
: 1;
320
__IO
uint16_t
MSGVAL
: 1;
321
}
stc_can_ifnarb2_t
;
322
327
typedef
struct
stc_can_ifnmctr
328
{
329
__IO
uint16_t
DLC
: 4;
330
uint16_t
RESERVED1
: 3;
331
__IO
uint16_t
EOB
: 1;
332
__IO
uint16_t
TXRQST
: 1;
333
__IO
uint16_t
RMTEN
: 1;
334
__IO
uint16_t
RXIE
: 1;
335
__IO
uint16_t
TXIE
: 1;
336
__IO
uint16_t
UMASK
: 1;
337
__IO
uint16_t
INTPND
: 1;
338
__IO
uint16_t
MSGLST
: 1;
339
__IO
uint16_t
NEWDAT
: 1;
340
}
stc_can_ifnmctr_t
;
341
346
typedef
struct
stc_can_btr
347
{
348
__IO
uint16_t
BRP
: 6;
349
__IO
uint16_t
SJW
: 2;
350
__IO
uint16_t
TSEG1
: 4;
351
__IO
uint16_t
TSEG2
: 3;
352
}
stc_can_btr_t
;
353
358
typedef
struct
stc_can_treqr
359
{
360
__IO
uint32_t
TXRQST1
: 1;
361
__IO
uint32_t
TXRQST2
: 1;
362
__IO
uint32_t
TXRQST3
: 1;
363
__IO
uint32_t
TXRQST4
: 1;
364
__IO
uint32_t
TXRQST5
: 1;
365
__IO
uint32_t
TXRQST6
: 1;
366
__IO
uint32_t
TXRQST7
: 1;
367
__IO
uint32_t
TXRQST8
: 1;
368
__IO
uint32_t
TXRQST9
: 1;
369
__IO
uint32_t
TXRQST10
: 1;
370
__IO
uint32_t
TXRQST11
: 1;
371
__IO
uint32_t
TXRQST12
: 1;
372
__IO
uint32_t
TXRQST13
: 1;
373
__IO
uint32_t
TXRQST14
: 1;
374
__IO
uint32_t
TXRQST15
: 1;
375
__IO
uint32_t
TXRQST16
: 1;
376
__IO
uint32_t
TXRQST17
: 1;
377
__IO
uint32_t
TXRQST18
: 1;
378
__IO
uint32_t
TXRQST19
: 1;
379
__IO
uint32_t
TXRQST20
: 1;
380
__IO
uint32_t
TXRQST21
: 1;
381
__IO
uint32_t
TXRQST22
: 1;
382
__IO
uint32_t
TXRQST23
: 1;
383
__IO
uint32_t
TXRQST24
: 1;
384
__IO
uint32_t
TXRQST25
: 1;
385
__IO
uint32_t
TXRQST26
: 1;
386
__IO
uint32_t
TXRQST27
: 1;
387
__IO
uint32_t
TXRQST28
: 1;
388
__IO
uint32_t
TXRQST29
: 1;
389
__IO
uint32_t
TXRQST30
: 1;
390
__IO
uint32_t
TXRQST31
: 1;
391
__IO
uint32_t
TXRQST32
: 1;
392
}
stc_can_treqr_t
;
393
398
typedef
struct
stc_can_treqr1
399
{
400
__IO
uint16_t
TXRQST1
: 1;
401
__IO
uint16_t
TXRQST2
: 1;
402
__IO
uint16_t
TXRQST3
: 1;
403
__IO
uint16_t
TXRQST4
: 1;
404
__IO
uint16_t
TXRQST5
: 1;
405
__IO
uint16_t
TXRQST6
: 1;
406
__IO
uint16_t
TXRQST7
: 1;
407
__IO
uint16_t
TXRQST8
: 1;
408
__IO
uint16_t
TXRQST9
: 1;
409
__IO
uint16_t
TXRQST10
: 1;
410
__IO
uint16_t
TXRQST11
: 1;
411
__IO
uint16_t
TXRQST12
: 1;
412
__IO
uint16_t
TXRQST13
: 1;
413
__IO
uint16_t
TXRQST14
: 1;
414
__IO
uint16_t
TXRQST15
: 1;
415
__IO
uint16_t
TXRQST16
: 1;
416
}
stc_can_treqr1_t
;
417
422
typedef
struct
stc_can_treqr2
423
{
424
__IO
uint16_t
TXRQST17
: 1;
425
__IO
uint16_t
TXRQST18
: 1;
426
__IO
uint16_t
TXRQST19
: 1;
427
__IO
uint16_t
TXRQST20
: 1;
428
__IO
uint16_t
TXRQST21
: 1;
429
__IO
uint16_t
TXRQST22
: 1;
430
__IO
uint16_t
TXRQST23
: 1;
431
__IO
uint16_t
TXRQST24
: 1;
432
__IO
uint16_t
TXRQST25
: 1;
433
__IO
uint16_t
TXRQST26
: 1;
434
__IO
uint16_t
TXRQST27
: 1;
435
__IO
uint16_t
TXRQST28
: 1;
436
__IO
uint16_t
TXRQST29
: 1;
437
__IO
uint16_t
TXRQST30
: 1;
438
__IO
uint16_t
TXRQST31
: 1;
439
__IO
uint16_t
TXRQST32
: 1;
440
}
stc_can_treqr2_t
;
441
446
typedef
struct
stc_can_newdt
447
{
448
__IO
uint32_t
NEWDAT1
: 1;
449
__IO
uint32_t
NEWDAT2
: 1;
450
__IO
uint32_t
NEWDAT3
: 1;
451
__IO
uint32_t
NEWDAT4
: 1;
452
__IO
uint32_t
NEWDAT5
: 1;
453
__IO
uint32_t
NEWDAT6
: 1;
454
__IO
uint32_t
NEWDAT7
: 1;
455
__IO
uint32_t
NEWDAT8
: 1;
456
__IO
uint32_t
NEWDAT9
: 1;
457
__IO
uint32_t
NEWDAT10
: 1;
458
__IO
uint32_t
NEWDAT11
: 1;
459
__IO
uint32_t
NEWDAT12
: 1;
460
__IO
uint32_t
NEWDAT13
: 1;
461
__IO
uint32_t
NEWDAT14
: 1;
462
__IO
uint32_t
NEWDAT15
: 1;
463
__IO
uint32_t
NEWDAT16
: 1;
464
__IO
uint32_t
NEWDAT17
: 1;
465
__IO
uint32_t
NEWDAT18
: 1;
466
__IO
uint32_t
NEWDAT19
: 1;
467
__IO
uint32_t
NEWDAT20
: 1;
468
__IO
uint32_t
NEWDAT21
: 1;
469
__IO
uint32_t
NEWDAT22
: 1;
470
__IO
uint32_t
NEWDAT23
: 1;
471
__IO
uint32_t
NEWDAT24
: 1;
472
__IO
uint32_t
NEWDAT25
: 1;
473
__IO
uint32_t
NEWDAT26
: 1;
474
__IO
uint32_t
NEWDAT27
: 1;
475
__IO
uint32_t
NEWDAT28
: 1;
476
__IO
uint32_t
NEWDAT29
: 1;
477
__IO
uint32_t
NEWDAT30
: 1;
478
__IO
uint32_t
NEWDAT31
: 1;
479
__IO
uint32_t
NEWDAT32
: 1;
480
}
stc_can_newdt_t
;
481
486
typedef
struct
stc_can_newdt1
487
{
488
__IO
uint16_t
NEWDAT1
: 1;
489
__IO
uint16_t
NEWDAT2
: 1;
490
__IO
uint16_t
NEWDAT3
: 1;
491
__IO
uint16_t
NEWDAT4
: 1;
492
__IO
uint16_t
NEWDAT5
: 1;
493
__IO
uint16_t
NEWDAT6
: 1;
494
__IO
uint16_t
NEWDAT7
: 1;
495
__IO
uint16_t
NEWDAT8
: 1;
496
__IO
uint16_t
NEWDAT9
: 1;
497
__IO
uint16_t
NEWDAT10
: 1;
498
__IO
uint16_t
NEWDAT11
: 1;
499
__IO
uint16_t
NEWDAT12
: 1;
500
__IO
uint16_t
NEWDAT13
: 1;
501
__IO
uint16_t
NEWDAT14
: 1;
502
__IO
uint16_t
NEWDAT15
: 1;
503
__IO
uint16_t
NEWDAT16
: 1;
504
}
stc_can_newdt1_t
;
505
510
typedef
struct
stc_can_intpnd
511
{
512
__IO
uint32_t
INTPND1
: 1;
513
__IO
uint32_t
INTPND2
: 1;
514
__IO
uint32_t
INTPND3
: 1;
515
__IO
uint32_t
INTPND4
: 1;
516
__IO
uint32_t
INTPND5
: 1;
517
__IO
uint32_t
INTPND6
: 1;
518
__IO
uint32_t
INTPND7
: 1;
519
__IO
uint32_t
INTPND8
: 1;
520
__IO
uint32_t
INTPND9
: 1;
521
__IO
uint32_t
INTPND10
: 1;
522
__IO
uint32_t
INTPND11
: 1;
523
__IO
uint32_t
INTPND12
: 1;
524
__IO
uint32_t
INTPND13
: 1;
525
__IO
uint32_t
INTPND14
: 1;
526
__IO
uint32_t
INTPND15
: 1;
527
__IO
uint32_t
INTPND16
: 1;
528
__IO
uint32_t
INTPND17
: 1;
529
__IO
uint32_t
INTPND18
: 1;
530
__IO
uint32_t
INTPND19
: 1;
531
__IO
uint32_t
INTPND20
: 1;
532
__IO
uint32_t
INTPND21
: 1;
533
__IO
uint32_t
INTPND22
: 1;
534
__IO
uint32_t
INTPND23
: 1;
535
__IO
uint32_t
INTPND24
: 1;
536
__IO
uint32_t
INTPND25
: 1;
537
__IO
uint32_t
INTPND26
: 1;
538
__IO
uint32_t
INTPND27
: 1;
539
__IO
uint32_t
INTPND28
: 1;
540
__IO
uint32_t
INTPND29
: 1;
541
__IO
uint32_t
INTPND30
: 1;
542
__IO
uint32_t
INTPND31
: 1;
543
__IO
uint32_t
INTPND32
: 1;
544
}
stc_can_intpnd_t
;
545
546
551
typedef
struct
stc_can_intpnd1
552
{
553
__IO
uint16_t
INTPND1
: 1;
554
__IO
uint16_t
INTPND2
: 1;
555
__IO
uint16_t
INTPND3
: 1;
556
__IO
uint16_t
INTPND4
: 1;
557
__IO
uint16_t
INTPND5
: 1;
558
__IO
uint16_t
INTPND6
: 1;
559
__IO
uint16_t
INTPND7
: 1;
560
__IO
uint16_t
INTPND8
: 1;
561
__IO
uint16_t
INTPND9
: 1;
562
__IO
uint16_t
INTPND10
: 1;
563
__IO
uint16_t
INTPND11
: 1;
564
__IO
uint16_t
INTPND12
: 1;
565
__IO
uint16_t
INTPND13
: 1;
566
__IO
uint16_t
INTPND14
: 1;
567
__IO
uint16_t
INTPND15
: 1;
568
__IO
uint16_t
INTPND16
: 1;
569
}
stc_can_intpnd1_t
;
570
571
576
typedef
struct
stc_can_intpnd2
577
{
578
__IO
uint16_t
INTPND17
: 1;
579
__IO
uint16_t
INTPND18
: 1;
580
__IO
uint16_t
INTPND19
: 1;
581
__IO
uint16_t
INTPND20
: 1;
582
__IO
uint16_t
INTPND21
: 1;
583
__IO
uint16_t
INTPND22
: 1;
584
__IO
uint16_t
INTPND23
: 1;
585
__IO
uint16_t
INTPND24
: 1;
586
__IO
uint16_t
INTPND25
: 1;
587
__IO
uint16_t
INTPND26
: 1;
588
__IO
uint16_t
INTPND27
: 1;
589
__IO
uint16_t
INTPND28
: 1;
590
__IO
uint16_t
INTPND29
: 1;
591
__IO
uint16_t
INTPND30
: 1;
592
__IO
uint16_t
INTPND31
: 1;
593
__IO
uint16_t
INTPND32
: 1;
594
}
stc_can_intpnd2_t
;
595
600
typedef
struct
stc_can_msgval
601
{
602
__IO
uint32_t
MSGVAL1
: 1;
603
__IO
uint32_t
MSGVAL2
: 1;
604
__IO
uint32_t
MSGVAL3
: 1;
605
__IO
uint32_t
MSGVAL4
: 1;
606
__IO
uint32_t
MSGVAL5
: 1;
607
__IO
uint32_t
MSGVAL6
: 1;
608
__IO
uint32_t
MSGVAL7
: 1;
609
__IO
uint32_t
MSGVAL8
: 1;
610
__IO
uint32_t
MSGVAL9
: 1;
611
__IO
uint32_t
MSGVAL10
: 1;
612
__IO
uint32_t
MSGVAL11
: 1;
613
__IO
uint32_t
MSGVAL12
: 1;
614
__IO
uint32_t
MSGVAL13
: 1;
615
__IO
uint32_t
MSGVAL14
: 1;
616
__IO
uint32_t
MSGVAL15
: 1;
617
__IO
uint32_t
MSGVAL16
: 1;
618
__IO
uint32_t
MSGVAL17
: 1;
619
__IO
uint32_t
MSGVAL18
: 1;
620
__IO
uint32_t
MSGVAL19
: 1;
621
__IO
uint32_t
MSGVAL20
: 1;
622
__IO
uint32_t
MSGVAL21
: 1;
623
__IO
uint32_t
MSGVAL22
: 1;
624
__IO
uint32_t
MSGVAL23
: 1;
625
__IO
uint32_t
MSGVAL24
: 1;
626
__IO
uint32_t
MSGVAL25
: 1;
627
__IO
uint32_t
MSGVAL26
: 1;
628
__IO
uint32_t
MSGVAL27
: 1;
629
__IO
uint32_t
MSGVAL28
: 1;
630
__IO
uint32_t
MSGVAL29
: 1;
631
__IO
uint32_t
MSGVAL30
: 1;
632
__IO
uint32_t
MSGVAL31
: 1;
633
__IO
uint32_t
MSGVAL32
: 1;
634
}
stc_can_msgval_t
;
635
640
typedef
struct
stc_can_msgval1
641
{
642
__IO
uint16_t
MSGVAL1
: 1;
643
__IO
uint16_t
MSGVAL2
: 1;
644
__IO
uint16_t
MSGVAL3
: 1;
645
__IO
uint16_t
MSGVAL4
: 1;
646
__IO
uint16_t
MSGVAL5
: 1;
647
__IO
uint16_t
MSGVAL6
: 1;
648
__IO
uint16_t
MSGVAL7
: 1;
649
__IO
uint16_t
MSGVAL8
: 1;
650
__IO
uint16_t
MSGVAL9
: 1;
651
__IO
uint16_t
MSGVAL10
: 1;
652
__IO
uint16_t
MSGVAL11
: 1;
653
__IO
uint16_t
MSGVAL12
: 1;
654
__IO
uint16_t
MSGVAL13
: 1;
655
__IO
uint16_t
MSGVAL14
: 1;
656
__IO
uint16_t
MSGVAL15
: 1;
657
__IO
uint16_t
MSGVAL16
: 1;
658
}
stc_can_msgval1_t
;
659
664
typedef
struct
stc_can_msgval2
665
{
666
__IO
uint16_t
MSGVAL17
: 1;
667
__IO
uint16_t
MSGVAL18
: 1;
668
__IO
uint16_t
MSGVAL19
: 1;
669
__IO
uint16_t
MSGVAL20
: 1;
670
__IO
uint16_t
MSGVAL21
: 1;
671
__IO
uint16_t
MSGVAL22
: 1;
672
__IO
uint16_t
MSGVAL23
: 1;
673
__IO
uint16_t
MSGVAL24
: 1;
674
__IO
uint16_t
MSGVAL25
: 1;
675
__IO
uint16_t
MSGVAL26
: 1;
676
__IO
uint16_t
MSGVAL27
: 1;
677
__IO
uint16_t
MSGVAL28
: 1;
678
__IO
uint16_t
MSGVAL29
: 1;
679
__IO
uint16_t
MSGVAL30
: 1;
680
__IO
uint16_t
MSGVAL31
: 1;
681
__IO
uint16_t
MSGVAL32
: 1;
682
}
stc_can_msgval2_t
;
683
688
typedef
struct
stc_cann
689
{
690
union
{
691
__IO
uint16_t
CTRLR
;
692
stc_can_ctrlr_t
CTRLR_f
;
693
};
694
union
{
695
__IO
uint16_t
STATR
;
696
stc_can_statr_t
STATR_f
;
697
};
698
union
{
699
__IO
uint16_t
ERRCNT
;
700
stc_can_errcnt_t
ERRCNT_f
;
701
};
702
union
{
703
__IO
uint16_t
BTR
;
704
stc_can_btr_t
BTR_f
;
705
};
706
union
{
707
__IO
uint16_t
INTR
;
708
stc_can_intr_t
INTR_f
;
709
};
710
union
{
711
__IO
uint16_t
TESTR
;
712
stc_can_testr_t
TESTR_f
;
713
};
714
union
{
715
__IO
uint16_t
BRPER
;
716
stc_can_brper_t
BRPER_f
;
717
};
718
uint8_t
RESERVED0
[2];
719
union
{
720
__IO
uint16_t
IF1CREQ
;
721
stc_can_ifncreq_t
IF1CREQ_f
;
722
};
723
union
{
724
__IO
uint16_t
IF1CMSK
;
725
stc_can_ifncmsk_t
IF1CMSK_f
;
726
};
727
union
{
728
union
{
729
__IO
uint32_t
IF1MSK
;
730
stc_can_ifnmsk_t
IF1MSK_f
;
731
};
732
struct
{
733
__IO
uint16_t
IF1MSK1
;
734
union
{
735
__IO
uint16_t
IF1MSK2
;
736
stc_can_ifnmsk2_t
IF1MSK2_f
;
737
};
738
};
739
};
740
union
{
741
union
{
742
__IO
uint32_t
IF1ARB
;
743
stc_can_ifnarb_t
u32IF1ARB
;
744
};
745
struct
{
746
__IO
uint16_t
IF1ARB1
;
747
union
{
748
__IO
uint16_t
IF1ARB2
;
749
stc_can_ifnarb2_t
IF1ARB2_f
;
750
};
751
};
752
};
753
union
{
754
__IO
uint16_t
IF1MCTR
;
755
stc_can_ifnmctr_t
IF1MCTR_f
;
756
};
757
uint8_t
RESERVED1
[2];
758
union
{
759
__IO
uint32_t
IF1DTA_L
;
760
struct
{
761
__IO
uint16_t
IF1DTA1_L
;
762
__IO
uint16_t
IF1DTA2_L
;
763
};
764
};
765
union
{
766
__IO
uint32_t
IF1DTB_L
;
767
struct
{
768
__IO
uint16_t
IF1DTB1_L
;
769
__IO
uint16_t
IF1DTB2_L
;
770
};
771
};
772
uint8_t
RESERVED2
[8];
773
union
{
774
__IO
uint32_t
IF1DTA_B
;
775
struct
{
776
__IO
uint16_t
IF1DTA2_B
;
777
__IO
uint16_t
IF1DTA1_B
;
778
};
779
};
780
union
{
781
__IO
uint32_t
IF1DTB_B
;
782
struct
{
783
__IO
uint16_t
IF1DTB2_B
;
784
__IO
uint16_t
IF1DTB1_B
;
785
};
786
};
787
uint8_t
RESERVED3
[8];
788
union
{
789
__IO
uint16_t
IF2CREQ
;
790
stc_can_ifncreq_t
IF2CREQ_f
;
791
};
792
union
{
793
__IO
uint16_t
IF2CMSK
;
794
stc_can_ifncmsk_t
IF2CMSK_f
;
795
};
796
union
{
797
union
{
798
__IO
uint32_t
IF2MSK
;
799
stc_can_ifnmsk_t
IF2MSK_f
;
800
};
801
struct
{
802
__IO
uint16_t
IF2MSK1
;
803
union
{
804
__IO
uint16_t
IF2MSK2
;
805
stc_can_ifnmsk2_t
IF2MSK2_f
;
806
};
807
};
808
};
809
union
{
810
union
{
811
__IO
uint32_t
IF2ARB
;
812
stc_can_ifnarb_t
u32IF2ARB
;
813
};
814
struct
{
815
__IO
uint16_t
IF2ARB1
;
816
union
{
817
__IO
uint16_t
IF2ARB2
;
818
stc_can_ifnarb2_t
IF2ARB2_f
;
819
};
820
};
821
};
822
union
{
823
__IO
uint16_t
IF2MCTR
;
824
stc_can_ifnmctr_t
IF2MCTR_f
;
825
};
826
uint8_t
RESERVED4
[2];
827
union
{
828
__IO
uint32_t
IF2DTA_L
;
829
struct
{
830
__IO
uint16_t
IF2DTA1_L
;
831
__IO
uint16_t
IF2DTA2_L
;
832
};
833
};
834
union
{
835
__IO
uint32_t
IF2DTB_L
;
836
struct
{
837
__IO
uint16_t
IF2DTB1_L
;
838
__IO
uint16_t
IF2DTB2_L
;
839
};
840
};
841
uint8_t
RESERVED5
[8];
842
union
{
843
__IO
uint32_t
IF2DTA_B
;
844
struct
{
845
__IO
uint16_t
IF2DTA2_B
;
846
__IO
uint16_t
IF2DTA1_B
;
847
};
848
};
849
union
{
850
__IO
uint32_t
IF2DTB_B
;
851
struct
{
852
__IO
uint16_t
IF2DTB2_B
;
853
__IO
uint16_t
IF2DTB1_B
;
854
};
855
};
856
uint8_t
RESERVED6
[24];
857
union
{
858
union
{
859
__IO
uint32_t
TREQR
;
860
stc_can_treqr_t
TREQR_f
;
861
};
862
struct
{
863
union
{
864
__IO
uint16_t
TREQR1
;
865
stc_can_treqr1_t
TREQR1_f
;
866
};
867
union
{
868
__IO
uint16_t
TREQR2
;
869
stc_can_treqr2_t
TREQR2_f
;
870
};
871
};
872
};
873
uint8_t
RESERVED7
[12];
874
union
{
875
union
{
876
__IO
uint32_t
NEWDT
;
877
stc_can_newdt_t
NEWDT_f
;
878
};
879
struct
{
880
union
{
881
__IO
uint16_t
NEWDT1
;
882
stc_can_newdt1_t
NEWDT1_f
;
883
};
884
__IO
uint16_t
NEWDT2
;
885
};
886
};
887
uint8_t
RESERVED8
[12];
888
union
{
889
union
{
890
__IO
uint32_t
INTPND
;
891
stc_can_intpnd_t
INTPND_f
;
892
};
893
struct
{
894
union
{
895
__IO
uint16_t
INTPND1
;
896
stc_can_intpnd1_t
INTPND1_f
;
897
};
898
union
{
899
__IO
uint16_t
INTPND2
;
900
stc_can_intpnd2_t
INTPND2_f
;
901
};
902
};
903
};
904
uint8_t
RESERVED9
[12];
905
union
{
906
union
{
907
__IO
uint32_t
MSGVAL
;
908
stc_can_msgval_t
MSGVAL_f
;
909
};
910
struct
{
911
union
{
912
__IO
uint16_t
MSGVAL1
;
913
stc_can_msgval1_t
MSGVAL1_f
;
914
};
915
union
{
916
__IO
uint16_t
MSGVAL2
;
917
stc_can_msgval2_t
MSGVAL2_f
;
918
};
919
};
920
};
921
}
stc_cann_t
;
922
932
typedef
enum
en_can_prescaler
933
{
934
CanPreDiv11
= 0,
935
CanPreDiv12
= 1,
936
CanPreDiv14
= 2,
937
CanPreDiv18
= 3,
938
CanPreDiv23
= 4,
939
CanPreDiv13
= 5,
940
CanPreDiv16
= 6,
941
CanPreDiv112
= 7,
942
CanPreDiv15
= 8,
943
CanPreDiv110
= 9
944
}
en_can_prescaler_t
;
945
954
typedef
struct
stc_can_bitrate
955
{
956
uint8_t
u8TimeSegment1
;
957
uint8_t
u8TimeSegment2
;
958
uint8_t
u8SyncJumpWidth
;
959
uint16_t
u16Prescaler
;
960
en_can_prescaler_t
enCanPrescaler
;
961
}
stc_can_bitrate_t
;
962
963
975
typedef
struct
stc_can_msg_id
976
{
977
uint32_t
u32Identifier
;
978
boolean_t
bExtended
;
979
}
stc_can_msg_id_t
;
980
981
989
typedef
struct
stc_can_msg_data
990
{
991
uint8_t
au8Data
[
CAN_MESSAGE_DATA_BUFFER_SIZE
];
992
uint8_t
u8DataLengthCode
;
993
}
stc_can_msg_data_t
;
994
995
1002
typedef
enum
en_can_tx_mode
1003
{
1004
CanImmediateTransmit
= 0,
1005
CanRemoteTransmit
= 1
1006
}
en_can_tx_mode_t
;
1007
1008
1016
typedef
enum
en_can_status
1017
{
1018
CanNoError
= 0,
1019
CanStuffError
= 1,
1020
CanFormError
= 2,
1021
CanAckError
= 3,
1022
CanBit1Error
= 4,
1023
CanBit0Error
= 5,
1024
CanCRCError
= 6
1025
}
en_can_status_t
;
1026
1027
1035
typedef
enum
en_can_error
1036
{
1037
CanBusOff
= 0,
1038
CanWarning
= 1
1039
}
en_can_error_t
;
1040
1049
typedef
struct
stc_can_msg
1050
{
1051
stc_can_msg_id_t
stcIdentifier
;
1052
stc_can_msg_data_t
stcData
;
1053
volatile
boolean_t
bOverflow
;
1054
volatile
boolean_t
bNew
;
1055
}
stc_can_msg_t
;
1056
1063
typedef
void (*
can_tx_msg_func_ptr_t
)(uint8_t u8MsgBuf);
1064
1065
1072
typedef
void (*
can_rx_msg_func_ptr_t
)(uint8_t u8MsgBuf,
stc_can_msg_t
* pstcRxMsg);
1073
1074
1082
typedef
void (*
can_status_chg_func_ptr_t
)(
en_can_status_t
enCanStatus);
1083
1084
1092
typedef
void (*
can_error_func_ptr_t
)(
en_can_error_t
enCanError);
1093
1100
typedef
struct
stc_can_interrupt_handling
1101
{
1102
stc_can_msg_t
*
pstcMsgBuffer
;
1103
can_tx_msg_func_ptr_t
pfnCanTxInterruptFunction
;
1104
can_rx_msg_func_ptr_t
pfnCanRxInterruptFunction
;
1105
}
stc_can_interrupt_handling_t
;
1106
1113
typedef
struct
stc_can_notification
1114
{
1115
can_status_chg_func_ptr_t
pfnCanStatusInterruptFunction
;
1116
can_error_func_ptr_t
pfnCanErrorInterruptFunction
;
1117
}
stc_can_notification_t
;
1118
1127
typedef
struct
stc_can_config
1128
{
1129
can_status_chg_func_ptr_t
pfnStatusCallback
;
1130
can_error_func_ptr_t
pfnErrorCallback
;
1131
boolean_t
bDisableAutomaticRetransmission
;
1132
stc_can_bitrate_t
stcBitrate
;
1133
boolean_t
bTouchPrescaler
;
1134
}
stc_can_config_t
;
1135
1137
typedef
enum
en_can_instance_index
1138
{
1139
#if (PDL_PERIPHERAL_ENABLE_CAN0 == PDL_ON)
1140
CanInstanceIndexCan0
,
1141
#endif
1142
#if (PDL_PERIPHERAL_ENABLE_CAN1 == PDL_ON)
1143
CanInstanceIndexCan1
,
1144
#endif
1145
CanInstanceIndexMax
1146
}
en_can_instance_index_t
;
1147
1149
typedef
struct
stc_can_intern_data
1150
{
1151
stc_can_interrupt_handling_t
stcCanInterruptHandling
[
CAN_MESSAGE_BUFFER_COUNT
];
1152
stc_can_notification_t
stcCanNotificationCb
;
1153
boolean_t
bEobZero
;
1154
}
stc_can_intern_data_t
;
1155
1157
typedef
struct
stc_can_instance_data
1158
{
1159
volatile
stc_cann_t
*
pstcInstance
;
1160
stc_can_intern_data_t
stcInternData
;
1161
}
stc_can_instance_data_t
;
1162
1163
/******************************************************************************/
1164
/* Global variable declarations ('extern', definition in C source) */
1165
/******************************************************************************/
1166
1168
extern
stc_can_instance_data_t
m_astcCanInstanceDataLut
[];
1169
1170
/******************************************************************************/
1171
/* Global function prototypes ('extern', definition in C source) */
1172
/******************************************************************************/
1173
extern
void
CanIrqHandler
(
volatile
stc_cann_t
* pstcCan,
1174
stc_can_intern_data_t
* pstcCanInternData
1175
) ;
1176
1177
extern
en_result_t
Can_Init
(
volatile
stc_cann_t
* pstcCan,
1178
const
stc_can_config_t
* pstcConfig
1179
) ;
1180
1181
extern
en_result_t
Can_DeInit
(
volatile
stc_cann_t
* pstcCan ) ;
1182
1183
extern
en_result_t
Can_SetTransmitMsgBuffer
(
volatile
stc_cann_t
* pstcCan,
1184
uint8_t u8MsgBuf,
1185
const
stc_can_msg_id_t
* pstcMsgId,
1186
can_tx_msg_func_ptr_t
pfnCallback
1187
) ;
1188
1189
extern
en_result_t
Can_UpdateAndTransmitMsgBuffer
(
1190
volatile
stc_cann_t
* pstcCan,
1191
uint8_t u8MsgBuf,
1192
const
stc_can_msg_data_t
* pstcMsgData,
1193
en_can_tx_mode_t
enTxMode
1194
) ;
1195
1196
extern
en_result_t
Can_UpdateAndTransmitFifoMsgBuffer
(
volatile
stc_cann_t
* pstcCan,
1197
uint8_t u8MsgBuf,
1198
const
stc_can_msg_data_t
* pstcMsgData,
1199
en_can_tx_mode_t
enTxMode
1200
) ;
1201
1202
extern
en_result_t
Can_SetReceiveMsgBuffer
(
volatile
stc_cann_t
* pstcCan,
1203
uint8_t u8MsgBuf,
1204
stc_can_msg_t
* pstcMsgBuffer,
1205
uint32_t u32MsgIdMask,
1206
can_rx_msg_func_ptr_t
pfnCallback
1207
) ;
1208
1209
extern
en_result_t
Can_SetReceiveFifoMsgBuffer
(
volatile
stc_cann_t
* pstcCan,
1210
uint8_t u8MsgBuf,
1211
stc_can_msg_t
* pstcMsgBuffer,
1212
uint32_t u32MsgIdMask,
1213
can_rx_msg_func_ptr_t
pfnCallback
1214
) ;
1215
1216
extern
en_result_t
Can_ResetMsgBuffer
(
volatile
stc_cann_t
* pstcCan, uint8_t u8MsgBuf ) ;
1217
1219
#ifdef __cplusplus
1220
}
1221
#endif
1222
1223
#endif // #if (defined(PDL_PERIPHERAL_CAN_ACTIVE))
1224
1225
#endif
/* __CAN_H__ */
1226
/******************************************************************************/
1227
/* EOF (not truncated) */
1228
/******************************************************************************/
PDL_1_2
library
driver
can
can.h
Generated on Wed May 28 2014 09:28:10 for PDL for FM4 by
1.8.3.1