Robobo
component_tc.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_TC_COMPONENT_
31 #define _SAM3XA_TC_COMPONENT_
32 
33 /* ============================================================================= */
35 /* ============================================================================= */
38 
39 #if !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
40 
41 typedef struct {
42  RwReg TC_CCR;
43  RwReg TC_CMR;
44  RwReg TC_SMMR;
45  RoReg Reserved1[1];
46  RwReg TC_CV;
47  RwReg TC_RA;
48  RwReg TC_RB;
49  RwReg TC_RC;
50  RwReg TC_SR;
51  RwReg TC_IER;
52  RwReg TC_IDR;
53  RwReg TC_IMR;
54  RoReg Reserved2[4];
55 } TcChannel;
57 #define TCCHANNEL_NUMBER 3
58 typedef struct {
59  TcChannel TC_CHANNEL[TCCHANNEL_NUMBER];
60  WoReg TC_BCR;
61  RwReg TC_BMR;
62  WoReg TC_QIER;
63  WoReg TC_QIDR;
64  RoReg TC_QIMR;
65  RoReg TC_QISR;
66  RwReg TC_FMR;
67  RoReg Reserved1[2];
68  RwReg TC_WPMR;
69 } Tc;
70 #endif /* !(defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
71 /* -------- TC_CCR : (TC Offset: N/A) Channel Control Register -------- */
72 #define TC_CCR_CLKEN (0x1u << 0)
73 #define TC_CCR_CLKDIS (0x1u << 1)
74 #define TC_CCR_SWTRG (0x1u << 2)
75 /* -------- TC_CMR : (TC Offset: N/A) Channel Mode Register -------- */
76 #define TC_CMR_TCCLKS_Pos 0
77 #define TC_CMR_TCCLKS_Msk (0x7u << TC_CMR_TCCLKS_Pos)
78 #define TC_CMR_TCCLKS_TIMER_CLOCK1 (0x0u << 0)
79 #define TC_CMR_TCCLKS_TIMER_CLOCK2 (0x1u << 0)
80 #define TC_CMR_TCCLKS_TIMER_CLOCK3 (0x2u << 0)
81 #define TC_CMR_TCCLKS_TIMER_CLOCK4 (0x3u << 0)
82 #define TC_CMR_TCCLKS_TIMER_CLOCK5 (0x4u << 0)
83 #define TC_CMR_TCCLKS_XC0 (0x5u << 0)
84 #define TC_CMR_TCCLKS_XC1 (0x6u << 0)
85 #define TC_CMR_TCCLKS_XC2 (0x7u << 0)
86 #define TC_CMR_CLKI (0x1u << 3)
87 #define TC_CMR_BURST_Pos 4
88 #define TC_CMR_BURST_Msk (0x3u << TC_CMR_BURST_Pos)
89 #define TC_CMR_BURST_NONE (0x0u << 4)
90 #define TC_CMR_BURST_XC0 (0x1u << 4)
91 #define TC_CMR_BURST_XC1 (0x2u << 4)
92 #define TC_CMR_BURST_XC2 (0x3u << 4)
93 #define TC_CMR_LDBSTOP (0x1u << 6)
94 #define TC_CMR_LDBDIS (0x1u << 7)
95 #define TC_CMR_ETRGEDG_Pos 8
96 #define TC_CMR_ETRGEDG_Msk (0x3u << TC_CMR_ETRGEDG_Pos)
97 #define TC_CMR_ETRGEDG_NONE (0x0u << 8)
98 #define TC_CMR_ETRGEDG_RISING (0x1u << 8)
99 #define TC_CMR_ETRGEDG_FALLING (0x2u << 8)
100 #define TC_CMR_ETRGEDG_EDGE (0x3u << 8)
101 #define TC_CMR_ABETRG (0x1u << 10)
102 #define TC_CMR_CPCTRG (0x1u << 14)
103 #define TC_CMR_WAVE (0x1u << 15)
104 #define TC_CMR_LDRA_Pos 16
105 #define TC_CMR_LDRA_Msk (0x3u << TC_CMR_LDRA_Pos)
106 #define TC_CMR_LDRA_NONE (0x0u << 16)
107 #define TC_CMR_LDRA_RISING (0x1u << 16)
108 #define TC_CMR_LDRA_FALLING (0x2u << 16)
109 #define TC_CMR_LDRA_EDGE (0x3u << 16)
110 #define TC_CMR_LDRB_Pos 18
111 #define TC_CMR_LDRB_Msk (0x3u << TC_CMR_LDRB_Pos)
112 #define TC_CMR_LDRB_NONE (0x0u << 18)
113 #define TC_CMR_LDRB_RISING (0x1u << 18)
114 #define TC_CMR_LDRB_FALLING (0x2u << 18)
115 #define TC_CMR_LDRB_EDGE (0x3u << 18)
116 #define TC_CMR_CPCSTOP (0x1u << 6)
117 #define TC_CMR_CPCDIS (0x1u << 7)
118 #define TC_CMR_EEVTEDG_Pos 8
119 #define TC_CMR_EEVTEDG_Msk (0x3u << TC_CMR_EEVTEDG_Pos)
120 #define TC_CMR_EEVTEDG_NONE (0x0u << 8)
121 #define TC_CMR_EEVTEDG_RISING (0x1u << 8)
122 #define TC_CMR_EEVTEDG_FALLING (0x2u << 8)
123 #define TC_CMR_EEVTEDG_EDGE (0x3u << 8)
124 #define TC_CMR_EEVT_Pos 10
125 #define TC_CMR_EEVT_Msk (0x3u << TC_CMR_EEVT_Pos)
126 #define TC_CMR_EEVT_TIOB (0x0u << 10)
127 #define TC_CMR_EEVT_XC0 (0x1u << 10)
128 #define TC_CMR_EEVT_XC1 (0x2u << 10)
129 #define TC_CMR_EEVT_XC2 (0x3u << 10)
130 #define TC_CMR_ENETRG (0x1u << 12)
131 #define TC_CMR_WAVSEL_Pos 13
132 #define TC_CMR_WAVSEL_Msk (0x3u << TC_CMR_WAVSEL_Pos)
133 #define TC_CMR_WAVSEL_UP (0x0u << 13)
134 #define TC_CMR_WAVSEL_UPDOWN (0x1u << 13)
135 #define TC_CMR_WAVSEL_UP_RC (0x2u << 13)
136 #define TC_CMR_WAVSEL_UPDOWN_RC (0x3u << 13)
137 #define TC_CMR_ACPA_Pos 16
138 #define TC_CMR_ACPA_Msk (0x3u << TC_CMR_ACPA_Pos)
139 #define TC_CMR_ACPA_NONE (0x0u << 16)
140 #define TC_CMR_ACPA_SET (0x1u << 16)
141 #define TC_CMR_ACPA_CLEAR (0x2u << 16)
142 #define TC_CMR_ACPA_TOGGLE (0x3u << 16)
143 #define TC_CMR_ACPC_Pos 18
144 #define TC_CMR_ACPC_Msk (0x3u << TC_CMR_ACPC_Pos)
145 #define TC_CMR_ACPC_NONE (0x0u << 18)
146 #define TC_CMR_ACPC_SET (0x1u << 18)
147 #define TC_CMR_ACPC_CLEAR (0x2u << 18)
148 #define TC_CMR_ACPC_TOGGLE (0x3u << 18)
149 #define TC_CMR_AEEVT_Pos 20
150 #define TC_CMR_AEEVT_Msk (0x3u << TC_CMR_AEEVT_Pos)
151 #define TC_CMR_AEEVT_NONE (0x0u << 20)
152 #define TC_CMR_AEEVT_SET (0x1u << 20)
153 #define TC_CMR_AEEVT_CLEAR (0x2u << 20)
154 #define TC_CMR_AEEVT_TOGGLE (0x3u << 20)
155 #define TC_CMR_ASWTRG_Pos 22
156 #define TC_CMR_ASWTRG_Msk (0x3u << TC_CMR_ASWTRG_Pos)
157 #define TC_CMR_ASWTRG_NONE (0x0u << 22)
158 #define TC_CMR_ASWTRG_SET (0x1u << 22)
159 #define TC_CMR_ASWTRG_CLEAR (0x2u << 22)
160 #define TC_CMR_ASWTRG_TOGGLE (0x3u << 22)
161 #define TC_CMR_BCPB_Pos 24
162 #define TC_CMR_BCPB_Msk (0x3u << TC_CMR_BCPB_Pos)
163 #define TC_CMR_BCPB_NONE (0x0u << 24)
164 #define TC_CMR_BCPB_SET (0x1u << 24)
165 #define TC_CMR_BCPB_CLEAR (0x2u << 24)
166 #define TC_CMR_BCPB_TOGGLE (0x3u << 24)
167 #define TC_CMR_BCPC_Pos 26
168 #define TC_CMR_BCPC_Msk (0x3u << TC_CMR_BCPC_Pos)
169 #define TC_CMR_BCPC_NONE (0x0u << 26)
170 #define TC_CMR_BCPC_SET (0x1u << 26)
171 #define TC_CMR_BCPC_CLEAR (0x2u << 26)
172 #define TC_CMR_BCPC_TOGGLE (0x3u << 26)
173 #define TC_CMR_BEEVT_Pos 28
174 #define TC_CMR_BEEVT_Msk (0x3u << TC_CMR_BEEVT_Pos)
175 #define TC_CMR_BEEVT_NONE (0x0u << 28)
176 #define TC_CMR_BEEVT_SET (0x1u << 28)
177 #define TC_CMR_BEEVT_CLEAR (0x2u << 28)
178 #define TC_CMR_BEEVT_TOGGLE (0x3u << 28)
179 #define TC_CMR_BSWTRG_Pos 30
180 #define TC_CMR_BSWTRG_Msk (0x3u << TC_CMR_BSWTRG_Pos)
181 #define TC_CMR_BSWTRG_NONE (0x0u << 30)
182 #define TC_CMR_BSWTRG_SET (0x1u << 30)
183 #define TC_CMR_BSWTRG_CLEAR (0x2u << 30)
184 #define TC_CMR_BSWTRG_TOGGLE (0x3u << 30)
185 /* -------- TC_SMMR : (TC Offset: N/A) Stepper Motor Mode Register -------- */
186 #define TC_SMMR_GCEN (0x1u << 0)
187 #define TC_SMMR_DOWN (0x1u << 1)
188 /* -------- TC_CV : (TC Offset: N/A) Counter Value -------- */
189 #define TC_CV_CV_Pos 0
190 #define TC_CV_CV_Msk (0xffffffffu << TC_CV_CV_Pos)
191 /* -------- TC_RA : (TC Offset: N/A) Register A -------- */
192 #define TC_RA_RA_Pos 0
193 #define TC_RA_RA_Msk (0xffffffffu << TC_RA_RA_Pos)
194 #define TC_RA_RA(value) ((TC_RA_RA_Msk & ((value) << TC_RA_RA_Pos)))
195 /* -------- TC_RB : (TC Offset: N/A) Register B -------- */
196 #define TC_RB_RB_Pos 0
197 #define TC_RB_RB_Msk (0xffffffffu << TC_RB_RB_Pos)
198 #define TC_RB_RB(value) ((TC_RB_RB_Msk & ((value) << TC_RB_RB_Pos)))
199 /* -------- TC_RC : (TC Offset: N/A) Register C -------- */
200 #define TC_RC_RC_Pos 0
201 #define TC_RC_RC_Msk (0xffffffffu << TC_RC_RC_Pos)
202 #define TC_RC_RC(value) ((TC_RC_RC_Msk & ((value) << TC_RC_RC_Pos)))
203 /* -------- TC_SR : (TC Offset: N/A) Status Register -------- */
204 #define TC_SR_COVFS (0x1u << 0)
205 #define TC_SR_LOVRS (0x1u << 1)
206 #define TC_SR_CPAS (0x1u << 2)
207 #define TC_SR_CPBS (0x1u << 3)
208 #define TC_SR_CPCS (0x1u << 4)
209 #define TC_SR_LDRAS (0x1u << 5)
210 #define TC_SR_LDRBS (0x1u << 6)
211 #define TC_SR_ETRGS (0x1u << 7)
212 #define TC_SR_CLKSTA (0x1u << 16)
213 #define TC_SR_MTIOA (0x1u << 17)
214 #define TC_SR_MTIOB (0x1u << 18)
215 /* -------- TC_IER : (TC Offset: N/A) Interrupt Enable Register -------- */
216 #define TC_IER_COVFS (0x1u << 0)
217 #define TC_IER_LOVRS (0x1u << 1)
218 #define TC_IER_CPAS (0x1u << 2)
219 #define TC_IER_CPBS (0x1u << 3)
220 #define TC_IER_CPCS (0x1u << 4)
221 #define TC_IER_LDRAS (0x1u << 5)
222 #define TC_IER_LDRBS (0x1u << 6)
223 #define TC_IER_ETRGS (0x1u << 7)
224 /* -------- TC_IDR : (TC Offset: N/A) Interrupt Disable Register -------- */
225 #define TC_IDR_COVFS (0x1u << 0)
226 #define TC_IDR_LOVRS (0x1u << 1)
227 #define TC_IDR_CPAS (0x1u << 2)
228 #define TC_IDR_CPBS (0x1u << 3)
229 #define TC_IDR_CPCS (0x1u << 4)
230 #define TC_IDR_LDRAS (0x1u << 5)
231 #define TC_IDR_LDRBS (0x1u << 6)
232 #define TC_IDR_ETRGS (0x1u << 7)
233 /* -------- TC_IMR : (TC Offset: N/A) Interrupt Mask Register -------- */
234 #define TC_IMR_COVFS (0x1u << 0)
235 #define TC_IMR_LOVRS (0x1u << 1)
236 #define TC_IMR_CPAS (0x1u << 2)
237 #define TC_IMR_CPBS (0x1u << 3)
238 #define TC_IMR_CPCS (0x1u << 4)
239 #define TC_IMR_LDRAS (0x1u << 5)
240 #define TC_IMR_LDRBS (0x1u << 6)
241 #define TC_IMR_ETRGS (0x1u << 7)
242 /* -------- TC_BCR : (TC Offset: 0xC0) Block Control Register -------- */
243 #define TC_BCR_SYNC (0x1u << 0)
244 /* -------- TC_BMR : (TC Offset: 0xC4) Block Mode Register -------- */
245 #define TC_BMR_TC0XC0S_Pos 0
246 #define TC_BMR_TC0XC0S_Msk (0x3u << TC_BMR_TC0XC0S_Pos)
247 #define TC_BMR_TC0XC0S_TCLK0 (0x0u << 0)
248 #define TC_BMR_TC0XC0S_TIOA1 (0x2u << 0)
249 #define TC_BMR_TC0XC0S_TIOA2 (0x3u << 0)
250 #define TC_BMR_TC1XC1S_Pos 2
251 #define TC_BMR_TC1XC1S_Msk (0x3u << TC_BMR_TC1XC1S_Pos)
252 #define TC_BMR_TC1XC1S_TCLK1 (0x0u << 2)
253 #define TC_BMR_TC1XC1S_TIOA0 (0x2u << 2)
254 #define TC_BMR_TC1XC1S_TIOA2 (0x3u << 2)
255 #define TC_BMR_TC2XC2S_Pos 4
256 #define TC_BMR_TC2XC2S_Msk (0x3u << TC_BMR_TC2XC2S_Pos)
257 #define TC_BMR_TC2XC2S_TCLK2 (0x0u << 4)
258 #define TC_BMR_TC2XC2S_TIOA1 (0x2u << 4)
259 #define TC_BMR_TC2XC2S_TIOA2 (0x3u << 4)
260 #define TC_BMR_QDEN (0x1u << 8)
261 #define TC_BMR_POSEN (0x1u << 9)
262 #define TC_BMR_SPEEDEN (0x1u << 10)
263 #define TC_BMR_QDTRANS (0x1u << 11)
264 #define TC_BMR_EDGPHA (0x1u << 12)
265 #define TC_BMR_INVA (0x1u << 13)
266 #define TC_BMR_INVB (0x1u << 14)
267 #define TC_BMR_INVIDX (0x1u << 15)
268 #define TC_BMR_SWAP (0x1u << 16)
269 #define TC_BMR_IDXPHB (0x1u << 17)
270 #define TC_BMR_FILTER (0x1u << 19)
271 #define TC_BMR_MAXFILT_Pos 20
272 #define TC_BMR_MAXFILT_Msk (0x3fu << TC_BMR_MAXFILT_Pos)
273 #define TC_BMR_MAXFILT(value) ((TC_BMR_MAXFILT_Msk & ((value) << TC_BMR_MAXFILT_Pos)))
274 /* -------- TC_QIER : (TC Offset: 0xC8) QDEC Interrupt Enable Register -------- */
275 #define TC_QIER_IDX (0x1u << 0)
276 #define TC_QIER_DIRCHG (0x1u << 1)
277 #define TC_QIER_QERR (0x1u << 2)
278 /* -------- TC_QIDR : (TC Offset: 0xCC) QDEC Interrupt Disable Register -------- */
279 #define TC_QIDR_IDX (0x1u << 0)
280 #define TC_QIDR_DIRCHG (0x1u << 1)
281 #define TC_QIDR_QERR (0x1u << 2)
282 /* -------- TC_QIMR : (TC Offset: 0xD0) QDEC Interrupt Mask Register -------- */
283 #define TC_QIMR_IDX (0x1u << 0)
284 #define TC_QIMR_DIRCHG (0x1u << 1)
285 #define TC_QIMR_QERR (0x1u << 2)
286 /* -------- TC_QISR : (TC Offset: 0xD4) QDEC Interrupt Status Register -------- */
287 #define TC_QISR_IDX (0x1u << 0)
288 #define TC_QISR_DIRCHG (0x1u << 1)
289 #define TC_QISR_QERR (0x1u << 2)
290 #define TC_QISR_DIR (0x1u << 8)
291 /* -------- TC_FMR : (TC Offset: 0xD8) Fault Mode Register -------- */
292 #define TC_FMR_ENCF0 (0x1u << 0)
293 #define TC_FMR_ENCF1 (0x1u << 1)
294 /* -------- TC_WPMR : (TC Offset: 0xE4) Write Protect Mode Register -------- */
295 #define TC_WPMR_WPEN (0x1u << 0)
296 #define TC_WPMR_WPKEY_Pos 8
297 #define TC_WPMR_WPKEY_Msk (0xffffffu << TC_WPMR_WPKEY_Pos)
298 #define TC_WPMR_WPKEY(value) ((TC_WPMR_WPKEY_Msk & ((value) << TC_WPMR_WPKEY_Pos)))
299 
303 #endif /* _SAM3XA_TC_COMPONENT_ */
volatile uint32_t RwReg
Definition: sam3n00a.h:54
#define TCCHANNEL_NUMBER
Tc hardware registers.
Definition: component_tc.h:57
volatile uint32_t WoReg
Definition: sam3n00a.h:53
TcChannel hardware registers.
Definition: component_tc.h:41
volatile const uint32_t RoReg
Definition: sam3n00a.h:49
Definition: component_tc.h:58