Robobo
component_can.h
1 /* ----------------------------------------------------------------------------
2  * SAM Software Package License
3  * ----------------------------------------------------------------------------
4  * Copyright (c) 2012, Atmel Corporation
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following condition is met:
10  *
11  * - Redistributions of source code must retain the above copyright notice,
12  * this list of conditions and the disclaimer below.
13  *
14  * Atmel's name may not be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  * ----------------------------------------------------------------------------
28  */
29 
30 #ifndef _SAM3XA_CAN_COMPONENT_
31 #define _SAM3XA_CAN_COMPONENT_
32 
33 /* ============================================================================= */
35 /* ============================================================================= */
38 
39 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
40 
41 typedef struct {
50 } CanMb;
52 #define CANMB_NUMBER 8
53 typedef struct {
65  RoReg Reserved1[46];
68  RoReg Reserved2[69];
69  CanMb CAN_MB[CANMB_NUMBER];
70 } Can;
71 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
72 /* -------- CAN_MR : (CAN Offset: 0x0000) Mode Register -------- */
73 #define CAN_MR_CANEN (0x1u << 0)
74 #define CAN_MR_LPM (0x1u << 1)
75 #define CAN_MR_ABM (0x1u << 2)
76 #define CAN_MR_OVL (0x1u << 3)
77 #define CAN_MR_TEOF (0x1u << 4)
78 #define CAN_MR_TTM (0x1u << 5)
79 #define CAN_MR_TIMFRZ (0x1u << 6)
80 #define CAN_MR_DRPT (0x1u << 7)
81 #define CAN_MR_RXSYNC_Pos 24
82 #define CAN_MR_RXSYNC_Msk (0x7u << CAN_MR_RXSYNC_Pos)
83 #define CAN_MR_RXSYNC_DOUBLE_PP (0x0u << 24)
84 #define CAN_MR_RXSYNC_DOUBLE_PN (0x1u << 24)
85 #define CAN_MR_RXSYNC_SINGLE_P (0x2u << 24)
86 #define CAN_MR_RXSYNC_NONE (0x3u << 24)
87 /* -------- CAN_IER : (CAN Offset: 0x0004) Interrupt Enable Register -------- */
88 #define CAN_IER_MB0 (0x1u << 0)
89 #define CAN_IER_MB1 (0x1u << 1)
90 #define CAN_IER_MB2 (0x1u << 2)
91 #define CAN_IER_MB3 (0x1u << 3)
92 #define CAN_IER_MB4 (0x1u << 4)
93 #define CAN_IER_MB5 (0x1u << 5)
94 #define CAN_IER_MB6 (0x1u << 6)
95 #define CAN_IER_MB7 (0x1u << 7)
96 #define CAN_IER_ERRA (0x1u << 16)
97 #define CAN_IER_WARN (0x1u << 17)
98 #define CAN_IER_ERRP (0x1u << 18)
99 #define CAN_IER_BOFF (0x1u << 19)
100 #define CAN_IER_SLEEP (0x1u << 20)
101 #define CAN_IER_WAKEUP (0x1u << 21)
102 #define CAN_IER_TOVF (0x1u << 22)
103 #define CAN_IER_TSTP (0x1u << 23)
104 #define CAN_IER_CERR (0x1u << 24)
105 #define CAN_IER_SERR (0x1u << 25)
106 #define CAN_IER_AERR (0x1u << 26)
107 #define CAN_IER_FERR (0x1u << 27)
108 #define CAN_IER_BERR (0x1u << 28)
109 /* -------- CAN_IDR : (CAN Offset: 0x0008) Interrupt Disable Register -------- */
110 #define CAN_IDR_MB0 (0x1u << 0)
111 #define CAN_IDR_MB1 (0x1u << 1)
112 #define CAN_IDR_MB2 (0x1u << 2)
113 #define CAN_IDR_MB3 (0x1u << 3)
114 #define CAN_IDR_MB4 (0x1u << 4)
115 #define CAN_IDR_MB5 (0x1u << 5)
116 #define CAN_IDR_MB6 (0x1u << 6)
117 #define CAN_IDR_MB7 (0x1u << 7)
118 #define CAN_IDR_ERRA (0x1u << 16)
119 #define CAN_IDR_WARN (0x1u << 17)
120 #define CAN_IDR_ERRP (0x1u << 18)
121 #define CAN_IDR_BOFF (0x1u << 19)
122 #define CAN_IDR_SLEEP (0x1u << 20)
123 #define CAN_IDR_WAKEUP (0x1u << 21)
124 #define CAN_IDR_TOVF (0x1u << 22)
125 #define CAN_IDR_TSTP (0x1u << 23)
126 #define CAN_IDR_CERR (0x1u << 24)
127 #define CAN_IDR_SERR (0x1u << 25)
128 #define CAN_IDR_AERR (0x1u << 26)
129 #define CAN_IDR_FERR (0x1u << 27)
130 #define CAN_IDR_BERR (0x1u << 28)
131 /* -------- CAN_IMR : (CAN Offset: 0x000C) Interrupt Mask Register -------- */
132 #define CAN_IMR_MB0 (0x1u << 0)
133 #define CAN_IMR_MB1 (0x1u << 1)
134 #define CAN_IMR_MB2 (0x1u << 2)
135 #define CAN_IMR_MB3 (0x1u << 3)
136 #define CAN_IMR_MB4 (0x1u << 4)
137 #define CAN_IMR_MB5 (0x1u << 5)
138 #define CAN_IMR_MB6 (0x1u << 6)
139 #define CAN_IMR_MB7 (0x1u << 7)
140 #define CAN_IMR_ERRA (0x1u << 16)
141 #define CAN_IMR_WARN (0x1u << 17)
142 #define CAN_IMR_ERRP (0x1u << 18)
143 #define CAN_IMR_BOFF (0x1u << 19)
144 #define CAN_IMR_SLEEP (0x1u << 20)
145 #define CAN_IMR_WAKEUP (0x1u << 21)
146 #define CAN_IMR_TOVF (0x1u << 22)
147 #define CAN_IMR_TSTP (0x1u << 23)
148 #define CAN_IMR_CERR (0x1u << 24)
149 #define CAN_IMR_SERR (0x1u << 25)
150 #define CAN_IMR_AERR (0x1u << 26)
151 #define CAN_IMR_FERR (0x1u << 27)
152 #define CAN_IMR_BERR (0x1u << 28)
153 /* -------- CAN_SR : (CAN Offset: 0x0010) Status Register -------- */
154 #define CAN_SR_MB0 (0x1u << 0)
155 #define CAN_SR_MB1 (0x1u << 1)
156 #define CAN_SR_MB2 (0x1u << 2)
157 #define CAN_SR_MB3 (0x1u << 3)
158 #define CAN_SR_MB4 (0x1u << 4)
159 #define CAN_SR_MB5 (0x1u << 5)
160 #define CAN_SR_MB6 (0x1u << 6)
161 #define CAN_SR_MB7 (0x1u << 7)
162 #define CAN_SR_ERRA (0x1u << 16)
163 #define CAN_SR_WARN (0x1u << 17)
164 #define CAN_SR_ERRP (0x1u << 18)
165 #define CAN_SR_BOFF (0x1u << 19)
166 #define CAN_SR_SLEEP (0x1u << 20)
167 #define CAN_SR_WAKEUP (0x1u << 21)
168 #define CAN_SR_TOVF (0x1u << 22)
169 #define CAN_SR_TSTP (0x1u << 23)
170 #define CAN_SR_CERR (0x1u << 24)
171 #define CAN_SR_SERR (0x1u << 25)
172 #define CAN_SR_AERR (0x1u << 26)
173 #define CAN_SR_FERR (0x1u << 27)
174 #define CAN_SR_BERR (0x1u << 28)
175 #define CAN_SR_RBSY (0x1u << 29)
176 #define CAN_SR_TBSY (0x1u << 30)
177 #define CAN_SR_OVLSY (0x1u << 31)
178 /* -------- CAN_BR : (CAN Offset: 0x0014) Baudrate Register -------- */
179 #define CAN_BR_PHASE2_Pos 0
180 #define CAN_BR_PHASE2_Msk (0x7u << CAN_BR_PHASE2_Pos)
181 #define CAN_BR_PHASE2(value) ((CAN_BR_PHASE2_Msk & ((value) << CAN_BR_PHASE2_Pos)))
182 #define CAN_BR_PHASE1_Pos 4
183 #define CAN_BR_PHASE1_Msk (0x7u << CAN_BR_PHASE1_Pos)
184 #define CAN_BR_PHASE1(value) ((CAN_BR_PHASE1_Msk & ((value) << CAN_BR_PHASE1_Pos)))
185 #define CAN_BR_PROPAG_Pos 8
186 #define CAN_BR_PROPAG_Msk (0x7u << CAN_BR_PROPAG_Pos)
187 #define CAN_BR_PROPAG(value) ((CAN_BR_PROPAG_Msk & ((value) << CAN_BR_PROPAG_Pos)))
188 #define CAN_BR_SJW_Pos 12
189 #define CAN_BR_SJW_Msk (0x3u << CAN_BR_SJW_Pos)
190 #define CAN_BR_SJW(value) ((CAN_BR_SJW_Msk & ((value) << CAN_BR_SJW_Pos)))
191 #define CAN_BR_BRP_Pos 16
192 #define CAN_BR_BRP_Msk (0x7fu << CAN_BR_BRP_Pos)
193 #define CAN_BR_BRP(value) ((CAN_BR_BRP_Msk & ((value) << CAN_BR_BRP_Pos)))
194 #define CAN_BR_SMP (0x1u << 24)
195 #define CAN_BR_SMP_ONCE (0x0u << 24)
196 #define CAN_BR_SMP_THREE (0x1u << 24)
197 /* -------- CAN_TIM : (CAN Offset: 0x0018) Timer Register -------- */
198 #define CAN_TIM_TIMER_Pos 0
199 #define CAN_TIM_TIMER_Msk (0xffffu << CAN_TIM_TIMER_Pos)
200 /* -------- CAN_TIMESTP : (CAN Offset: 0x001C) Timestamp Register -------- */
201 #define CAN_TIMESTP_MTIMESTAMP_Pos 0
202 #define CAN_TIMESTP_MTIMESTAMP_Msk (0xffffu << CAN_TIMESTP_MTIMESTAMP_Pos)
203 /* -------- CAN_ECR : (CAN Offset: 0x0020) Error Counter Register -------- */
204 #define CAN_ECR_REC_Pos 0
205 #define CAN_ECR_REC_Msk (0xffu << CAN_ECR_REC_Pos)
206 #define CAN_ECR_TEC_Pos 16
207 #define CAN_ECR_TEC_Msk (0xffu << CAN_ECR_TEC_Pos)
208 /* -------- CAN_TCR : (CAN Offset: 0x0024) Transfer Command Register -------- */
209 #define CAN_TCR_MB0 (0x1u << 0)
210 #define CAN_TCR_MB1 (0x1u << 1)
211 #define CAN_TCR_MB2 (0x1u << 2)
212 #define CAN_TCR_MB3 (0x1u << 3)
213 #define CAN_TCR_MB4 (0x1u << 4)
214 #define CAN_TCR_MB5 (0x1u << 5)
215 #define CAN_TCR_MB6 (0x1u << 6)
216 #define CAN_TCR_MB7 (0x1u << 7)
217 #define CAN_TCR_TIMRST (0x1u << 31)
218 /* -------- CAN_ACR : (CAN Offset: 0x0028) Abort Command Register -------- */
219 #define CAN_ACR_MB0 (0x1u << 0)
220 #define CAN_ACR_MB1 (0x1u << 1)
221 #define CAN_ACR_MB2 (0x1u << 2)
222 #define CAN_ACR_MB3 (0x1u << 3)
223 #define CAN_ACR_MB4 (0x1u << 4)
224 #define CAN_ACR_MB5 (0x1u << 5)
225 #define CAN_ACR_MB6 (0x1u << 6)
226 #define CAN_ACR_MB7 (0x1u << 7)
227 /* -------- CAN_WPMR : (CAN Offset: 0x00E4) Write Protect Mode Register -------- */
228 #define CAN_WPMR_WPEN (0x1u << 0)
229 #define CAN_WPMR_WPKEY_Pos 8
230 #define CAN_WPMR_WPKEY_Msk (0xffffffu << CAN_WPMR_WPKEY_Pos)
231 #define CAN_WPMR_WPKEY(value) ((CAN_WPMR_WPKEY_Msk & ((value) << CAN_WPMR_WPKEY_Pos)))
232 /* -------- CAN_WPSR : (CAN Offset: 0x00E8) Write Protect Status Register -------- */
233 #define CAN_WPSR_WPVS (0x1u << 0)
234 #define CAN_WPSR_WPVSRC_Pos 8
235 #define CAN_WPSR_WPVSRC_Msk (0xffu << CAN_WPSR_WPVSRC_Pos)
236 /* -------- CAN_MMR : (CAN Offset: N/A) Mailbox Mode Register -------- */
237 #define CAN_MMR_MTIMEMARK_Pos 0
238 #define CAN_MMR_MTIMEMARK_Msk (0xffffu << CAN_MMR_MTIMEMARK_Pos)
239 #define CAN_MMR_MTIMEMARK(value) ((CAN_MMR_MTIMEMARK_Msk & ((value) << CAN_MMR_MTIMEMARK_Pos)))
240 #define CAN_MMR_PRIOR_Pos 16
241 #define CAN_MMR_PRIOR_Msk (0xfu << CAN_MMR_PRIOR_Pos)
242 #define CAN_MMR_PRIOR(value) ((CAN_MMR_PRIOR_Msk & ((value) << CAN_MMR_PRIOR_Pos)))
243 #define CAN_MMR_MOT_Pos 24
244 #define CAN_MMR_MOT_Msk (0x7u << CAN_MMR_MOT_Pos)
245 #define CAN_MMR_MOT_MB_DISABLED (0x0u << 24)
246 #define CAN_MMR_MOT_MB_RX (0x1u << 24)
247 #define CAN_MMR_MOT_MB_RX_OVERWRITE (0x2u << 24)
248 #define CAN_MMR_MOT_MB_TX (0x3u << 24)
249 #define CAN_MMR_MOT_MB_CONSUMER (0x4u << 24)
250 #define CAN_MMR_MOT_MB_PRODUCER (0x5u << 24)
251 /* -------- CAN_MAM : (CAN Offset: N/A) Mailbox Acceptance Mask Register -------- */
252 #define CAN_MAM_MIDvB_Pos 0
253 #define CAN_MAM_MIDvB_Msk (0x3ffffu << CAN_MAM_MIDvB_Pos)
254 #define CAN_MAM_MIDvB(value) ((CAN_MAM_MIDvB_Msk & ((value) << CAN_MAM_MIDvB_Pos)))
255 #define CAN_MAM_MIDvA_Pos 18
256 #define CAN_MAM_MIDvA_Msk (0x7ffu << CAN_MAM_MIDvA_Pos)
257 #define CAN_MAM_MIDvA(value) ((CAN_MAM_MIDvA_Msk & ((value) << CAN_MAM_MIDvA_Pos)))
258 #define CAN_MAM_MIDE (0x1u << 29)
259 /* -------- CAN_MID : (CAN Offset: N/A) Mailbox ID Register -------- */
260 #define CAN_MID_MIDvB_Pos 0
261 #define CAN_MID_MIDvB_Msk (0x3ffffu << CAN_MID_MIDvB_Pos)
262 #define CAN_MID_MIDvB(value) ((CAN_MID_MIDvB_Msk & ((value) << CAN_MID_MIDvB_Pos)))
263 #define CAN_MID_MIDvA_Pos 18
264 #define CAN_MID_MIDvA_Msk (0x7ffu << CAN_MID_MIDvA_Pos)
265 #define CAN_MID_MIDvA(value) ((CAN_MID_MIDvA_Msk & ((value) << CAN_MID_MIDvA_Pos)))
266 #define CAN_MID_MIDE (0x1u << 29)
267 /* -------- CAN_MFID : (CAN Offset: N/A) Mailbox Family ID Register -------- */
268 #define CAN_MFID_MFID_Pos 0
269 #define CAN_MFID_MFID_Msk (0x1fffffffu << CAN_MFID_MFID_Pos)
270 /* -------- CAN_MSR : (CAN Offset: N/A) Mailbox Status Register -------- */
271 #define CAN_MSR_MTIMESTAMP_Pos 0
272 #define CAN_MSR_MTIMESTAMP_Msk (0xffffu << CAN_MSR_MTIMESTAMP_Pos)
273 #define CAN_MSR_MDLC_Pos 16
274 #define CAN_MSR_MDLC_Msk (0xfu << CAN_MSR_MDLC_Pos)
275 #define CAN_MSR_MRTR (0x1u << 20)
276 #define CAN_MSR_MABT (0x1u << 22)
277 #define CAN_MSR_MRDY (0x1u << 23)
278 #define CAN_MSR_MMI (0x1u << 24)
279 /* -------- CAN_MDL : (CAN Offset: N/A) Mailbox Data Low Register -------- */
280 #define CAN_MDL_MDL_Pos 0
281 #define CAN_MDL_MDL_Msk (0xffffffffu << CAN_MDL_MDL_Pos)
282 #define CAN_MDL_MDL(value) ((CAN_MDL_MDL_Msk & ((value) << CAN_MDL_MDL_Pos)))
283 /* -------- CAN_MDH : (CAN Offset: N/A) Mailbox Data High Register -------- */
284 #define CAN_MDH_MDH_Pos 0
285 #define CAN_MDH_MDH_Msk (0xffffffffu << CAN_MDH_MDH_Pos)
286 #define CAN_MDH_MDH(value) ((CAN_MDH_MDH_Msk & ((value) << CAN_MDH_MDH_Pos)))
287 /* -------- CAN_MCR : (CAN Offset: N/A) Mailbox Control Register -------- */
288 #define CAN_MCR_MDLC_Pos 16
289 #define CAN_MCR_MDLC_Msk (0xfu << CAN_MCR_MDLC_Pos)
290 #define CAN_MCR_MDLC(value) ((CAN_MCR_MDLC_Msk & ((value) << CAN_MCR_MDLC_Pos)))
291 #define CAN_MCR_MRTR (0x1u << 20)
292 #define CAN_MCR_MACR (0x1u << 22)
293 #define CAN_MCR_MTCR (0x1u << 23)
296 
297 
298 #endif /* _SAM3XA_CAN_COMPONENT_ */
RwReg CAN_MAM
(CanMb Offset: 0x4) Mailbox Acceptance Mask Register
Definition: component_can.h:43
RoReg CAN_TIM
(Can Offset: 0x0018) Timer Register
Definition: component_can.h:60
RoReg CAN_WPSR
(Can Offset: 0x00E8) Write Protect Status Register
Definition: component_can.h:67
RoReg CAN_SR
(Can Offset: 0x0010) Status Register
Definition: component_can.h:58
RwReg CAN_WPMR
(Can Offset: 0x00E4) Write Protect Mode Register
Definition: component_can.h:66
volatile uint32_t RwReg
Definition: sam3n00a.h:54
WoReg CAN_IER
(Can Offset: 0x0004) Interrupt Enable Register
Definition: component_can.h:55
volatile uint32_t WoReg
Definition: sam3n00a.h:53
RwReg CAN_MCR
(CanMb Offset: 0x1C) Mailbox Control Register
Definition: component_can.h:49
RwReg CAN_MFID
(CanMb Offset: 0xC) Mailbox Family ID Register
Definition: component_can.h:45
WoReg CAN_IDR
(Can Offset: 0x0008) Interrupt Disable Register
Definition: component_can.h:56
RwReg CAN_MDH
(CanMb Offset: 0x18) Mailbox Data High Register
Definition: component_can.h:48
Definition: component_can.h:53
RwReg CAN_MID
(CanMb Offset: 0x8) Mailbox ID Register
Definition: component_can.h:44
RwReg CAN_MDL
(CanMb Offset: 0x14) Mailbox Data Low Register
Definition: component_can.h:47
WoReg CAN_TCR
(Can Offset: 0x0024) Transfer Command Register
Definition: component_can.h:63
RoReg CAN_ECR
(Can Offset: 0x0020) Error Counter Register
Definition: component_can.h:62
#define CANMB_NUMBER
Can hardware registers.
Definition: component_can.h:52
WoReg CAN_ACR
(Can Offset: 0x0028) Abort Command Register
Definition: component_can.h:64
RwReg CAN_MMR
(CanMb Offset: 0x0) Mailbox Mode Register
Definition: component_can.h:42
RwReg CAN_MSR
(CanMb Offset: 0x10) Mailbox Status Register
Definition: component_can.h:46
volatile const uint32_t RoReg
Definition: sam3n00a.h:49
RoReg CAN_IMR
(Can Offset: 0x000C) Interrupt Mask Register
Definition: component_can.h:57
RoReg CAN_TIMESTP
(Can Offset: 0x001C) Timestamp Register
Definition: component_can.h:61
RwReg CAN_MR
(Can Offset: 0x0000) Mode Register
Definition: component_can.h:54
CanMb hardware registers.
Definition: component_can.h:41
RwReg CAN_BR
(Can Offset: 0x0014) Baudrate Register
Definition: component_can.h:59