-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMCP251XFD.h
4819 lines (4294 loc) · 335 KB
/
MCP251XFD.h
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
/*!*****************************************************************************
* @file MCP251XFD.h
* @author Fabien 'Emandhal' MAILLY
* @version 1.0.6
* @date 16/04/2023
* @brief MCP251XFD driver
* @details
* The MCP251XFD component is a CAN-bus controller supporting CAN2.0A, CAN2.0B
* and CAN-FD with SPI interface
* Follow datasheet MCP2517FD Rev.B (July 2019)
* MCP2518FD Rev.B (Dec 2020)
* MCP251863 Rev.A (Sept 2022) [Have a MCP2518FD inside]
* Follow MCP25XXFD Family Reference Manual (DS20005678D)
******************************************************************************/
/* @page License
*
* Copyright (c) 2020-2023 Fabien MAILLY
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS,
* IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*****************************************************************************/
/* Revision history:
* 1.0.7 Add MCP251XFD_SetFIFOinterruptConfiguration(), MCP251XFD_SetTEFinterruptConfiguration() and MCP251XFD_SetTXQinterruptConfiguration()
* These are to change interrupt configuration of a FIFO/TEF/TXQ at runtime [Thanks to xmurx]
* 1.0.6 Reduce code size by merging all Data Reads and all Data Writes
* 1.0.5 Do a safer timeout for functions
* Mark RegMCP251XFD_IOCON as deprecated following MCP2517FD: DS80000792C (§6), MCP2518FD: DS80000789C (§5), MCP251863: DS80000984A (§5)
* Change SPI max speed following MCP2517FD: DS80000792C (§5), MCP2518FD: DS80000789C (§4), MCP251863: DS80000984A (§4)
* 1.0.4 Minor changes in the code and documentation [Thanks to BombaMat]
* 1.0.3 Add MCP251XFD_StartCANListenOnly() function
* Correct the MCP251XFD_ReceiveMessageFromFIFO() function [Thanks to mikucukyilmaz]
* 1.0.2 MessageCtrlFlags is a set of instead of an enum, some reorganization of the code
* 1.0.1 Simplify implementation of MCP251XFD_ConfigurePins(), MCP251XFD_SetGPIOPinsDirection(),
* MCP251XFD_GetGPIOPinsInputLevel(), and MCP251XFD_SetGPIOPinsOutputLevel() functions
* Correct MCP251XFD_EnterSleepMode() function's description
* 1.0.0 Release version
*****************************************************************************/
#ifndef MCP251XFD_H_INC
#define MCP251XFD_H_INC
//=============================================================================
//-----------------------------------------------------------------------------
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
//-----------------------------------------------------------------------------
#include "ErrorsDef.h"
//-----------------------------------------------------------------------------
#ifdef __cplusplus
# define USE_MCP251XFD_TOOLS
extern "C" {
# define __MCP251XFD_PACKED__
# define MCP251XFD_PACKITEM __pragma(pack(push, 1))
# define MCP251XFD_UNPACKITEM __pragma(pack(pop))
# define MCP251XFD_PACKENUM(name,type) typedef enum name : type
# define MCP251XFD_UNPACKENUM(name) name
#else
# include "Conf_MCP251XFD.h"
# define __MCP251XFD_PACKED__ __attribute__((packed))
# define MCP251XFD_PACKITEM
# define MCP251XFD_UNPACKITEM
# define MCP251XFD_PACKENUM(name,type) typedef enum __MCP251XFD_PACKED__
# define MCP251XFD_UNPACKENUM(name) name
#endif
//-----------------------------------------------------------------------------
//! This macro is used to check the size of an object. If not, it will raise a "divide by 0" error at compile time
#define MCP251XFD_CONTROL_ITEM_SIZE(item, size) enum { item##_size_must_be_##size##_bytes = 1 / (int)(!!(sizeof(item) == size)) }
//-----------------------------------------------------------------------------
#if MCP251XFD_TRANS_BUF_SIZE < 9
# error MCP251XFD_TRANS_BUF_SIZE should not be < 9
#endif
//-----------------------------------------------------------------------------
//********************************************************************************************************************
// MCP251XFD limits definitions
//********************************************************************************************************************
// Frequencies and bitrate limits for MCP251XFD
#define MCP251XFD_XTALFREQ_MIN ( 4000000u ) //!< Min Xtal/Resonator frequency
#define MCP251XFD_XTALFREQ_MAX ( 40000000u ) //!< Max Xtal/Resonator frequency
#define MCP251XFD_OSCFREQ_MIN ( 2000000u ) //!< Min Oscillator frequency
#define MCP251XFD_OSCFREQ_MAX ( 40000000u ) //!< Max Oscillator frequency
#define MCP251XFD_SYSCLK_MIN ( 2000000u ) //!< Min SYSCLK frequency
#define MCP251XFD_SYSCLK_MAX ( 40000000u ) //!< Max SYSCLK frequency
#define MCP251XFD_CLKINPLL_MAX ( 40000000u ) //!< Max CLKIN+PLL frequency
#define MCP251XFD_NOMBITRATE_MIN ( 125000u ) //!< Min Nominal bitrate
#define MCP251XFD_NOMBITRATE_MAX ( 1000000u ) //!< Max Nominal bitrate
#define MCP251XFD_DATABITRATE_MIN ( 500000u ) //!< Min Data bitrate
#define MCP251XFD_DATABITRATE_MAX ( 8000000u ) //!< Max Data bitrate
#define MCP251XFD_SPICLOCK_MAX ( 17000000u ) //!< Max SPI clock frequency for MCP251XFD (Ensure that FSCK is less than or equal to 0.85 * (FSYSCLK/2))
//-----------------------------------------------------------------------------
// Limits Bit Rate configuration range for MCP251XFD
#define MCP251XFD_tTXDtRXD_MAX ( 255 ) //!< tTXD-RXD is the propagation delay of the transceiver, a maximum 255ns according to ISO 11898-1:2015
#define MCP251XFD_tBUS_CONV ( 5 ) //!< TBUS is the delay on the CAN bus, which is approximately 5ns/m
#define MCP251XFD_NBRP_MIN ( 1 ) //!< Min NBRP
#define MCP251XFD_NBRP_MAX ( 256 ) //!< Max NBRP
#define MCP251XFD_NSYNC ( 1 ) //!< NSYNC is 1 NTQ (Defined in ISO 11898-1:2015)
#define MCP251XFD_NTSEG1_MIN ( 2 ) //!< Min NTSEG1
#define MCP251XFD_NTSEG1_MAX ( 256 ) //!< Max NTSEG1
#define MCP251XFD_NTSEG2_MIN ( 1 ) //!< Min NTSEG2
#define MCP251XFD_NTSEG2_MAX ( 128 ) //!< Max NTSEG2
#define MCP251XFD_NSJW_MIN ( 1 ) //!< Min NSJW
#define MCP251XFD_NSJW_MAX ( 128 ) //!< Max NSJW
#define MCP251XFD_NTQBIT_MIN ( MCP251XFD_NSYNC + MCP251XFD_NTSEG1_MIN + MCP251XFD_NTSEG2_MIN ) //!< Min NTQ per Bit (1-bit SYNC + 1-bit PRSEG + 1-bit PHSEG1 + 1-bit PHSEG2)
#define MCP251XFD_NTQBIT_MAX ( MCP251XFD_NTSEG1_MAX + MCP251XFD_NTSEG2_MAX + 1 ) //!< Max NTQ per Bit (385-bits)
#define MCP251XFD_DBRP_MIN ( 1 ) //!< Min DBRP
#define MCP251XFD_DBRP_MAX ( 256 ) //!< Max DBRP
#define MCP251XFD_DSYNC ( 1 ) //!< DSYNC is 1 NTQ (Defined in ISO 11898-1:2015)
#define MCP251XFD_DTSEG1_MIN ( 1 ) //!< Min DTSEG1
#define MCP251XFD_DTSEG1_MAX ( 32 ) //!< Max DTSEG1
#define MCP251XFD_DTSEG2_MIN ( 1 ) //!< Min DTSEG2
#define MCP251XFD_DTSEG2_MAX ( 16 ) //!< Max DTSEG2
#define MCP251XFD_DSJW_MIN ( 1 ) //!< Min DSJW
#define MCP251XFD_DSJW_MAX ( 16 ) //!< Max DSJW
#define MCP251XFD_DTQBIT_MIN ( MCP251XFD_NSYNC + MCP251XFD_NTSEG1_MIN + MCP251XFD_NTSEG2_MIN ) //!< Min DTQ per Bit (1-bit SYNC + 1-bit PRSEG + 1-bit PHSEG1 + 1-bit PHSEG2)
#define MCP251XFD_DTQBIT_MAX ( MCP251XFD_NTSEG1_MAX + MCP251XFD_NTSEG2_MAX + 1 ) //!< Max DTQ per Bit (49-bits)
#define MCP251XFD_TDCO_MIN ( -64 ) //!< Min TDCO
#define MCP251XFD_TDCO_MAX ( 63 ) //!< Max TDCO
#define MCP251XFD_TDCV_MIN ( 0 ) //!< Min TDCV
#define MCP251XFD_TDCV_MAX ( 63 ) //!< Max TDCV
//-----------------------------------------------------------------------------
// FIFO definitions
#define MCP251XFD_TEF_MAX ( 1 ) //!< 1 TEF maximum
#define MCP251XFD_TXQ_MAX ( 1 ) //!< 1 TXQ maximum
#define MCP251XFD_FIFO_MAX ( 31 ) //!< 31 FIFOs maximum
#define MCP251XFD_FIFO_CONF_MAX ( MCP251XFD_TEF_MAX + MCP251XFD_TXQ_MAX + MCP251XFD_FIFO_MAX ) //!< Maximum 33 FIFO configurable (TEF + TXQ + 31 FIFO)
#define MCP251XFD_TX_FIFO_MAX ( MCP251XFD_TXQ_MAX + MCP251XFD_FIFO_MAX ) //!< Maximum 32 transmit FIFO (TXQ + 31 FIFO)
#define MCP251XFD_RX_FIFO_MAX ( MCP251XFD_TEF_MAX + MCP251XFD_FIFO_MAX ) //!< Maximum 32 receive FIFO (TEF + 31 FIFO)
//-----------------------------------------------------------------------------
// Memory mapping definitions for MCP251XFD
#define MCP251XFD_CAN_CONTROLLER_SIZE ( 752u ) //!< CAN controller size
#define MCP251XFD_RAM_SIZE ( 2048u ) //!< RAM size
#define MCP251XFD_CONTROLLER_SFR_SIZE ( 24u ) //!< Controller SFR size
#define MCP251XFD_CAN_CONTROLLER_ADDR ( 0x000u ) //!< CAN Controller Memory base address
#define MCP251XFD_RAM_ADDR ( 0x400u ) //!< RAM Memory base address
#define MCP251XFD_CONTROLLER_SFR_ADDR ( 0xE00u ) //!< SFR Controller Memory base address
#define MCP251XFD_END_ADDR ( 0xFFFu ) //!< Last possible address
//-----------------------------------------------------------------------------
//********************************************************************************************************************
// MCP251XFD's RAM definitions
//********************************************************************************************************************
//! MCP251XFD RAM FIFO Informations structure
typedef struct MCP251XFD_RAMInfos
{
uint16_t ByteInFIFO; //!< Total number of bytes that FIFO takes in RAM
uint16_t RAMStartAddress; //!< RAM Start Address of the FIFO
uint8_t ByteInObject; //!< How many bytes in an object of the FIFO
} MCP251XFD_RAMInfos;
//-----------------------------------------------------------------------------
//! int32_t to 2-uint16_t to 4-uint8_t conversion
MCP251XFD_PACKITEM
typedef union __MCP251XFD_PACKED__
{
uint32_t Uint32;
uint16_t Uint16[sizeof(uint32_t) / sizeof(uint16_t)];
uint8_t Bytes[sizeof(uint32_t) / sizeof(uint8_t)];
} MCP251XFD_uint32t_Conv;
MCP251XFD_UNPACKITEM;
MCP251XFD_CONTROL_ITEM_SIZE(MCP251XFD_uint32t_Conv, 4);
//! int16_t to 2-uint8_t conversion
MCP251XFD_PACKITEM
typedef union __MCP251XFD_PACKED__
{
uint16_t Uint16;
uint8_t Bytes[sizeof(uint16_t) / sizeof(uint8_t)];
} MCP251XFD_uint16t_Conv;
MCP251XFD_UNPACKITEM;
MCP251XFD_CONTROL_ITEM_SIZE(MCP251XFD_uint16t_Conv, 2);
//-----------------------------------------------------------------------------
//********************************************************************************************************************
// MCP251XFD's driver definitions
//********************************************************************************************************************
//! Driver configuration enum
typedef enum
{
MCP251XFD_DRIVER_NORMAL_USE = 0x00, //!< Use the driver with no special verifications, just settings verifications (usually the fastest mode)
MCP251XFD_DRIVER_SAFE_RESET = 0x01, //!< Set Configuration mode first and next send a Reset command with a SPI clock at 1MHz max (MCP251XFD_SYSCLK_MIN div by 2)
MCP251XFD_DRIVER_ENABLE_ECC = 0x02, //!< Enable the ECC just before the RAM initialization and activate ECCCON_SECIE and ECCCON_DEDIE interrupt flags
MCP251XFD_DRIVER_INIT_CHECK_RAM = 0x04, //!< Check RAM at initialization by writing some data and checking them on all the RAM range (slower at initialization, take a long time)
MCP251XFD_DRIVER_INIT_SET_RAM_AT_0 = 0x08, //!< Set all bytes of the RAM to 0x00 (slower at initialization)
MCP251XFD_DRIVER_CLEAR_BUFFER_BEFORE_READ = 0x10, //!< This send 0x00 byte while reading SPI interface, mainly for cybersecurity purpose (little bit slower)
MCP251XFD_DRIVER_USE_READ_WRITE_CRC = 0x20, //!< Use CRC with all commands and data going to and from the controller (add 3 more bytes to each transaction, 2 for CRC + 1 for length)
MCP251XFD_DRIVER_USE_SAFE_WRITE = 0x40, //!< Each SFR write or memory write is sent one at a time (slower but send only the 2 bytes for CRC)
} eMCP251XFD_DriverConfig;
typedef eMCP251XFD_DriverConfig setMCP251XFD_DriverConfig; //! Set of Driver configuration (can be OR'ed)
//-----------------------------------------------------------------------------
// Safe Reset speed definition
#define MCP251XFD_DRIVER_SAFE_RESET_SPI_CLK ( MCP251XFD_SYSCLK_MIN / 2 ) //!< Set the SPI safe reset clock speed at 1MHz because SPI speed max is SYSCLK/2 and Xtal/Resonator/Oscillator frequency min is 2MHz
//-----------------------------------------------------------------------------
// SPI commands instructions (first 2 bytes are CAAA where C is 4-bits Command and A is 12-bits Address)
#define MCP251XFD_SPI_INSTRUCTION_RESET ( 0x00 ) //!< Reset instruction
#define MCP251XFD_SPI_INSTRUCTION_READ ( 0x03 ) //!< Read instruction
#define MCP251XFD_SPI_INSTRUCTION_WRITE ( 0x02 ) //!< Write instruction
#define MCP251XFD_SPI_INSTRUCTION_WRITE_CRC ( 0x0A ) //!< Write with CRC instruction
#define MCP251XFD_SPI_INSTRUCTION_READ_CRC ( 0x0B ) //!< Read with CRC instruction
#define MCP251XFD_SPI_INSTRUCTION_SAFE_WRITE ( 0x0C ) //!< Safe Write instruction
#define MCP251XFD_SPI_FIRST_BYTE(instruction,address) ( ((instruction) << 4) | (((address) >> 8) & 0xF) ) //!< Set first byte of SPI command
#define MCP251XFD_SPI_SECOND_BYTE(address) ( (address) & 0xFF ) //!< Set next byte of SPI command
#define MCP251XFD_SPI_16BITS_WORD(instruction,address) ( ((instruction) << 12) | ((address) & 0xFFF) ) //!< Set first and second byte of SPI command into a 16-bit word
//-----------------------------------------------------------------------------
//! List of supported devices
typedef enum
{
MCP2517FD = 0x0, //!< MCP2517FD supported
MCP2518FD = 0x1, //!< MCP2518FD/MCP251863 supported
eMPC251XFD_DEVICE_COUNT, // Device count of this enum, keep last
} eMCP251XFD_Devices;
#define MCP251XFD_DEV_ID_Pos 2
#define MCP251XFD_DEV_ID_Mask (0x1u << MCP251XFD_DEV_ID_Pos)
#define MCP251XFD_DEV_ID_SET(value) (((uint8_t)(value) << MCP251XFD_DEV_ID_Pos) & MCP251XFD_DEV_ID_Mask) //!< Set Device ID
#define MCP251XFD_DEV_ID_GET(value) (((uint8_t)(value) & MCP251XFD_DEV_ID_Mask) >> MCP251XFD_DEV_ID_Pos) //!< Get Device ID
static const char* const MCP251XFD_DevicesNames[eMPC251XFD_DEVICE_COUNT] =
{
"MCP2517FD",
"MCP2518FD", // Same for MCP251863
};
//-----------------------------------------------------------------------------
//********************************************************************************************************************
// MCP251XFD Register list
//********************************************************************************************************************
//! MCP251XFD registers list
typedef enum
{
// CAN-FD Controller Module Registers
RegMCP251XFD_CiCON = 0x000, //!< CAN Control Register
RegMCP251XFD_CiNBTCFG = 0x004, //!< Nominal BitTime Configuration Register
RegMCP251XFD_CiNBTCFG_SJW = RegMCP251XFD_CiNBTCFG+0, //!< Nominal BitTime Configuration Register - Synchronization Jump Width
RegMCP251XFD_CiNBTCFG_TSEG2 = RegMCP251XFD_CiNBTCFG+1, //!< Nominal BitTime Configuration Register - Time Segment 2 (Phase Segment 2)
RegMCP251XFD_CiNBTCFG_TSEG1 = RegMCP251XFD_CiNBTCFG+2, //!< Nominal BitTime Configuration Register - Time Segment 1 (Propagation Segment + Phase Segment 1)
RegMCP251XFD_CiNBTCFG_BRP = RegMCP251XFD_CiNBTCFG+3, //!< Nominal BitTime Configuration Register - Baud Rate Prescaler
RegMCP251XFD_CiDBTCFG = 0x008, //!< Data BitTime Configuration Register
RegMCP251XFD_CiDBTCFG_SJW = RegMCP251XFD_CiDBTCFG+0, //!< Data BitTime Configuration Register - Synchronization Jump Width
RegMCP251XFD_CiDBTCFG_TSEG2 = RegMCP251XFD_CiDBTCFG+1, //!< Data BitTime Configuration Register - Time Segment 2 (Phase Segment 2)
RegMCP251XFD_CiDBTCFG_TSEG1 = RegMCP251XFD_CiDBTCFG+2, //!< Data BitTime Configuration Register - Time Segment 1 (Propagation Segment + Phase Segment 1)
RegMCP251XFD_CiDBTCFG_BRP = RegMCP251XFD_CiDBTCFG+3, //!< Data BitTime Configuration Register - Baud Rate Prescaler
RegMCP251XFD_CiTDC = 0x00C, //!< Transmitter Delay Compensation Register
RegMCP251XFD_CiTDC_TDCV = RegMCP251XFD_CiTDC+0, //!< Transmitter Delay Compensation Register - Transmitter Delay Compensation Value
RegMCP251XFD_CiTDC_TDCO = RegMCP251XFD_CiTDC+1, //!< Transmitter Delay Compensation Register - Transmitter Delay Compensation Offset
RegMCP251XFD_CiTDC_TDCMOD = RegMCP251XFD_CiTDC+2, //!< Transmitter Delay Compensation Register - Transmitter Delay Compensation Mode
RegMCP251XFD_CiTDC_CONFIG = RegMCP251XFD_CiTDC+3, //!< Transmitter Delay Compensation Register - CAN-FD configuration
RegMCP251XFD_CiTBC = 0x010, //!< Time Base Counter Register
RegMCP251XFD_CiTSCON = 0x014, //!< Time Stamp Control Register
RegMCP251XFD_CiTSCON_TBCPRE = RegMCP251XFD_CiTSCON+0, //!< Time Stamp Control Register - Time Base Counter Prescaler
RegMCP251XFD_CiTSCON_CONFIG = RegMCP251XFD_CiTSCON+2, //!< Time Stamp Control Register - Time Base Counter Configuration
RegMCP251XFD_CiVEC = 0x018, //!< Interrupt Code Register
RegMCP251XFD_CiVEC_ICODE = RegMCP251XFD_CiVEC+0, //!< Interrupt Code Register - Interrupt Flag Code
RegMCP251XFD_CiVEC_FILHIT = RegMCP251XFD_CiVEC+1, //!< Interrupt Code Register - Filter Hit Number
RegMCP251XFD_CiVEC_TXCODE = RegMCP251XFD_CiVEC+2, //!< Interrupt Code Register - Transmit Interrupt Flag Code
RegMCP251XFD_CiVEC_RXCODE = RegMCP251XFD_CiVEC+3, //!< Interrupt Code Register - Receive Interrupt Flag Code
RegMCP251XFD_CiINT = 0x01C, //!< Interrupt Register
RegMCP251XFD_CiINT_FLAG = RegMCP251XFD_CiINT+0, //!< Interrupt Register - Interrupts flags
RegMCP251XFD_CiINT_CONFIG = RegMCP251XFD_CiINT+2, //!< Interrupt Register - Interrupts enable
RegMCP251XFD_CiRXIF = 0x020, //!< Receive Interrupt Status Register
RegMCP251XFD_CiTXIF = 0x024, //!< Receive Overflow Interrupt Status Register
RegMCP251XFD_CiRXOVIF = 0x028, //!< Transmit Interrupt Status Register
RegMCP251XFD_CiTXATIF = 0x02C, //!< Transmit Attempt Interrupt Status Register
RegMCP251XFD_CiTXREQ = 0x030, //!< Transmit Request Register
RegMCP251XFD_CiTREC = 0x034, //!< Transmit/Receive Error Count Register
RegMCP251XFD_CiTREC_REC = RegMCP251XFD_CiTREC+0, //!< Transmit/Receive Error Count Register - Receive Error Counter
RegMCP251XFD_CiTREC_TEC = RegMCP251XFD_CiTREC+1, //!< Transmit/Receive Error Count Register - Transmit Error Counter
RegMCP251XFD_CiTREC_STATUS = RegMCP251XFD_CiTREC+2, //!< Transmit/Receive Error Count Register - Error Status
RegMCP251XFD_CiBDIAG0 = 0x038, //!< Bus Diagnostic Register 0
RegMCP251XFD_CiBDIAG0_NRERRCNT = RegMCP251XFD_CiBDIAG0+0, //!< Bus Diagnostic Register 0 - Nominal Bit Rate Receive Error Counter
RegMCP251XFD_CiBDIAG0_NTERRCNT = RegMCP251XFD_CiBDIAG0+1, //!< Bus Diagnostic Register 0 - Nominal Bit Rate Transmit Error Counter
RegMCP251XFD_CiBDIAG0_DRERRCNT = RegMCP251XFD_CiBDIAG0+2, //!< Bus Diagnostic Register 0 - Data Bit Rate Receive Error Counter
RegMCP251XFD_CiBDIAG0_DTERRCNT = RegMCP251XFD_CiBDIAG0+3, //!< Bus Diagnostic Register 0 - Data Bit Rate Transmit Error Counter
RegMCP251XFD_CiBDIAG1 = 0x03C, //!< Bus Diagnostic Register 1
RegMCP251XFD_CiBDIAG1_EFMSGCNT = RegMCP251XFD_CiBDIAG1+0, //!< Bus Diagnostic Register 1 - Error Free Message Counter
RegMCP251XFD_CiTEFCON = 0x040, //!< Transmit Event FIFO Control Register
RegMCP251XFD_CiTEFCON_CONFIG = RegMCP251XFD_CiTEFCON+0, //!< Transmit Event FIFO Control Register - Interrupt configuration
RegMCP251XFD_CiTEFCON_CONTROL = RegMCP251XFD_CiTEFCON+1, //!< Transmit Event FIFO Control Register - TEF Control
RegMCP251XFD_CiTEFSTA = 0x044, //!< Transmit Event FIFO Status Register
RegMCP251XFD_CiTEFSTA_FLAGS = RegMCP251XFD_CiTEFSTA+0, //!< Transmit Event FIFO Status Register - Flags
RegMCP251XFD_CiTEFUA = 0x048, //!< Transmit Event FIFO User Address Register
RegMCP251XFD_Reserved4C = 0x04C, //!< Reserved Register
// Transmit Queue Registers
RegMCP251XFD_CiTXQCON = 0x050, //!< Transmit Queue Control Register
RegMCP251XFD_CiTXQCON_CONFIG = RegMCP251XFD_CiTXQCON+0, //!< Transmit Queue Control Register - Interrupt configuration
RegMCP251XFD_CiTXQCON_CONTROL = RegMCP251XFD_CiTXQCON+1, //!< Transmit Queue Control Register - TXQ Control
RegMCP251XFD_CiTXQSTA = 0x054, //!< Transmit Queue Status Register
RegMCP251XFD_CiTXQSTA_FLAGS = RegMCP251XFD_CiTXQSTA+0, //!< Transmit Queue Status Register - Flags
RegMCP251XFD_CiTXQSTA_TXQCI = RegMCP251XFD_CiTXQSTA+1, //!< Transmit Queue Status Register - Transmit Queue Message Index
RegMCP251XFD_CiTXQUA = 0x058, //!< Transmit Queue User Address Register
// FIFOs Registers
RegMCP251XFD_CiFIFOCONm = 0x05C, //!< FIFO Control Register m, (m = 1 to 31)
RegMCP251XFD_CiFIFOCONm_CONFIG = RegMCP251XFD_CiFIFOCONm+0, //!< FIFO Control Register m, (m = 1 to 31) - Interrupt configuration
RegMCP251XFD_CiFIFOCONm_CONTROL = RegMCP251XFD_CiFIFOCONm+1, //!< FIFO Control Register m, (m = 1 to 31) - FIFO Control
RegMCP251XFD_CiFIFOSTAm = 0x060, //!< FIFO Status Register m, (m = 1 to 31)
RegMCP251XFD_CiFIFOSTAm_FLAGS = RegMCP251XFD_CiFIFOSTAm+0, //!< FIFO Status Register m, (m = 1 to 31) - Flags
RegMCP251XFD_CiFIFOSTAm_FIFOCI = RegMCP251XFD_CiFIFOSTAm+1, //!< FIFO Status Register m, (m = 1 to 31) - FIFO Message Index
RegMCP251XFD_CiFIFOUAm = 0x064, //!< FIFO User Address Register m, (m = 1 to 31)
RegMCP251XFD_CiFIFOCON1 = 0x05C, //!< FIFO Control Register 1
RegMCP251XFD_CiFIFOSTA1 = 0x060, //!< FIFO Status Register 1
RegMCP251XFD_CiFIFOUA1 = 0x064, //!< FIFO User Address Register 1
RegMCP251XFD_CiFIFOCON2 = 0x068, //!< FIFO Control Register 2
RegMCP251XFD_CiFIFOSTA2 = 0x06C, //!< FIFO Status Register 2
RegMCP251XFD_CiFIFOUA2 = 0x070, //!< FIFO User Address Register 2
RegMCP251XFD_CiFIFOCON3 = 0x074, //!< FIFO Control Register 3
RegMCP251XFD_CiFIFOSTA3 = 0x078, //!< FIFO Status Register 3
RegMCP251XFD_CiFIFOUA3 = 0x07C, //!< FIFO User Address Register 3
RegMCP251XFD_CiFIFOCON4 = 0x080, //!< FIFO Control Register 4
RegMCP251XFD_CiFIFOSTA4 = 0x084, //!< FIFO Status Register 4
RegMCP251XFD_CiFIFOUA4 = 0x088, //!< FIFO User Address Register 4
RegMCP251XFD_CiFIFOCON5 = 0x08C, //!< FIFO Control Register 5
RegMCP251XFD_CiFIFOSTA5 = 0x090, //!< FIFO Status Register 5
RegMCP251XFD_CiFIFOUA5 = 0x094, //!< FIFO User Address Register 5
RegMCP251XFD_CiFIFOCON6 = 0x098, //!< FIFO Control Register 6
RegMCP251XFD_CiFIFOSTA6 = 0x09C, //!< FIFO Status Register 6
RegMCP251XFD_CiFIFOUA6 = 0x0A0, //!< FIFO User Address Register 6
RegMCP251XFD_CiFIFOCON7 = 0x0A4, //!< FIFO Control Register 7
RegMCP251XFD_CiFIFOSTA7 = 0x0A8, //!< FIFO Status Register 7
RegMCP251XFD_CiFIFOUA7 = 0x0AC, //!< FIFO User Address Register 7
RegMCP251XFD_CiFIFOCON8 = 0x0B0, //!< FIFO Control Register 8
RegMCP251XFD_CiFIFOSTA8 = 0x0B4, //!< FIFO Status Register 8
RegMCP251XFD_CiFIFOUA8 = 0x0B8, //!< FIFO User Address Register 8
RegMCP251XFD_CiFIFOCON9 = 0x0BC, //!< FIFO Control Register 9
RegMCP251XFD_CiFIFOSTA9 = 0x0C0, //!< FIFO Status Register 9
RegMCP251XFD_CiFIFOUA9 = 0x0C4, //!< FIFO User Address Register 9
RegMCP251XFD_CiFIFOCON10 = 0x0C8, //!< FIFO Control Register 10
RegMCP251XFD_CiFIFOSTA10 = 0x0CC, //!< FIFO Status Register 10
RegMCP251XFD_CiFIFOUA10 = 0x0D0, //!< FIFO User Address Register 10
RegMCP251XFD_CiFIFOCON11 = 0x0D4, //!< FIFO Control Register 11
RegMCP251XFD_CiFIFOSTA11 = 0x0D8, //!< FIFO Status Register 11
RegMCP251XFD_CiFIFOUA11 = 0x0DC, //!< FIFO User Address Register 11
RegMCP251XFD_CiFIFOCON12 = 0x0E0, //!< FIFO Control Register 12
RegMCP251XFD_CiFIFOSTA12 = 0x0E4, //!< FIFO Status Register 12
RegMCP251XFD_CiFIFOUA12 = 0x0E8, //!< FIFO User Address Register 12
RegMCP251XFD_CiFIFOCON13 = 0x0EC, //!< FIFO Control Register 13
RegMCP251XFD_CiFIFOSTA13 = 0x0F0, //!< FIFO Status Register 13
RegMCP251XFD_CiFIFOUA13 = 0x0F4, //!< FIFO User Address Register 13
RegMCP251XFD_CiFIFOCON14 = 0x0F8, //!< FIFO Control Register 14
RegMCP251XFD_CiFIFOSTA14 = 0x0FC, //!< FIFO Status Register 14
RegMCP251XFD_CiFIFOUA14 = 0x100, //!< FIFO User Address Register 14
RegMCP251XFD_CiFIFOCON15 = 0x104, //!< FIFO Control Register 15
RegMCP251XFD_CiFIFOSTA15 = 0x108, //!< FIFO Status Register 15
RegMCP251XFD_CiFIFOUA15 = 0x10C, //!< FIFO User Address Register 15
RegMCP251XFD_CiFIFOCON16 = 0x110, //!< FIFO Control Register 16
RegMCP251XFD_CiFIFOSTA16 = 0x114, //!< FIFO Status Register 16
RegMCP251XFD_CiFIFOUA16 = 0x118, //!< FIFO User Address Register 16
RegMCP251XFD_CiFIFOCON17 = 0x11C, //!< FIFO Control Register 17
RegMCP251XFD_CiFIFOSTA17 = 0x120, //!< FIFO Status Register 17
RegMCP251XFD_CiFIFOUA17 = 0x124, //!< FIFO User Address Register 17
RegMCP251XFD_CiFIFOCON18 = 0x128, //!< FIFO Control Register 18
RegMCP251XFD_CiFIFOSTA18 = 0x12C, //!< FIFO Status Register 18
RegMCP251XFD_CiFIFOUA18 = 0x130, //!< FIFO User Address Register 18
RegMCP251XFD_CiFIFOCON19 = 0x134, //!< FIFO Control Register 19
RegMCP251XFD_CiFIFOSTA19 = 0x138, //!< FIFO Status Register 19
RegMCP251XFD_CiFIFOUA19 = 0x13C, //!< FIFO User Address Register 19
RegMCP251XFD_CiFIFOCON20 = 0x140, //!< FIFO Control Register 20
RegMCP251XFD_CiFIFOSTA20 = 0x144, //!< FIFO Status Register 20
RegMCP251XFD_CiFIFOUA20 = 0x148, //!< FIFO User Address Register 20
RegMCP251XFD_CiFIFOCON21 = 0x14C, //!< FIFO Control Register 21
RegMCP251XFD_CiFIFOSTA21 = 0x150, //!< FIFO Status Register 21
RegMCP251XFD_CiFIFOUA21 = 0x154, //!< FIFO User Address Register 21
RegMCP251XFD_CiFIFOCON22 = 0x158, //!< FIFO Control Register 22
RegMCP251XFD_CiFIFOSTA22 = 0x15C, //!< FIFO Status Register 22
RegMCP251XFD_CiFIFOUA22 = 0x160, //!< FIFO User Address Register 22
RegMCP251XFD_CiFIFOCON23 = 0x164, //!< FIFO Control Register 23
RegMCP251XFD_CiFIFOSTA23 = 0x168, //!< FIFO Status Register 23
RegMCP251XFD_CiFIFOUA23 = 0x16C, //!< FIFO User Address Register 23
RegMCP251XFD_CiFIFOCON24 = 0x170, //!< FIFO Control Register 24
RegMCP251XFD_CiFIFOSTA24 = 0x174, //!< FIFO Status Register 24
RegMCP251XFD_CiFIFOUA24 = 0x178, //!< FIFO User Address Register 24
RegMCP251XFD_CiFIFOCON25 = 0x17C, //!< FIFO Control Register 25
RegMCP251XFD_CiFIFOSTA25 = 0x180, //!< FIFO Status Register 25
RegMCP251XFD_CiFIFOUA25 = 0x184, //!< FIFO User Address Register 25
RegMCP251XFD_CiFIFOCON26 = 0x188, //!< FIFO Control Register 26
RegMCP251XFD_CiFIFOSTA26 = 0x18C, //!< FIFO Status Register 26
RegMCP251XFD_CiFIFOUA26 = 0x190, //!< FIFO User Address Register 26
RegMCP251XFD_CiFIFOCON27 = 0x194, //!< FIFO Control Register 27
RegMCP251XFD_CiFIFOSTA27 = 0x198, //!< FIFO Status Register 27
RegMCP251XFD_CiFIFOUA27 = 0x19C, //!< FIFO User Address Register 27
RegMCP251XFD_CiFIFOCON28 = 0x1A0, //!< FIFO Control Register 28
RegMCP251XFD_CiFIFOSTA28 = 0x1A4, //!< FIFO Status Register 28
RegMCP251XFD_CiFIFOUA28 = 0x1A8, //!< FIFO User Address Register 28
RegMCP251XFD_CiFIFOCON29 = 0x1AC, //!< FIFO Control Register 29
RegMCP251XFD_CiFIFOSTA29 = 0x1B0, //!< FIFO Status Register 29
RegMCP251XFD_CiFIFOUA29 = 0x1B4, //!< FIFO User Address Register 29
RegMCP251XFD_CiFIFOCON30 = 0x1B8, //!< FIFO Control Register 30
RegMCP251XFD_CiFIFOSTA30 = 0x1BC, //!< FIFO Status Register 30
RegMCP251XFD_CiFIFOUA30 = 0x1C0, //!< FIFO User Address Register 30
RegMCP251XFD_CiFIFOCON31 = 0x1C4, //!< FIFO Control Register 31
RegMCP251XFD_CiFIFOSTA31 = 0x1C8, //!< FIFO Status Register 31
RegMCP251XFD_CiFIFOUA31 = 0x1CC, //!< FIFO User Address Register 31
// Filters Registers
RegMCP251XFD_CiFLTCONm = 0x1D0, //!< Filter Control Register m, (m = 0 to 31)
RegMCP251XFD_CiFLTCON0 = 0x1D0, //!< Filter 0 to 3 Control Register
RegMCP251XFD_CiFLTCON0_FILTER0 = RegMCP251XFD_CiFLTCON0+0, //!< Filter 0 to 3 Control Register - Filter 0
RegMCP251XFD_CiFLTCON0_FILTER1 = RegMCP251XFD_CiFLTCON0+1, //!< Filter 0 to 3 Control Register - Filter 1
RegMCP251XFD_CiFLTCON0_FILTER2 = RegMCP251XFD_CiFLTCON0+2, //!< Filter 0 to 3 Control Register - Filter 2
RegMCP251XFD_CiFLTCON0_FILTER3 = RegMCP251XFD_CiFLTCON0+3, //!< Filter 0 to 3 Control Register - Filter 3
RegMCP251XFD_CiFLTCON1 = 0x1D4, //!< Filter 4 to 7 Control Register
RegMCP251XFD_CiFLTCON1_FILTER4 = RegMCP251XFD_CiFLTCON1+0, //!< Filter 4 to 7 Control Register - Filter 4
RegMCP251XFD_CiFLTCON1_FILTER5 = RegMCP251XFD_CiFLTCON1+1, //!< Filter 4 to 7 Control Register - Filter 5
RegMCP251XFD_CiFLTCON1_FILTER6 = RegMCP251XFD_CiFLTCON1+2, //!< Filter 4 to 7 Control Register - Filter 6
RegMCP251XFD_CiFLTCON1_FILTER7 = RegMCP251XFD_CiFLTCON1+3, //!< Filter 4 to 7 Control Register - Filter 7
RegMCP251XFD_CiFLTCON2 = 0x1D8, //!< Filter 8 to 11 Control Register
RegMCP251XFD_CiFLTCON2_FILTER8 = RegMCP251XFD_CiFLTCON2+0, //!< Filter 8 to 11 Control Register - Filter 8
RegMCP251XFD_CiFLTCON2_FILTER9 = RegMCP251XFD_CiFLTCON2+1, //!< Filter 8 to 11 Control Register - Filter 9
RegMCP251XFD_CiFLTCON2_FILTER10 = RegMCP251XFD_CiFLTCON2+2, //!< Filter 8 to 11 Control Register - Filter 10
RegMCP251XFD_CiFLTCON2_FILTER11 = RegMCP251XFD_CiFLTCON2+3, //!< Filter 8 to 11 Control Register - Filter 11
RegMCP251XFD_CiFLTCON3 = 0x1DC, //!< Filter 12 to 15 Control Register
RegMCP251XFD_CiFLTCON3_FILTER12 = RegMCP251XFD_CiFLTCON3+0, //!< Filter 12 to 15 Control Register - Filter 12
RegMCP251XFD_CiFLTCON3_FILTER13 = RegMCP251XFD_CiFLTCON3+1, //!< Filter 12 to 15 Control Register - Filter 13
RegMCP251XFD_CiFLTCON3_FILTER14 = RegMCP251XFD_CiFLTCON3+2, //!< Filter 12 to 15 Control Register - Filter 14
RegMCP251XFD_CiFLTCON3_FILTER15 = RegMCP251XFD_CiFLTCON3+3, //!< Filter 12 to 15 Control Register - Filter 15
RegMCP251XFD_CiFLTCON4 = 0x1E0, //!< Filter 16 to 19 Control Register
RegMCP251XFD_CiFLTCON4_FILTER16 = RegMCP251XFD_CiFLTCON4+0, //!< Filter 16 to 19 Control Register - Filter 16
RegMCP251XFD_CiFLTCON4_FILTER17 = RegMCP251XFD_CiFLTCON4+1, //!< Filter 16 to 19 Control Register - Filter 17
RegMCP251XFD_CiFLTCON4_FILTER18 = RegMCP251XFD_CiFLTCON4+2, //!< Filter 16 to 19 Control Register - Filter 18
RegMCP251XFD_CiFLTCON4_FILTER19 = RegMCP251XFD_CiFLTCON4+3, //!< Filter 16 to 19 Control Register - Filter 19
RegMCP251XFD_CiFLTCON5 = 0x1E4, //!< Filter 20 to 23 Control Register
RegMCP251XFD_CiFLTCON5_FILTER20 = RegMCP251XFD_CiFLTCON5+0, //!< Filter 20 to 23 Control Register - Filter 20
RegMCP251XFD_CiFLTCON5_FILTER21 = RegMCP251XFD_CiFLTCON5+1, //!< Filter 20 to 23 Control Register - Filter 21
RegMCP251XFD_CiFLTCON5_FILTER22 = RegMCP251XFD_CiFLTCON5+2, //!< Filter 20 to 23 Control Register - Filter 22
RegMCP251XFD_CiFLTCON5_FILTER23 = RegMCP251XFD_CiFLTCON5+3, //!< Filter 20 to 23 Control Register - Filter 23
RegMCP251XFD_CiFLTCON6 = 0x1E8, //!< Filter 24 to 27 Control Register
RegMCP251XFD_CiFLTCON6_FILTER24 = RegMCP251XFD_CiFLTCON6+0, //!< Filter 24 to 27 Control Register - Filter 24
RegMCP251XFD_CiFLTCON6_FILTER25 = RegMCP251XFD_CiFLTCON6+1, //!< Filter 24 to 27 Control Register - Filter 25
RegMCP251XFD_CiFLTCON6_FILTER26 = RegMCP251XFD_CiFLTCON6+2, //!< Filter 24 to 27 Control Register - Filter 26
RegMCP251XFD_CiFLTCON6_FILTER27 = RegMCP251XFD_CiFLTCON6+3, //!< Filter 24 to 27 Control Register - Filter 27
RegMCP251XFD_CiFLTCON7 = 0x1EC, //!< Filter 28 to 31 Control Register
RegMCP251XFD_CiFLTCON7_FILTER28 = RegMCP251XFD_CiFLTCON7+0, //!< Filter 28 to 31 Control Register - Filter 28
RegMCP251XFD_CiFLTCON7_FILTER29 = RegMCP251XFD_CiFLTCON7+1, //!< Filter 28 to 31 Control Register - Filter 29
RegMCP251XFD_CiFLTCON7_FILTER30 = RegMCP251XFD_CiFLTCON7+2, //!< Filter 28 to 31 Control Register - Filter 30
RegMCP251XFD_CiFLTCON7_FILTER31 = RegMCP251XFD_CiFLTCON7+3, //!< Filter 28 to 31 Control Register - Filter 31
RegMCP251XFD_CiFLTOBJm = 0x1F0, //!< Filter Object Register m, (m = 0 to 31)
RegMCP251XFD_CiMASKm = 0x1F4, //!< Filter Mask Register m, (m = 0 to 31)
RegMCP251XFD_CiFLTOBJ0 = 0x1F0, //!< Filter Object Register 0
RegMCP251XFD_CiMASK0 = 0x1F4, //!< Filter Mask Register 0
RegMCP251XFD_CiFLTOBJ1 = 0x1F8, //!< Filter Object Register 1
RegMCP251XFD_CiMASK1 = 0x1FC, //!< Filter Mask Register 1
RegMCP251XFD_CiFLTOBJ2 = 0x200, //!< Filter Object Register 2
RegMCP251XFD_CiMASK2 = 0x204, //!< Filter Mask Register 2
RegMCP251XFD_CiFLTOBJ3 = 0x208, //!< Filter Object Register 3
RegMCP251XFD_CiMASK3 = 0x20C, //!< Filter Mask Register 3
RegMCP251XFD_CiFLTOBJ4 = 0x210, //!< Filter Object Register 4
RegMCP251XFD_CiMASK4 = 0x214, //!< Filter Mask Register 4
RegMCP251XFD_CiFLTOBJ5 = 0x218, //!< Filter Object Register 5
RegMCP251XFD_CiMASK5 = 0x21C, //!< Filter Mask Register 5
RegMCP251XFD_CiFLTOBJ6 = 0x220, //!< Filter Object Register 6
RegMCP251XFD_CiMASK6 = 0x224, //!< Filter Mask Register 6
RegMCP251XFD_CiFLTOBJ7 = 0x228, //!< Filter Object Register 7
RegMCP251XFD_CiMASK7 = 0x22C, //!< Filter Mask Register 7
RegMCP251XFD_CiFLTOBJ8 = 0x230, //!< Filter Object Register 8
RegMCP251XFD_CiMASK8 = 0x234, //!< Filter Mask Register 8
RegMCP251XFD_CiFLTOBJ9 = 0x238, //!< Filter Object Register 9
RegMCP251XFD_CiMASK9 = 0x23C, //!< Filter Mask Register 9
RegMCP251XFD_CiFLTOBJ10 = 0x240, //!< Filter Object Register 10
RegMCP251XFD_CiMASK10 = 0x244, //!< Filter Mask Register 10
RegMCP251XFD_CiFLTOBJ11 = 0x248, //!< Filter Object Register 11
RegMCP251XFD_CiMASK11 = 0x24C, //!< Filter Mask Register 11
RegMCP251XFD_CiFLTOBJ12 = 0x250, //!< Filter Object Register 12
RegMCP251XFD_CiMASK12 = 0x254, //!< Filter Mask Register 12
RegMCP251XFD_CiFLTOBJ13 = 0x258, //!< Filter Object Register 13
RegMCP251XFD_CiMASK13 = 0x25C, //!< Filter Mask Register 13
RegMCP251XFD_CiFLTOBJ14 = 0x260, //!< Filter Object Register 14
RegMCP251XFD_CiMASK14 = 0x264, //!< Filter Mask Register 14
RegMCP251XFD_CiFLTOBJ15 = 0x268, //!< Filter Object Register 15
RegMCP251XFD_CiMASK15 = 0x26C, //!< Filter Mask Register 15
RegMCP251XFD_CiFLTOBJ16 = 0x270, //!< Filter Object Register 16
RegMCP251XFD_CiMASK16 = 0x274, //!< Filter Mask Register 16
RegMCP251XFD_CiFLTOBJ17 = 0x278, //!< Filter Object Register 17
RegMCP251XFD_CiMASK17 = 0x27C, //!< Filter Mask Register 17
RegMCP251XFD_CiFLTOBJ18 = 0x280, //!< Filter Object Register 18
RegMCP251XFD_CiMASK18 = 0x284, //!< Filter Mask Register 18
RegMCP251XFD_CiFLTOBJ19 = 0x288, //!< Filter Object Register 19
RegMCP251XFD_CiMASK19 = 0x28C, //!< Filter Mask Register 19
RegMCP251XFD_CiFLTOBJ20 = 0x290, //!< Filter Object Register 20
RegMCP251XFD_CiMASK20 = 0x294, //!< Filter Mask Register 20
RegMCP251XFD_CiFLTOBJ21 = 0x298, //!< Filter Object Register 21
RegMCP251XFD_CiMASK21 = 0x29C, //!< Filter Mask Register 21
RegMCP251XFD_CiFLTOBJ22 = 0x2A0, //!< Filter Object Register 22
RegMCP251XFD_CiMASK22 = 0x2A4, //!< Filter Mask Register 22
RegMCP251XFD_CiFLTOBJ23 = 0x2A8, //!< Filter Object Register 23
RegMCP251XFD_CiMASK23 = 0x2AC, //!< Filter Mask Register 23
RegMCP251XFD_CiFLTOBJ24 = 0x2B0, //!< Filter Object Register 24
RegMCP251XFD_CiMASK24 = 0x2B4, //!< Filter Mask Register 24
RegMCP251XFD_CiFLTOBJ25 = 0x2B8, //!< Filter Object Register 25
RegMCP251XFD_CiMASK25 = 0x2BC, //!< Filter Mask Register 25
RegMCP251XFD_CiFLTOBJ26 = 0x2C0, //!< Filter Object Register 26
RegMCP251XFD_CiMASK26 = 0x2C4, //!< Filter Mask Register 26
RegMCP251XFD_CiFLTOBJ27 = 0x2C8, //!< Filter Object Register 27
RegMCP251XFD_CiMASK27 = 0x2CC, //!< Filter Mask Register 27
RegMCP251XFD_CiFLTOBJ28 = 0x2D0, //!< Filter Object Register 28
RegMCP251XFD_CiMASK28 = 0x2D4, //!< Filter Mask Register 28
RegMCP251XFD_CiFLTOBJ29 = 0x2D8, //!< Filter Object Register 29
RegMCP251XFD_CiMASK29 = 0x2DC, //!< Filter Mask Register 29
RegMCP251XFD_CiFLTOBJ30 = 0x2E0, //!< Filter Object Register 30
RegMCP251XFD_CiMASK30 = 0x2E4, //!< Filter Mask Register 30
RegMCP251XFD_CiFLTOBJ31 = 0x2E8, //!< Filter Object Register 31
RegMCP251XFD_CiMASK31 = 0x2EC, //!< Filter Mask Register 31
// MCP251XFD Specific Registers
RegMCP251XFD_OSC = 0xE00, //!< Oscillator Control Register
RegMCP251XFD_OSC_CONFIG = RegMCP251XFD_OSC+0, //!< Oscillator Control Register - Configuration register
RegMCP251XFD_OSC_CHECK = RegMCP251XFD_OSC+1, //!< Oscillator Control Register - Check frequency configuration register
#if defined(_MSC_VER) || (defined(__cplusplus) && (__cplusplus >= 201103L/*C++11*/)) || (!defined(__cplusplus))
RegMCP251XFD_IOCON = 0xE04, //!< Input/Output Control Register
//!< @deprecated Use RegMCP251XFD_IOCON_x subregisters with MCP251XFD_ReadSFR8() and MCP251XFD_WriteSFR8(). Follows datasheets errata for: Writing multiple bytes to the IOCON register using one SPI WRITE instruction may overwrite LAT0 and LAT1
#endif
RegMCP251XFD_IOCON_DIRECTION = 0xE04+0, //!< Input/Output Control Register - Pins direction
RegMCP251XFD_IOCON_OUTLEVEL = 0xE04+1, //!< Input/Output Control Register - Pin output level
RegMCP251XFD_IOCON_INLEVEL = 0xE04+2, //!< Input/Output Control Register - Pin input level
RegMCP251XFD_IOCON_PINMODE = 0xE04+3, //!< Input/Output Control Register - Pin mode
RegMCP251XFD_CRC = 0xE08, //!< CRC Register
RegMCP251XFD_CRC_CRC = RegMCP251XFD_CRC+0, //!< CRC Register - Last CRC mismatch
RegMCP251XFD_CRC_FLAGS = RegMCP251XFD_CRC+2, //!< CRC Register - Status flags
RegMCP251XFD_CRC_CONFIG = RegMCP251XFD_CRC+3, //!< CRC Register - Interrupts enable
RegMCP251XFD_ECCCON = 0xE0C, //!< ECC Control Register
RegMCP251XFD_ECCCON_ENABLE = RegMCP251XFD_ECCCON+0, //!< ECC Control Register - Interrupt and ECC enable
RegMCP251XFD_ECCCON_PARITY = RegMCP251XFD_ECCCON+1, //!< ECC Control Register - Fixed parity value
RegMCP251XFD_ECCSTAT = 0xE10, //!< ECC Status Register
RegMCP251XFD_ECCSTAT_FLAGS = RegMCP251XFD_ECCSTAT+0, //!< ECC Status Register - Status flags
RegMCP251XFD_ECCSTAT_ERRADDR = RegMCP251XFD_ECCSTAT+2, //!< ECC Status Register - ECC error address
RegMCP251XFD_DEVID = 0xE14, //!< Device ID Register
} eMCP251XFD_Registers;
//-----------------------------------------------------------------------------
#if defined(__GNUC__) && !(defined(__cplusplus) && (__cplusplus >= 201103L/*C++11*/)) || (!defined(__cplusplus))
typedef __attribute__((deprecated)) eMCP251XFD_Registers eMCP251XFD_Registers_deprecated; //! Create a new type for deprecated registers
# define RegMCP251XFD_IOCON ((eMCP251XFD_Registers_deprecated)RegMCP251XFD_IOCON) //! Override RegMCP251XFD_IOCON definition to force deprecated warning for the use of this register
#elif defined _MSC_VER
# pragma deprecated(RegMCP251XFD_IOCON)
#endif
//-----------------------------------------------------------------------------
//********************************************************************************************************************
// MCP251XFD Specific Controller Registers
//********************************************************************************************************************
//! Oscillator Control Register
MCP251XFD_PACKITEM
typedef union __MCP251XFD_PACKED__ MCP251XFD_OSC_Register
{
uint32_t OSC;
uint8_t Bytes[sizeof(uint32_t)];
struct
{
uint32_t PLLEN : 1; //!< 0 - PLL Enable (This bit can only be modified in Configuration mode): 1 = System Clock from 10x PLL ; 0 = System Clock comes directly from XTAL oscillator
uint32_t : 1; //!< 1
uint32_t OSCDIS : 1; //!< 2 - Clock (Oscillator) Disable: 1 = Clock disabled, the device is in Sleep mode ; 0 = Enable Clock (Clearing while in Sleep mode will wake-up the device and put it back in Configuration mode)
uint32_t LPMEN : 1; //!< 3 - (MCP2518FD only) Low Power Mode (LPM) Enable: 1 = When in LPM, the device will stop the clock and power down the majority of the chip. Register and RAM values will be lost. The device will wake-up due to asserting nCS, or due to RXCAN activity ; 0 = When in Sleep mode, the device will stop the clock, and retain it’s register and RAM values. It will wake-up due to clearing the OSCDIS bit, or due to RXCAN activity
uint32_t SCLKDIV: 1; //!< 4 - System Clock Divisor (This bit can only be modified in Configuration mode): 1 = SCLK is divided by 2 ; 0 = SCLK is divided by 1
uint32_t CLKODIV: 2; //!< 5-6 - Clock Output Divisor: 11 = CLKO is divided by 10 ; 10 = CLKO is divided by 4 ; 01 = CLKO is divided by 2 ; 00 = CLKO is divided by 1
uint32_t : 1; //!< 7
uint32_t PLLRDY : 1; //!< 8 - PLL Ready: 1 = PLL Locked ; 0 = PLL not ready
uint32_t : 1; //!< 9
uint32_t OSCRDY : 1; //!< 10 - Clock Ready: 1 = Clock is running and stable ; 0 = Clock not ready or off
uint32_t : 1; //!< 11
uint32_t SCLKRDY: 1; //!< 12 - Synchronized SCLKDIV bit: 1 = SCLKDIV 1 ; 0 = SCLKDIV 0
uint32_t : 19; //!< 13-31
} Bits;
} MCP251XFD_OSC_Register;
MCP251XFD_UNPACKITEM;
MCP251XFD_CONTROL_ITEM_SIZE(MCP251XFD_OSC_Register, 4);
#define MCP251XFD_SFR_OSC_PLLEN ((uint32_t)(0x1u << 0)) //!< PLL Enable
#define MCP251XFD_SFR_OSC_PLLDIS ((uint32_t)(0x0u << 0)) //!< PLL Disable
#define MCP251XFD_SFR_OSC_OSCDIS ((uint32_t)(0x1u << 2)) //!< Clock (Oscillator) Disable, device is in sleep mode
#define MCP251XFD_SFR_OSC_WAKEUP ((uint32_t)(0x0u << 2)) //!< Device wake-up from sleep and put it in Configuration mode
#define MCP251XFD_SFR_OSC_LPMEN ((uint32_t)(0x1u << 3)) //!< Low Power Mode (LPM) Enable; Setting LPMEN doesn’t actually put the device in LPM. It selects which Sleep mode will be entered after requesting Sleep mode using CiCON.REQOP. In order to wake up on RXCAN activity, CiINT.WAKIE must be set
#define MCP251XFD_SFR_OSC_LPMDIS ((uint32_t)(0x0u << 3)) //!< Low Power Mode (LPM) Disable; The device is in sleep mode
//! System Clock Divisor for the OSC.SCLKDIV register
typedef enum
{
MCP251XFD_SCLK_DivBy1 = 0b0, //!< System Clock Divisor by 1 (default)
MCP251XFD_SCLK_DivBy2 = 0b1, //!< System Clock Divisor by 2
} eMCP251XFD_SCLKDIV;
#define MCP251XFD_SFR_OSC_SCLKDIV_Pos 4
#define MCP251XFD_SFR_OSC_SCLKDIV_Mask (0x1u << MCP251XFD_SFR_OSC_SCLKDIV_Pos)
#define MCP251XFD_SFR_OSC_SCLKDIV_SET(value) (((uint32_t)(value) << MCP251XFD_SFR_OSC_SCLKDIV_Pos) & MCP251XFD_SFR_OSC_SCLKDIV_Mask) //!< System Clock Divisor
//! Clock Output Divisor for the OSC.CLKODIV register
typedef enum
{
MCP251XFD_CLKO_DivBy1 = 0b000, //!< Clock Output Divisor by 1
MCP251XFD_CLKO_DivBy2 = 0b001, //!< Clock Output Divisor by 2
MCP251XFD_CLKO_DivBy4 = 0b010, //!< Clock Output Divisor by 4
MCP251XFD_CLKO_DivBy10 = 0b011, //!< Clock Output Divisor by 10 (default)
MCP251XFD_CLKO_SOF = 0b111, //!< CLKO pin output Start Of Frame (Not configured in the OSC.CLKODIV register)
} eMCP251XFD_CLKODIV;
#define MCP251XFD_SFR_OSC_CLKODIV_Pos 5
#define MCP251XFD_SFR_OSC_CLKODIV_Mask (0x3u << MCP251XFD_SFR_OSC_CLKODIV_Pos)
#define MCP251XFD_SFR_OSC_CLKODIV_SET(value) (((uint32_t)(value) << MCP251XFD_SFR_OSC_CLKODIV_Pos) & MCP251XFD_SFR_OSC_CLKODIV_Mask) //!< Clock Output Divisor
#define MCP251XFD_SFR_OSC_PLLRDY ((uint32_t)(0x1u << 8)) //!< PLL Ready
#define MCP251XFD_SFR_OSC_OSCRDY ((uint32_t)(0x1u << 10)) //!< Clock Ready
#define MCP251XFD_SFR_OSC_SCLKRDY ((uint32_t)(0x1u << 12)) //!< Synchronized SCLKDIV
//*** Byte version access to Registers ***
#define MCP251XFD_SFR_OSC8_PLLEN ((uint8_t)(0x1u << 0)) //!< PLL Enable
#define MCP251XFD_SFR_OSC8_PLLDIS ((uint8_t)(0x0u << 0)) //!< PLL Disable
#define MCP251XFD_SFR_OSC8_OSCDIS ((uint8_t)(0x1u << 2)) //!< Clock (Oscillator) Disable, device is in sleep mode
#define MCP251XFD_SFR_OSC8_WAKEUP ((uint8_t)(0x0u << 2)) //!< Device wake-up from sleep and put it in Configuration mode
#define MCP251XFD_SFR_OSC8_LPMEN ((uint8_t)(0x1u << 3)) //!< Low Power Mode (LPM) Enable; Setting LPMEN doesn’t actually put the device in LPM. It selects which Sleep mode will be entered after requesting Sleep mode using CiCON.REQOP. In order to wake up on RXCAN activity, CiINT.WAKIE must be set
#define MCP251XFD_SFR_OSC8_LPMDIS ((uint8_t)(0x0u << 3)) //!< Low Power Mode (LPM) Disable; The device is in sleep mode
#define MCP251XFD_SFR_OSC8_SCLKDIV_Pos 4
#define MCP251XFD_SFR_OSC8_SCLKDIV_Mask (0x1u << MCP251XFD_SFR_OSC8_SCLKDIV_Pos)
#define MCP251XFD_SFR_OSC8_SCLKDIV_SET(value) (((uint8_t)(value) << MCP251XFD_SFR_OSC8_SCLKDIV_Pos) & MCP251XFD_SFR_OSC8_SCLKDIV_Mask) //!< System Clock Divisor
#define MCP251XFD_SFR_OSC8_CLKODIV_Pos 5
#define MCP251XFD_SFR_OSC8_CLKODIV_Mask (0x3u << MCP251XFD_SFR_OSC8_CLKODIV_Pos)
#define MCP251XFD_SFR_OSC8_CLKODIV_SET(value) (((uint8_t)(value) << MCP251XFD_SFR_OSC8_CLKODIV_Pos) & MCP251XFD_SFR_OSC8_CLKODIV_Mask) //!< Clock Output Divisor
#define MCP251XFD_SFR_OSC8_PLLRDY ((uint8_t)(0x1u << 0)) //!< PLL Ready
#define MCP251XFD_SFR_OSC8_OSCRDY ((uint8_t)(0x1u << 2)) //!< Clock Ready
#define MCP251XFD_SFR_OSC8_SCLKRDY ((uint8_t)(0x1u << 4)) //!< Synchronized SCLKDIV
#define MCP251XFD_SFR_OSC8_CHECKFLAGS (MCP251XFD_SFR_OSC8_PLLRDY | MCP251XFD_SFR_OSC8_OSCRDY | MCP251XFD_SFR_OSC8_SCLKRDY) //!< Oscillator check flags
//-----------------------------------------------------------------------------
//! Xtal/Oscillator (CLKIN) multiplier/divisor to SYSCLK
typedef enum
{
MCP251XFD_SYSCLK_IS_CLKIN , //!< SYSCLK is CLKIN (no PLL, eMCP251XFD_SCLKDIV.SCLK_DivBy1). For CLKIN at 20MHz or 40MHz
MCP251XFD_SYSCLK_IS_CLKIN_DIV_2 , //!< SYSCLK is CLKIN divide by 2 (no PLL, eMCP251XFD_SCLKDIV.SCLK_DivBy2). For CLKIN at 20MHz or 40MHz
MCP251XFD_SYSCLK_IS_CLKIN_MUL_5 , //!< SYSCLK is CLKIN multiply by 5 (PLL enable, eMCP251XFD_SCLKDIV.SCLK_DivBy2). For CLKIN at 4MHz
MCP251XFD_SYSCLK_IS_CLKIN_MUL_10, //!< SYSCLK is CLKIN multiply by 10 (PLL enable, eMCP251XFD_SCLKDIV.SCLK_DivBy1). For CLKIN at 2MHz or 4MHz
} eMCP251XFD_CLKINtoSYSCLK;
//-----------------------------------------------------------------------------
#define MCP251XFD_GPIO0_Mask ( 0b01 ) //!< Define the GPIO0 mask
#define MCP251XFD_GPIO1_Mask ( 0b10 ) //!< Define the GPIO1 mask
#define MCP251XFD_GPIO0_OUTPUT ( 0b00 ) //!< Define the GPIO0 as output
#define MCP251XFD_GPIO0_INPUT ( 0b01 ) //!< Define the GPIO0 as input
#define MCP251XFD_GPIO1_OUTPUT ( 0b00 ) //!< Define the GPIO1 as output
#define MCP251XFD_GPIO1_INPUT ( 0b10 ) //!< Define the GPIO1 as input
#define MCP251XFD_GPIO0_LOW ( 0b00 ) //!< Define the GPIO0 low status
#define MCP251XFD_GPIO0_HIGH ( 0b01 ) //!< Define the GPIO0 high status
#define MCP251XFD_GPIO1_LOW ( 0b00 ) //!< Define the GPIO1 low status
#define MCP251XFD_GPIO1_HIGH ( 0b10 ) //!< Define the GPIO1 high status
//! Input/Output Control Register
MCP251XFD_PACKITEM
typedef union __MCP251XFD_PACKED__ MCP251XFD_IOCON_Register
{
uint32_t IOCON;
uint8_t Bytes[sizeof(uint32_t)];
struct
{
uint32_t TRIS0 : 1; //!< 0 - GPIO0 Data Direction. If PM0 = '0', TRIS0 will be ignored and the pin will be an output: '1' = Input Pin ; '0' = Output Pin
uint32_t TRIS1 : 1; //!< 1 - GPIO1 Data Direction. If PM1 = '0', TRIS1 will be ignored and the pin will be an output: '1' = Input Pin ; '0' = Output Pin
uint32_t : 4; //!< 2-5
uint32_t XSTBYEN: 1; //!< 6 - Enable Transceiver Standby Pin Control: '1' = XSTBY control enabled ; '0' = XSTBY control disabled
uint32_t : 1; //!< 7
uint32_t LAT0 : 1; //!< 8 - GPIO0 Latch: '1' = Drive Pin High ; '0' = Drive Pin Low
uint32_t LAT1 : 1; //!< 9 - GPIO1 Latch: '1' = Drive Pin High ; '0' = Drive Pin Low
uint32_t : 6; //!< 10-15
uint32_t GPIO0 : 1; //!< 16 - GPIO0 Status: '1' = VGPIO0 > VIH ; '0' = VGPIO0 < VIL
uint32_t GPIO1 : 1; //!< 17 - GPIO1 Status: '1' = VGPIO0 > VIH ; '0' = VGPIO0 < VIL
uint32_t : 6; //!< 18-23
uint32_t PM0 : 1; //!< 24 - GPIO Pin Mode: '1' = Pin is used as GPIO0 ; '0' = Interrupt Pin INT0, asserted when CiINT.TXIF and TXIE are set
uint32_t PM1 : 1; //!< 25 - GPIO Pin Mode: '1' = Pin is used as GPIO1 ; '0' = Interrupt Pin INT1, asserted when CiINT.TXIF and TXIE are set
uint32_t : 2; //!< 26-27
uint32_t TXCANOD: 1; //!< 28 - TXCAN Open Drain Mode: '1' = Open Drain Output ; '0' = Push/Pull Output
uint32_t SOF : 1; //!< 29 - Start-Of-Frame signal: SOF signal on CLKO pin ; Clock on CLKO pin
uint32_t INTOD : 1; //!< 30 - Interrupt pins Open Drain Mode: '1' = Open Drain Output ; '0' = Push/Pull Output
uint32_t : 1; //!< 31
} Bits;
} MCP251XFD_IOCON_Register;
MCP251XFD_UNPACKITEM;
MCP251XFD_CONTROL_ITEM_SIZE(MCP251XFD_IOCON_Register, 4);
#define MCP251XFD_SFR_IOCON_GPIO0_INPUT ((uint32_t)(0x1u << 0)) //!< GPIO0 Data Input Direction
#define MCP251XFD_SFR_IOCON_GPIO0_OUTPUT ((uint32_t)(0x0u << 0)) //!< GPIO0 Data Output Direction
#define MCP251XFD_SFR_IOCON_GPIO1_INPUT ((uint32_t)(0x1u << 1)) //!< GPIO1 Data Input Direction
#define MCP251XFD_SFR_IOCON_GPIO1_OUTPUT ((uint32_t)(0x0u << 1)) //!< GPIO1 Data Output Direction
#define MCP251XFD_SFR_IOCON_XSTBYEN ((uint32_t)(0x1u << 6)) //!< Enable Transceiver Standby Pin Control
#define MCP251XFD_SFR_IOCON_XSTBYDIS ((uint32_t)(0x0u << 6)) //!< Disable Transceiver Standby Pin Control
#define MCP251XFD_SFR_IOCON_GPIO0_HIGH ((uint32_t)(0x1u << 8)) //!< GPIO0 Latch Drive Pin High
#define MCP251XFD_SFR_IOCON_GPIO0_LOW ((uint32_t)(0x0u << 8)) //!< GPIO0 Latch Drive Pin Low
#define MCP251XFD_SFR_IOCON_GPIO1_HIGH ((uint32_t)(0x1u << 9)) //!< GPIO1 Latch Drive Pin High
#define MCP251XFD_SFR_IOCON_GPIO1_LOW ((uint32_t)(0x0u << 9)) //!< GPIO1 Latch Drive Pin Low
#define MCP251XFD_SFR_IOCON_GPIO0_STATUS ((uint32_t)(0x1u << 16)) //!< GPIO0 Status
#define MCP251XFD_SFR_IOCON_GPIO1_STATUS ((uint32_t)(0x1u << 17)) //!< GPIO1 Status
#define MCP251XFD_SFR_IOCON_GPIO0_MODE ((uint32_t)(0x1u << 24)) //!< GPIO0 GPIO Pin Mode
#define MCP251XFD_SFR_IOCON_GPIO0_INT0 ((uint32_t)(0x0u << 24)) //!< GPIO0 Interrupt Pin INT0, asserted when CiINT.TXIF and TXIE are set
#define MCP251XFD_SFR_IOCON_GPIO1_MODE ((uint32_t)(0x1u << 25)) //!< GPIO1 GPIO Pin Mode
#define MCP251XFD_SFR_IOCON_GPIO1_INT1 ((uint32_t)(0x0u << 25)) //!< GPIO1 Interrupt Pin INT1, asserted when CiINT.RXIF and RXIE are set
#define MCP251XFD_SFR_IOCON_TXCANOD ((uint32_t)(0x1u << 28)) //!< TXCAN Open Drain Mode
#define MCP251XFD_SFR_IOCON_SOF ((uint32_t)(0x1u << 29)) //!< Start-Of-Frame signal
#define MCP251XFD_SFR_IOCON_INTOD ((uint32_t)(0x1u << 30)) //!< Interrupt pins Open Drain Mode
//*** Byte version access to Registers ***
#define MCP251XFD_SFR_IOCON8_GPIO0_INPUT ((uint8_t)(0x1u << 0)) //!< GPIO0 Data Input Direction
#define MCP251XFD_SFR_IOCON8_GPIO0_OUTPUT ((uint8_t)(0x0u << 0)) //!< GPIO0 Data Output Direction
#define MCP251XFD_SFR_IOCON8_GPIO1_INPUT ((uint8_t)(0x1u << 1)) //!< GPIO1 Data Input Direction
#define MCP251XFD_SFR_IOCON8_GPIO1_OUTPUT ((uint8_t)(0x0u << 1)) //!< GPIO1 Data Output Direction
#define MCP251XFD_SFR_IOCON8_XSTBYEN ((uint8_t)(0x1u << 6)) //!< Enable Transceiver Standby Pin Control
#define MCP251XFD_SFR_IOCON8_XSTBYDIS ((uint8_t)(0x0u << 6)) //!< Disable Transceiver Standby Pin Control
#define MCP251XFD_SFR_IOCON8_GPIO0_HIGH ((uint8_t)(0x1u << 0)) //!< GPIO0 Latch Drive Pin High
#define MCP251XFD_SFR_IOCON8_GPIO0_LOW ((uint8_t)(0x0u << 0)) //!< GPIO0 Latch Drive Pin Low
#define MCP251XFD_SFR_IOCON8_GPIO1_HIGH ((uint8_t)(0x1u << 1)) //!< GPIO1 Latch Drive Pin High
#define MCP251XFD_SFR_IOCON8_GPIO1_LOW ((uint8_t)(0x0u << 1)) //!< GPIO1 Latch Drive Pin Low
#define MCP251XFD_SFR_IOCON8_GPIO0_STATUS ((uint8_t)(0x1u << 0)) //!< GPIO0 Status
#define MCP251XFD_SFR_IOCON8_GPIO1_STATUS ((uint8_t)(0x1u << 1)) //!< GPIO1 Status
#define MCP251XFD_SFR_IOCON8_GPIO0_MODE ((uint8_t)(0x1u << 0)) //!< GPIO0 GPIO Pin Mode
#define MCP251XFD_SFR_IOCON8_GPIO0_INT0 ((uint8_t)(0x0u << 0)) //!< GPIO0 Interrupt Pin INT0, asserted when CiINT.TXIF and TXIE are set
#define MCP251XFD_SFR_IOCON8_GPIO1_MODE ((uint8_t)(0x1u << 1)) //!< GPIO1 GPIO Pin Mode
#define MCP251XFD_SFR_IOCON8_GPIO1_INT1 ((uint8_t)(0x0u << 1)) //!< GPIO1 Interrupt Pin INT1, asserted when CiINT.RXIF and RXIE are set
#define MCP251XFD_SFR_IOCON8_TXCANOD ((uint8_t)(0x1u << 4)) //!< TXCAN Open Drain Mode
#define MCP251XFD_SFR_IOCON8_SOF ((uint8_t)(0x1u << 5)) //!< Start-Of-Frame signal
#define MCP251XFD_SFR_IOCON8_INTOD ((uint8_t)(0x1u << 6)) //!< Interrupt pins Open Drain Mode
//! INT0/GPIO0/XSTBY configuration for the IOCON register
typedef enum
{
MCP251XFD_PIN_AS_INT0_TX = 0b00, //!< INT0/GPIO0/XSTBY pin as TX Interrupt output (active low)
MCP251XFD_PIN_AS_GPIO0_IN = 0b01, //!< INT0/GPIO0/XSTBY pin as GPIO input
MCP251XFD_PIN_AS_GPIO0_OUT = 0b10, //!< INT0/GPIO0/XSTBY pin as GPIO output
MCP251XFD_PIN_AS_XSTBY = 0b11, //!< INT0/GPIO0/XSTBY pin as Transceiver Standby output
} eMCP251XFD_GPIO0Mode;
//! INT1/GPIO1 configuration for the IOCON register
typedef enum
{
MCP251XFD_PIN_AS_INT1_RX = 0b00, //!< INT1/GPIO1 pin as RX Interrupt output (active low)
MCP251XFD_PIN_AS_GPIO1_IN = 0b01, //!< INT1/GPIO1 pin as GPIO input
MCP251XFD_PIN_AS_GPIO1_OUT = 0b10, //!< INT1/GPIO1 pin as GPIO output
} eMCP251XFD_GPIO1Mode;
//! Output configuration for the IOCON.INTOD and the IOCON.TXCANOD register
typedef enum
{
MCP251XFD_PINS_PUSHPULL_OUT = 0b00, //!< Pin with Push/Pull output
MCP251XFD_PINS_OPENDRAIN_OUT = 0b01, //!< Pin with Open Drain output
} eMCP251XFD_OutMode;
//-----------------------------------------------------------------------------
//! CRC Register
MCP251XFD_PACKITEM
typedef union __MCP251XFD_PACKED__ MCP251XFD_CRC_Register
{
uint32_t CRCreg;
uint8_t Bytes[sizeof(uint32_t)];
struct
{
uint32_t CRCbits : 16; //!< 0-15 - Cycle Redundancy Check from last CRC mismatch
uint32_t CRCERRIF: 1; //!< 16 - CRC Error Interrupt Flag: '1' = CRC mismatch occurred ; '0' = No CRC error has occurred
uint32_t FERRIF : 1; //!< 17 - CRC Command Format Error Interrupt Flag: '1' = Number of Bytes mismatch during “SPI with CRC” command occurred ; '0' = No SPI CRC command format error occurred
uint32_t : 6; //!< 18-23
uint32_t CRCERRIE: 1; //!< 24 - CRC Error Interrupt Enable
uint32_t FERRIE : 1; //!< 25 - CRC Command Format Error Interrupt Enable
uint32_t : 6; //!< 26-31
} Bits;
} MCP251XFD_CRC_Register;
MCP251XFD_UNPACKITEM;
MCP251XFD_CONTROL_ITEM_SIZE(MCP251XFD_CRC_Register, 4);
#define MCP251XFD_SFR_CRC_Pos 0
#define MCP251XFD_SFR_CRC_Mask (0xFFFFu << MCP251XFD_SFR_CRC_Pos)
#define MCP251XFD_SFR_CRC_SET(value) (((uint32_t)(value) << MCP251XFD_SFR_CRC_Pos) & MCP251XFD_SFR_CRC_Mask) //!< Cycle Redundancy Check from last CRC mismatch
#define MCP251XFD_SFR_CRC_CRCERRIF ((uint32_t)(0x1u << 16)) //!< CRC Error Interrupt Flag
#define MCP251XFD_SFR_CRC_FERRIF ((uint32_t)(0x1u << 17)) //!< CRC Command Format Error Interrupt Flag
#define MCP251XFD_SFR_CRC_CRCERRIE ((uint32_t)(0x1u << 24)) //!< CRC Error Interrupt Enable
#define MCP251XFD_SFR_CRC_FERRIE ((uint32_t)(0x1u << 25)) //!< CRC Command Format Error Interrupt Enable
//*** Byte version access to Registers ***
#define MCP251XFD_SFR_CRC16_Pos 0
#define MCP251XFD_SFR_CRC16_Mask (0xFFFFu << MCP251XFD_SFR_CRC16_Pos)
#define MCP251XFD_SFR_CRC16_SET(value) (((uint16_t)(value) << MCP251XFD_SFR_CRC16_Pos) & MCP251XFD_SFR_CRC16_Mask) //!< Cycle Redundancy Check from last CRC mismatch
#define MCP251XFD_SFR_CRC8_CRCERRIF ((uint8_t)(0x1u << 0)) //!< CRC Error Interrupt Flag
#define MCP251XFD_SFR_CRC8_FERRIF ((uint8_t)(0x1u << 1)) //!< CRC Command Format Error Interrupt Flag
#define MCP251XFD_SFR_CRC8_CRCERRIE ((uint8_t)(0x1u << 0)) //!< CRC Error Interrupt Enable
#define MCP251XFD_SFR_CRC8_CRCERRID ((uint8_t)(0x0u << 0)) //!< CRC Error Interrupt Disable
#define MCP251XFD_SFR_CRC8_FERRIE ((uint8_t)(0x1u << 1)) //!< CRC Command Format Error Interrupt Enable
#define MCP251XFD_SFR_CRC8_FERRID ((uint8_t)(0x0u << 1)) //!< CRC Command Format Error Interrupt Disable
//! CRC Events
typedef enum
{
MCP251XFD_CRC_NO_EVENT = 0x00, //!< No CRC events
MCP251XFD_CRC_CRCERR_EVENT = 0x01, //!< CRC Error Interrupt event
MCP251XFD_CRC_FORMERR_EVENT = 0x02, //!< CRC Command Format Error Interrupt event
MCP251XFD_CRC_ALL_EVENTS = 0x03, //!< All CRC interrupts events
MCP251XFD_CRC_EVENTS_MASK = 0x03, //!< CRC events mask
} eMCP251XFD_CRCEvents;
typedef eMCP251XFD_CRCEvents setMCP251XFD_CRCEvents; //! Set of CRC Events (can be OR'ed)
//-----------------------------------------------------------------------------
//! ECC Control Register
MCP251XFD_PACKITEM
typedef union __MCP251XFD_PACKED__ MCP251XFD_ECCCON_Register
{
uint32_t ECCCON;
uint8_t Bytes[sizeof(uint32_t)];
struct
{
uint32_t ECCEN : 1; //!< 0 - ECC Enable: '1' = ECC enabled ; '0' = ECC disabled
uint32_t SECIE : 1; //!< 1 - Single Error Correction Interrupt Enable Flag
uint32_t DEDIE : 1; //!< 2 - Double Error Detection Interrupt Enable Flag
uint32_t : 5; //!< 3- 7
uint32_t PARITY: 7; //!< 8-14 - Parity bits used during write to RAM when ECC is disabled
uint32_t : 17; //!< 15-31
} Bits;
} MCP251XFD_ECCCON_Register;
MCP251XFD_UNPACKITEM;
MCP251XFD_CONTROL_ITEM_SIZE(MCP251XFD_ECCCON_Register, 4);
#define MCP251XFD_SFR_ECCCON_ECCEN ((uint32_t)(0x1u << 0)) //!< ECC Enable
#define MCP251XFD_SFR_ECCCON_ECCDIS ((uint32_t)(0x0u << 0)) //!< ECC Disable
#define MCP251XFD_SFR_ECCCON_SECIE ((uint32_t)(0x1u << 1)) //!< Single Error Correction Interrupt Enable Flag
#define MCP251XFD_SFR_ECCCON_SECID ((uint32_t)(0x0u << 1)) //!< Single Error Correction Interrupt Disable Flag
#define MCP251XFD_SFR_ECCCON_DEDIE ((uint32_t)(0x1u << 2)) //!< Double Error Detection Interrupt Enable Flag
#define MCP251XFD_SFR_ECCCON_DEDID ((uint32_t)(0x0u << 2)) //!< Double Error Detection Interrupt Disable Flag
#define MCP251XFD_SFR_ECCCON_PARITY_Pos 8
#define MCP251XFD_SFR_ECCCON_PARITY_Mask (0x3Fu << MCP251XFD_SFR_ECCCON_PARITY_Pos)
#define MCP251XFD_SFR_ECCCON_PARITY_GET(value) (((uint32_t)(value) & MCP251XFD_SFR_ECCCON_PARITY_Mask) >> MCP251XFD_SFR_ECCCON_PARITY_Pos) //!< Parity bits used during write to RAM when ECC is disabled
#define MCP251XFD_SFR_ECCCON_PARITY_SET(value) (((uint32_t)(value) << MCP251XFD_SFR_ECCCON_PARITY_Pos) & MCP251XFD_SFR_ECCCON_PARITY_Mask) //!< Get parity bits used during write to RAM when ECC is disabled
//*** Byte version access to Registers ***
#define MCP251XFD_SFR_ECCCON8_ECCEN ((uint8_t)(0x1u << 0)) //!< ECC Enable
#define MCP251XFD_SFR_ECCCON8_ECCDIS ((uint8_t)(0x0u << 0)) //!< ECC Disable
#define MCP251XFD_SFR_ECCCON8_SECIE ((uint8_t)(0x1u << 1)) //!< Single Error Correction Interrupt Enable Flag
#define MCP251XFD_SFR_ECCCON8_SECID ((uint8_t)(0x0u << 1)) //!< Single Error Correction Interrupt Disable Flag
#define MCP251XFD_SFR_ECCCON8_DEDIE ((uint8_t)(0x1u << 2)) //!< Double Error Detection Interrupt Enable Flag
#define MCP251XFD_SFR_ECCCON8_DEDID ((uint8_t)(0x0u << 2)) //!< Double Error Detection Interrupt Disable Flag
#define MCP251XFD_SFR_ECCCON8_PARITY_Pos 0
#define MCP251XFD_SFR_ECCCON8_PARITY_Mask (0x3Fu << MCP251XFD_SFR_ECCCON8_PARITY_Pos)
#define MCP251XFD_SFR_ECCCON8_PARITY_GET(value) (((uint8_t)(value) & MCP251XFD_SFR_ECCCON8_PARITY_Mask) >> MCP251XFD_SFR_ECCCON8_PARITY_Pos) //!< Set parity bits used during write to RAM when ECC is disabled
#define MCP251XFD_SFR_ECCCON8_PARITY_SET(value) (((uint8_t)(value) << MCP251XFD_SFR_ECCCON8_PARITY_Pos) & MCP251XFD_SFR_ECCCON8_PARITY_Mask) //!< Get parity bits used during write to RAM when ECC is disabled
//-----------------------------------------------------------------------------
//! ECC Status Register
MCP251XFD_PACKITEM
typedef union __MCP251XFD_PACKED__ MCP251XFD_ECCSTAT_Register
{
uint32_t ECCSTAT;
uint8_t Bytes[sizeof(uint32_t)];
struct
{
uint32_t : 1; //!< 0
uint32_t SECIF : 1; //!< 1 - Single Error Correction Interrupt Flag: '1' = Single Error was corrected ; '0' = No Single Error occurred
uint32_t DEDIF : 1; //!< 2 - Double Error Detection Interrupt Flag: '1' = Double Error was detected ; '0' = No Double Error Detection occurred
uint32_t : 13; //!< 3-15
uint32_t ERRADDR: 12; //!< 16-27 - Address where last ECC error occurred
uint32_t : 4; //!< 28-31
} Bits;
} MCP251XFD_ECCSTAT_Register;
MCP251XFD_UNPACKITEM;
MCP251XFD_CONTROL_ITEM_SIZE(MCP251XFD_ECCSTAT_Register, 4);
#define MCP251XFD_SFR_ECCSTAT_SECIF ((uint32_t)(0x1u << 1)) //!< Single Error Correction Interrupt Flag
#define MCP251XFD_SFR_ECCSTAT_DEDIF ((uint32_t)(0x1u << 2)) //!< Double Error Detection Interrupt Flag
#define MCP251XFD_SFR_ECCSTAT_ERRADDR_Pos 16
#define MCP251XFD_SFR_ECCSTAT_ERRADDR_Mask (0xFFFu << MCP251XFD_SFR_ECCSTAT_ERRADDR_Pos)
#define MCP251XFD_SFR_ECCSTAT_ERRADDR_GET(value) (((uint32_t)(value) & MCP251XFD_SFR_ECCSTAT_ERRADDR_Mask) >> MCP251XFD_SFR_ECCSTAT_ERRADDR_Pos) //!< Get address where last ECC error occurred
//*** Byte version access to Registers ***
#define MCP251XFD_SFR_ECCSTAT8_SECIF ((uint8_t)(0x1u << 1)) //!< Single Error Correction Interrupt Flag
#define MCP251XFD_SFR_ECCSTAT8_DEDIF ((uint8_t)(0x1u << 2)) //!< Double Error Detection Interrupt Flag
#define MCP251XFD_SFR_ECCSTAT16_ERRADDR_Pos 0
#define MCP251XFD_SFR_ECCSTAT16_ERRADDR_Mask (0xFFFu << MCP251XFD_SFR_ECCSTAT16_ERRADDR_Pos)
#define MCP251XFD_SFR_ECCSTAT16_ERRADDR_GET(value) (((uint16_t)(value) & MCP251XFD_SFR_ECCSTAT16_ERRADDR_Mask) >> MCP251XFD_SFR_ECCSTAT16_ERRADDR_Pos) //!< Get address where last ECC error occurred
//! ECC Events
typedef enum
{
MCP251XFD_ECC_NO_EVENT = 0x00, //!< No ECC events
MCP251XFD_ECC_SEC_EVENT = 0x02, //!< ECC Single Error Correction Interrupt
MCP251XFD_ECC_DED_EVENT = 0x04, //!< ECC Double Error Detection Interrupt
MCP251XFD_ECC_ALL_EVENTS = 0x06, //!< All ECC interrupts events
MCP251XFD_ECC_EVENTS_MASK = 0x06, //!< ECC events mask
} eMCP251XFD_ECCEvents;
typedef eMCP251XFD_ECCEvents setMCP251XFD_ECCEvents; //! Set of ECC Events (can be OR'ed)
//-----------------------------------------------------------------------------
//! Device ID Register (MCP2518FD only)
MCP251XFD_PACKITEM
typedef union __MCP251XFD_PACKED__ MCP251XFD_DEVID_Register
{
uint32_t DEVID;
uint8_t Bytes[sizeof(uint32_t)];
struct
{
uint32_t REV: 4; //!< 0- 3 - Silicon Revision
uint32_t ID : 4; //!< 4- 7 - Device ID
uint32_t : 24; //!< 8-31
} Bits;
} MCP251XFD_DEVID_Register;
MCP251XFD_UNPACKITEM;
MCP251XFD_CONTROL_ITEM_SIZE(MCP251XFD_DEVID_Register, 4);
#define MCP251XFD_SFR_DEVID_REV_Pos 0
#define MCP251XFD_SFR_DEVID_REV_Mask (0xFu << MCP251XFD_SFR_DEVID_REV_Pos)
#define MCP251XFD_SFR_DEVID_REV_GET(value) (((uint32_t)(value) & MCP251XFD_SFR_DEVID_REV_Mask) >> MCP251XFD_SFR_DEVID_REV_Pos) //!< Get Silicon Revision
#define MCP251XFD_SFR_DEVID_ID_Pos 4
#define MCP251XFD_SFR_DEVID_ID_Mask (0xFu << MCP251XFD_SFR_DEVID_ID_Pos)
#define MCP251XFD_SFR_DEVID_ID_GET(value) (((uint32_t)(value) & MCP251XFD_SFR_DEVID_ID_Mask) >> MCP251XFD_SFR_DEVID_ID_Pos) //!< Get Device ID
//*** Byte version access to Registers ***
#define MCP251XFD_SFR_DEVID8_REV_Pos 0
#define MCP251XFD_SFR_DEVID8_REV_Mask (0xFu << MCP251XFD_SFR_DEVID8_REV_Pos)
#define MCP251XFD_SFR_DEVID8_REV_GET(value) (((uint32_t)(value) & MCP251XFD_SFR_DEVID8_REV_Mask) >> MCP251XFD_SFR_DEVID8_REV_Pos) //!< Get Silicon Revision
#define MCP251XFD_SFR_DEVID8_ID_Pos 4
#define MCP251XFD_SFR_DEVID8_ID_Mask (0xFu << MCP251XFD_SFR_DEVID8_ID_Pos)
#define MCP251XFD_SFR_DEVID8_ID_GET(value) (((uint32_t)(value) & MCP251XFD_SFR_DEVID8_ID_Mask) >> MCP251XFD_SFR_DEVID8_ID_Pos) //!< Get Device ID
//-----------------------------------------------------------------------------
//********************************************************************************************************************
// MCP251XFD CAN Controller Registers
//********************************************************************************************************************
//! CAN Control Register
MCP251XFD_PACKITEM
typedef union __MCP251XFD_PACKED__ MCP251XFD_CiCON_Register
{