-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcan_defs_mcp2515.h
More file actions
1544 lines (1475 loc) · 36 KB
/
can_defs_mcp2515.h
File metadata and controls
1544 lines (1475 loc) · 36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* ----------------------------------------------------------------------------
*
* "THE ANY BEVERAGE-WARE LICENSE" (Revision 42 - based on beer-ware license):
* <dev@layer128.net> wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a be(ve)er(age) in return. (I don't
* like beer much.)
*
* Matthias Kleemann
*
* ----------------------------------------------------------------------------
*
* \file can_defs_mcp2515.h
*
* \date Created: 28.11.2011 18:36:26
* \author Matthias Kleemann
*
**/
#ifndef CAN_DEFS_MCP2515_H_
#define CAN_DEFS_MCP2515_H_
/**************************************************************************/
/* MCP2515 COMMAND SET */
/**************************************************************************/
/**
* \addtogroup mcp_command_set MCP2515 Command Set
* This is the command set used to control the MCP2515 CAN controller.
* @{
*/
/*! \brief resets all registers to configuration mode */
#define MCP2515_RESET 0xC0
/*! \brief quick polling of filter match and message type */
#define MCP2515_RX_STATUS 0xB0
/*! \brief quick read status of RX/TX functions */
#define MCP2515_READ_STATUS 0xA0
/*! \brief read a RX buffer indicated by bit 0..1 */
#define MCP2515_READ_RX 0x90
/*! \brief begin TX sequence for a TX buffer (bit 0..2) */
#define MCP2515_RTS 0x80
/*! \brief load a TX buffer indicated by bit 0..2 */
#define MCP2515_LOAD_TX 0x40
/*! \brief modifies bit in MCP2515 register */
#define MCP2515_BITMODIFY 0x05
/*! \brief read data from MCP2515 */
#define MCP2515_READ 0x03
/*! \brief write data to MCP2515 */
#define MCP2515_WRITE 0x02
/*! @} */
/**************************************************************************/
/* MCP2515 CONTROL REGISTERS */
/**************************************************************************/
/**
* \addtogroup mcp_control_registers MCP2515 Control Registers
* These are the registers the MCP2515 CAN controller provides to read and
* write status, control and data information.
* @{
*/
/*! \brief Receive Buffer 1 Control Register */
#define RXB1CTRL 0x70
/*! \brief Receive Buffer 0 Control Register */
#define RXB0CTRL 0x60
/*! \brief Transmit Buffer 2 Control Register */
#define TXB2CTRL 0x50
/*! \brief Transmit Buffer 1 Control Register */
#define TXB1CTRL 0x40
/*! \brief Transmit Buffer 0 Control Register */
#define TXB0CTRL 0x30
/*! \brief Error Flag Register */
#define EFLG 0x2D
/*! \brief CAN Interrupt Flag Register */
#define CANINTF 0x2C
/*! \brief CAN Interrupt Enable Register */
#define CANINTE 0x2B
/*! \brief Configuration Register 1 */
#define CNF1 0x2A
/*! \brief Configuration Register 2 */
#define CNF2 0x29
/*! \brief Configuration Register 3 */
#define CNF3 0x28
/*! \brief Receive Error Counter */
#define REC 0x1D
/*! \brief Transmit Error Counter */
#define TEC 0x1C
/*! \brief TXnRTS Pin Control and Status Register */
#define TXRTSCTRL 0x0D
/*! \brief RXnBF Pin Control and Status Register */
#define BFPCTRL 0x0C
/*!
* \def CANSTAT(x)
* \brief CAN Status Register(s)
*
* Multiple registers CANSTATx. Only one needs to be used (sets all), since
* they are in the same location physically.
*/
#define CANSTAT(x) CANSTAT ## x
/*! \sa CANSTAT(x) */
#define CANSTAT7 0x7E
/*! \sa CANSTAT(x) */
#define CANSTAT6 0x6E
/*! \sa CANSTAT(x) */
#define CANSTAT5 0x5E
/*! \sa CANSTAT(x) */
#define CANSTAT4 0x4E
/*! \sa CANSTAT(x) */
#define CANSTAT3 0x3E
/*! \sa CANSTAT(x) */
#define CANSTAT2 0x2E
/*! \sa CANSTAT(x) */
#define CANSTAT1 0x1E
/*! \sa CANSTAT(x) */
#define CANSTAT0 0x0E
/*!
* \def CANCTRL(x)
* \brief CAN Control Register(s)
*
* Multiple registers CANCTRLx. Only one needs to be used (sets all), since
* they are in the same location physically.
*/
#define CANCTRL(x) CANCTRL ## x
/*! \sa CANCTRL(x) */
#define CANCTRL7 0x7F
/*! \sa CANCTRL(x) */
#define CANCTRL6 0x6F
/*! \sa CANCTRL(x) */
#define CANCTRL5 0x5F
/*! \sa CANCTRL(x) */
#define CANCTRL4 0x4F
/*! \sa CANCTRL(x) */
#define CANCTRL3 0x3F
/*! \sa CANCTRL(x) */
#define CANCTRL2 0x2F
/*! \sa CANCTRL(x) */
#define CANCTRL1 0x1F
/*! \sa CANCTRL(x) */
#define CANCTRL0 0x0F
// reception filter mask registers
/**
* \def RXM0SIDH
* \brief Reception Mask Register 0 Standard ID Highbyte
*
* \def RXM0SIDL
* \brief Reception Mask Register 0 Standard ID Lowbyte
*
* \def RXM0EID8
* \brief Reception Mask Register 0 Extended ID Highbyte
*
* \def RXM0EID0
* \brief Reception Mask Register 0 Extended ID Lowbyte
*/
#define RXM0SIDH 0x20
#define RXM0SIDL 0x21
#define RXM0EID8 0x22
#define RXM0EID0 0x23
/**
* \def RXM1SIDH
* \brief Reception Mask Register 1 Standard ID Highbyte
*
* \def RXM1SIDL
* \brief Reception Mask Register 1 Standard ID Lowbyte
*
* \def RXM1EID8
* \brief Reception Mask Register 1 Extended ID Highbyte
*
* \def RXM1EID0
* \brief Reception Mask Register 1 Extended ID Lowbyte
*/
#define RXM1SIDH 0x24
#define RXM1SIDL 0x25
#define RXM1EID8 0x26
#define RXM1EID0 0x27
// reception filter registers
/**
* \def RXF0SIDH
* \brief Reception Filter Register 0 Standard ID Highbyte
*
* \def RXF0SIDL
* \brief Reception Filter Register 0 Standard ID Lowbyte
*
* \def RXF0EID8
* \brief Reception Filter Register 0 Extended ID Highbyte
*
* \def RXF0EID0
* \brief Reception Filter Register 0 Extended ID Lowbyte
*/
#define RXF0SIDH 0x00
#define RXF0SIDL 0x01
#define RXF0EID8 0x02
#define RXF0EID0 0x03
/**
* \def RXF1SIDH
* \brief Reception Filter Register 1 Standard ID Highbyte
*
* \def RXF1SIDL
* \brief Reception Filter Register 1 Standard ID Lowbyte
*
* \def RXF1EID8
* \brief Reception Filter Register 1 Extended ID Highbyte
*
* \def RXF1EID0
* \brief Reception Filter Register 1 Extended ID Lowbyte
*/
#define RXF1SIDH 0x04
#define RXF1SIDL 0x05
#define RXF1EID8 0x06
#define RXF1EID0 0x07
/**
* \def RXF2SIDH
* \brief Reception Filter Register 2 Standard ID Highbyte
*
* \def RXF2SIDL
* \brief Reception Filter Register 2 Standard ID Lowbyte
*
* \def RXF2EID8
* \brief Reception Filter Register 2 Extended ID Highbyte
*
* \def RXF2EID0
* \brief Reception Filter Register 2 Extended ID Lowbyte
*/
#define RXF2SIDH 0x08
#define RXF2SIDL 0x09
#define RXF2EID8 0x0A
#define RXF2EID0 0x0B
/**
* \def RXF3SIDH
* \brief Reception Filter Register 3 Standard ID Highbyte
*
* \def RXF3SIDL
* \brief Reception Filter Register 3 Standard ID Lowbyte
*
* \def RXF3EID8
* \brief Reception Filter Register 3 Extended ID Highbyte
*
* \def RXF3EID0
* \brief Reception Filter Register 3 Extended ID Lowbyte
*/
#define RXF3SIDH 0x10
#define RXF3SIDL 0x11
#define RXF3EID8 0x12
#define RXF3EID0 0x13
/**
* \def RXF4SIDH
* \brief Reception Filter Register 4 Standard ID Highbyte
*
* \def RXF4SIDL
* \brief Reception Filter Register 4 Standard ID Lowbyte
*
* \def RXF4EID8
* \brief Reception Filter Register 4 Extended ID Highbyte
*
* \def RXF4EID0
* \brief Reception Filter Register 4 Extended ID Lowbyte
*/
#define RXF4SIDH 0x14
#define RXF4SIDL 0x15
#define RXF4EID8 0x16
#define RXF4EID0 0x17
/**
* \def RXF5SIDH
* \brief Reception Filter Register 5 Standard ID Highbyte
*
* \def RXF5SIDL
* \brief Reception Filter Register 5 Standard ID Lowbyte
*
* \def RXF5EID8
* \brief Reception Filter Register 5 Extended ID Highbyte
*
* \def RXF5EID0
* \brief Reception Filter Register 5 Extended ID Lowbyte
*/
#define RXF5SIDH 0x18
#define RXF5SIDL 0x19
#define RXF5EID8 0x1A
#define RXF5EID0 0x1B
/*! @} */
/**************************************************************************/
/* MCP2515 BIT DEFINITIONS */
/**************************************************************************/
/**
* \addtogroup mcp_bit_definitions MCP2515 Bit Definitions
* All named bits to be used writing and reading from MCP2515 registers.
* @{
*/
/*!
* \def BUKT2
* Rollover enable bit. If set RXB0 message will rollover and be written to
* RXB1 if RXB0 is full
* \sa RXB0CTRL
*
* \def BUKT1
* Copy of BUKT2 and used only internally by MCP2515. Read-Only
* \sa RXB0CTRL
* \sa BUKT2
*/
#define BUKT2 2
#define BUKT1 1
/**
* \def FILHIT2
* \brief Filter Hit bits.
*
* Indicates which acceptance filter enabled reception of message.
*
* \code
* FILHIT 2 1 0
* 1 0 1 = Acceptance Filter 5 (RXF5)
* 1 0 0 = Acceptance Filter 4 (RXF4)
* 0 1 1 = Acceptance Filter 3 (RXF3)
* 0 1 0 = Acceptance Filter 2 (RXF2)
* 0 0 1 = Acceptance Filter 1 (RXF1) (Only if BUKT bit set in RXB0CTRL)
* 0 0 0 = Acceptance Filter 0 (RXF0) (Only if BUKT bit set in RXB0CTRL)
* \endcode
*
* \sa RXB1CTRL, RXB0CTRL
* \sa FILHIT1, FILHIT0
* \sa BUKT1, BUKT2
*
* \def FILHIT1
* \brief Filter Hit bits.
*
* For a detailed documentation, see FILHIT2
* \sa FILHIT2, FILHIT0
*/
#define FILHIT2 2
#define FILHIT1 1
/**
* \def RXM1
* \brief Receive Buffer Operating Mode
*
* \code
* RXM 1 0
* 1 1 = Turn mask/filters off; receive any message
* 1 0 = Receive only valid messages with extended identifiers that meet filter criteria
* 0 1 = Receive only valid messages with standard identifiers that meet filter criteria
* 0 0 = Receive all valid messages using either standard or extended identifiers that meet filter criteria
* \endcode
*
* \sa RXM0
* \sa RXB1CTRL, RXB0CTRL
*
* \def RXM0
* \brief Receive Buffer Operating Mode bits
*
* \sa RXM1 for detailed description
* \sa RXB1CTRL, RXB0CTRL
*
* \def RXRTR
* \brief Received Remote Transfer Request
*
* \code
* 1 = Remote Transfer Request Received
* 0 = No Remote Transfer Request Received
* \endcode
*
* \def FILHIT0
* \brief Filter Hit bits.
*
* For a detailed documentation, see FILHIT2
* \sa FILHIT2, FILHIT1
* \sa RXB1CTRL, RXB0CTRL
*/
#define RXM1 6
#define RXM0 5
#define RXRTR 3
#define FILHIT0 0
// TXBxCTRL
/*!
* \def ABTF
* \brief Message Abborted Flag
*
* Message was aborted when det to 1, otherwise transmission completed
* successfully.
*
* \def MLOA
* \brief Message Lost Arbitration
*
* When set to 1, the message lost arbitration while being sent.
*
* \def TXERR
* \brief Transmission Error Detected
*
* A bus error occurrance while the message was being transmitted causes
* this bit to be set to 1.
*
* \def TXREQ
* \brief Message Transmit Request
*
* When this bit is set to 1 by MCU, the message in the tx buffer requests
* transmission. The bit is automatically cleared when message is sent. To
* abort a message, this bit can be set to 0 by MCU.
*
* \def TXP1
* \brief Transmit Buffer Priority bit 1
*
* These two bits set the priority of the tx buffer.
*
* \code
* TXP 1 0
* 1 1 = Highest Message Priority
* 1 0 = High Intermediate Message Priority
* 0 1 = Low Intermediate Message Priority
* 0 0 = Lowest Message Priority
* \endcode
*
* \def TXP0
* \brief Transmit Buffer Priority bit 0
* \sa TXP1 for detailed documentation
*
*/
#define ABTF 6
#define MLOA 5
#define TXERR 4
#define TXREQ 3
#define TXP1 1
#define TXP0 0
// EFLG
/*!
* \def RX1OVR
* \brief Receive Buffer 1 Overflow Flag
*
* Set when a valid message is received for RXB1 and CANINTF.RX1IF = 1.
* Must be reset by MCU.
*
* \sa CANINTF
* \sa RX1IF
*
* \def RX0OVR
* \brief Receive Buffer 0 Overflow Flag
*
* Set when a valid message is received for RXB0 and CANINTF.RX0IF = 1.
* Must be reset by MCU.
*
* \sa CANINTF
* \sa RX0IF
*
* \def TXBO
* \brief Bus-Off Error Flag
*
* Bit set when TEC reaches 255. Must be reset after a successful bus
* recovery sequence.
*
* \def TXEP
* \brief Transmit Error-Passive Flag
*
* Set when TEC is equal to or greater than 128. Reset when TEC is less
* than 128.
*
* \sa TEC
*
* \def RXEP
* \brief Receive Error-Passive Flag
*
* Set when REC is equal to or greater than 128. Reset when REC is less
* than 128.
*
* \sa REC
*
* \def TXWAR
* \brief Transmit Error Warning Flag
*
* Set when TEC is equal to or greater than 96. Reset when TEC is less
* than 96.
*
* \sa TEC
*
* \def RXWAR
* \brief Receive Error Warning Flag
*
* Set when REC is equal to or greater than 128. Reset when REC is less
* than 128.
*
* \sa REC
*
* \def EWARN
* \brief Error Warning Flag
*
* Set when TEC or REC is equal to or greater than 96 (TXWAR or RXWAR = 1).
* reset when both REC and TEC are less than 96.
*
* \sa TXWAR, RXWAR
* \sa TEC, REC
*
*/
#define RX1OVR 7
#define RX0OVR 6
#define TXBO 5
#define TXEP 4
#define RXEP 3
#define TXWAR 2
#define RXWAR 1
#define EWARN 0
// CANINTE
/*!
* \def MERRE
* \brief Message Error Interrupt Enable
*
* If set to 1, interrupt on error during message reception or transmission.
*
* \sa MERRF
*
* \def WAKIE
* \brief Wakeup Interrupt Enable
*
* If set to 1, interrupt on CAn bus activity. This is used to signal wake-up
* on CAN towards MCU.
*
* \sa WAKIF
*
* \def ERRIE
* \brief Error Interrupt Enable
*
* There are multiple sources located in EFLG register. Set to 1 results in
* an interrupt on EFLG error condition change.
*
* \sa ERRIF
* \sa EFLG
*
* \def TX2IE
* \brief Transmit Buffer 2 Empty Interrupt Enable
*
* Set to 1, interrupt when tx buffer 2 (TXB2) becomes empty.
*
* \sa TX2IF
*
* \def TX1IE
* \brief Transmit Buffer 1 Empty Interrupt Enable
*
* Set to 1, interrupt when tx buffer 1 (TXB1) becomes empty.
*
* \sa TX1IF
*
* \def TX0IE
* \brief Transmit Buffer 0 Empty Interrupt Enable
*
* Set to 1, interrupt when tx buffer 0 (TXB0) becomes empty.
*
* \sa TX0IF
*
* \def RX1IE
* \brief Receive Buffer 1 Full Interrupt Enable
*
* Set to 1, interrupt when message received in RXB1.
*
* \sa RX1IF
*
* \def RX0IE
* \brief Receive Buffer 0 Full Interrupt Enable
*
* Set to 1, interrupt when message received in RXB0.
*
* \sa RX0IF
*/
#define MERRE 7
#define WAKIE 6
#define ERRIE 5
#define TX2IE 4
#define TX1IE 3
#define TX0IE 2
#define RX1IE 1
#define RX0IE 0
// CANINTF
/*!
* \def MERRF
* \brief Message Error Interrupt Flag
*
* Set to 1, an interrupt is pending. Must be cleared by MCU to reset
* interrupt condition.
*
* \sa MERRE
*
* \def WAKIF
* \brief Wakeup Interrupt Flag
*
* Set to 1, an interrupt is pending. Must be cleared by MCU to reset
* interrupt condition.
*
* \sa WAKIE
*
* \def ERRIF
* \brief Error Interrupt Flag
*
* Set to 1, an interrupt is pending. Must be cleared by MCU to reset
* interrupt condition.
*
* \sa ERRIE
*
* \def TX2IF
* \brief Transmit Buffer 2 Empty Interrupt Flag
*
* Set to 1, an interrupt is pending. Must be cleared by MCU to reset
* interrupt condition.
*
* \sa TX2IE
*
* \def TX1IF
* \brief Transmit Buffer 1 Empty Interrupt Flag
*
* Set to 1, an interrupt is pending. Must be cleared by MCU to reset
* interrupt condition.
*
* \sa TX1Ie
*
* \def TX0IF
* \brief Transmit Buffer 0 Empty Interrupt Flag
*
* Set to 1, an interrupt is pending. Must be cleared by MCU to reset
* interrupt condition.
*
* \sa TX0IE
*
* \def RX1IF
* \brief Receive Buffer 1 Full Interrupt Flag
*
* Set to 1, an interrupt is pending. Must be cleared by MCU to reset
* interrupt condition.
*
* \sa RX1IE
*
* \def RX0IF
* \brief Receive Buffer 0 Full Interrupt Flag
*
* Set to 1, an interrupt is pending. Must be cleared by MCU to reset
* interrupt condition.
*
* \sa RX0IE
*/
#define MERRF 7
#define WAKIF 6
#define ERRIF 5
#define TX2IF 4
#define TX1IF 3
#define TX0IF 2
#define RX1IF 1
#define RX0IF 0
/*!
* \def SJW1
* \brief Synchronization Jump Width Length bit 1
*
* The SJW<1:0> bits select the Synchronization Jump Width Length in
* terms of number of TQs.
*
* \code
* SJW1 SJW0
* 1 1 = Length = 4 x TQ
* 1 0 = Length = 3 x TQ
* 0 1 = Length = 2 x TQ
* 0 0 = Length = 1 x TQ
* \endcode
*
* \sa CNF1
*
* \def SJW0
* \brief Synchronization Jump Width Length bit 0
*
* \sa CNF1
* \sa SJW1
*
* \def BRP5
* \brief Baud Rate Prescaler bit 5
*
* The BRP<5:0> bits control the baud rate prescaler. These bits set
* the length of TQ relative to the OSC1 input frequency, with the
* minimum TQ length being 2 TOSC (when BRP<5:0> = 'b000000').
*
* \code
* TQ = 2 x (BRP + 1)/Fosc
* \endcode
*
* \sa CNF1
*
* \def BRP4
* \brief Baud Rate Prescaler bit 4
*
* \sa CNF1
* \sa BRP5
*
* \def BRP3
* \brief Baud Rate Prescaler bit 3
*
* \sa CNF1
* \sa BRP5
*
* \def BRP2
* \brief Baud Rate Prescaler bit 2
*
* \sa CNF1
* \sa BRP5
*
* \def BRP1
* \brief Baud Rate Prescaler bit 1
*
* \sa CNF1
* \sa BRP5
*
* \def BRP0
* \brief Baud Rate Prescaler bit 0
*
* \sa CNF1
* \sa BRP5
*/
#define SJW1 7
#define SJW0 6
#define BRP5 5
#define BRP4 4
#define BRP3 3
#define BRP2 2
#define BRP1 1
#define BRP0 0
/**
* \def BTLMODE
* \brief PS2 Bit Time Length
*
* The BTLMODE bit controls how the length of PS2 is determined. If this
* bit is set to a '1', the length of PS2 is determined by the PHSEG2<2:0>
* bits of CNF3. If the BTLMODE bit is set to a '0', the length of PS2
* is greater than that of PS1 and the information processing time (which
* is fixed at 2 TQ for the MCP2515).
*
* \code
* 1 = Length of PS2 determined by PHSEG22:PHSEG20 bits of CNF3
* 0 = Length of PS2 is the greater of PS1 and IPT (2 TQ)
* \endcode
*
* \sa CNF2
* \sa PHSEG21
* \sa PHSEG20
*
* \def SAM
* \brief Sample Point Configuration
*
* The SAM bit controls how many times the RXCAN pin is sampled. Setting
* this bit to a '1' causes the bus to be sampled three times: twice at
* TQ/2 before the sample point and once at the normal sample point (which
* is at the end of PS1). The value of the bus is determined to be the
* majority sampled. If the SAM bit is set to a '0', the RXCAN pin is
* sampled only once at the sample point.
*
* \code
* 1 = Bus line is sampled three times at the sample point
* 0 = Bus line is sampled once at the sample point
* \endcode
*
* \sa CNF2
*
* \def PHSEG12
* \brief PS1 Length bit 2
*
* The PHSEG1<2:0> bits set the length (in TQ's) of PS1.
*
* \code
* (PHSEG1 + 1) x TQ
* \endcode
*
* \sa CNF2
*
* \def PHSEG11
* \brief PS1 Length bit 1
*
* \sa CNF2
* \sa PHSEG12
*
* \def PHSEG10
* \brief PS1 Length bit 0
*
* \sa CNF2
* \sa PHSEG12
*
* \def PRSEG2
* \brief Propagation Segment Length bit 2
*
* The PRSEG<2:0> bits set the length (in TQ's) of the propagation segment.
*
* \code
* (PRSEG + 1) x TQ
* \endcode
*
* \sa CNF2
*
* \def PRSEG1
* \brief Propagation Segment Length bit 1
*
* \sa CNF2
* \sa PRSEG2
*
* \def PRSEG0
* \brief Propagation Segment Length bit 0
*
* \sa CNF2
* \sa PRSEG2
*/
#define BTLMODE 7
#define SAM 6
#define PHSEG12 5
#define PHSEG11 4
#define PHSEG10 3
#define PRSEG2 2
#define PRSEG1 1
#define PRSEG0 0
/*!
* \def SOF
* \brief Start-of-Frame signal bit
*
* \code
* If CANCTRL.CLKEN = 1:
* 1 = CLKOUT pin enabled for SOF signal
* 0 = CLKOUT pin enabled for clockout function
*
* If CANCTRL.CLKEN = 0, Bit is don't care.
* \endcode
*
* \sa CNF3
* \sa CLKEN
* \sa CANCTRL
*
* \def WAKFIL
* \brief Wake-up Filter bit
*
* \code
* 1 = Wake-up filter enabled
* 0 = Wake-up filter disabled
* \endcode
*
* \sa CNF3
*
* \def PHSEG22
* \brief PS2 Length bit 2
*
* The PHSEG2<2:0> bits set the length (in TQ's) of PS2, if the CNF2.BTLMODE
* bit is set to a '1'. If the BTLMODE bit is set to a '0', the PHSEG2<2:0>
* bits have no effect.
*
* \code
* (PHSEG2 + 1) x TQ
* Minimum valid setting for PS2 is 2 TQ
* \endcode
*
* \sa CNF3
* \sa BTLMODE
*
* \def PHSEG21
* \brief PS2 Length bit 1
*
* \sa CNF3
* \sa PHSEG22
*
* \def PHSEG20
* \brief PS2 Length bit 0
*
* \sa CNF3
* \sa PHSEG22
*/
#define SOF 7
#define WAKFIL 6
#define PHSEG22 2
#define PHSEG21 1
#define PHSEG20 0
/**
* \def B2RTS
* \brief TX2RTS Pin State
*
* - Reads state of TX2RTS pin when in Digital Input mode
* - Reads as '0' when pin is in 'Request-to-Send' mode
*
* \sa TXRTSCTRL
*
* \def B1RTS
* \brief TX1RTS Pin State
*
* - Reads state of TX1RTS pin when in Digital Input mode
* - Reads as '0' when pin is in 'Request-to-Send' mode
*
* \sa TXRTSCTRL
*
* \def B0RTS
* \brief TX0RTS Pin State
*
* - Reads state of TX0RTS pin when in Digital Input mode
* - Reads as '0' when pin is in 'Request-to-Send' mode
*
* \sa TXRTSCTRL
*
* \def B2RTSM
* \brief TX2RTS Pin mode
*
* \code
* 1 = Pin is used to request message transmission of TXB2 buffer (on falling edge)
* 0 = Digital input
* \endcode
*
* \sa TXRTSCTRL
*
* \def B1RTSM
* \brief TX1RTS Pin mode
*
* \code
* 1 = Pin is used to request message transmission of TXB1 buffer (on falling edge)
* 0 = Digital input
* \endcode
*
* \sa TXRTSCTRL
*
* \def B0RTSM
* \brief TX0RTS Pin mode
*
* \code
* 1 = Pin is used to request message transmission of TXB0 buffer (on falling edge)
* 0 = Digital input
* \endcode
*
* \sa TXRTSCTRL
*/
#define B2RTS 5
#define B1RTS 4
#define B0RTS 3
#define B2RTSM 2
#define B1RTSM 1
#define B0RTSM 0
/**
* \def B1BFS
* \brief RX1BF Pin State (Digital Output mode only)
*
* Reads as '0' when RX1BF is configured as interrupt pin
*
* \sa BFPCTRL
*
* \def B0BFS
* \brief RX0BF Pin State (Digital Output mode only)
*
* Reads as '0' when RX0BF is configured as interrupt pin
*
* \sa BFPCTRL
*
* \def B1BFE
* \brief RX1BF Pin Function Enable
*
* \code
* 1 = Pin function enabled, operation mode determined by B1BFM bit
* 0 = Pin function disabled, pin goes to high-impedance state
* \endcode
*
* \sa BFPCTRL
*
* \def B0BFE
* \brief RX0BF Pin Function Enable
*
* \code
* 1 = Pin function enabled, operation mode determined by B0BFM bit
* 0 = Pin function disabled, pin goes to high-impedance state
* \endcode
*
* \sa BFPCTRL
*
* \def B1BFM
* \brief RX1BF Pin Operation Mode
*
* \code
* 1 = Pin is used as interrupt when valid message loaded into RXB1