4664838d0e33e86d90f9fac80831083b7454b5b6
[bertos.git] / bertos / cpu / cortex-m3 / io / sam3_pmc.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \brief AT91SAM3 PMC hardware.
34  */
35
36 #ifndef SAM3_PMC_H
37 #define SAM3_PMC_H
38
39 // FIXME: move these in sam3(?)_int.h
40 #define INT_SUPC     0  ///< SAM3N Supply Controller (SUPC)
41 #define INT_RSTC     1  ///< SAM3N Reset Controller (RSTC)
42 #define INT_RTC      2  ///< SAM3N Real Time Clock (RTC)
43 #define INT_RTT      3  ///< SAM3N Real Time Timer (RTT)
44 #define INT_WDT      4  ///< SAM3N Watchdog Timer (WDT)
45 #define INT_PMC      5  ///< SAM3N Power Management Controller (PMC)
46 #define INT_EFC      6  ///< SAM3N Enhanced Flash Controller (EFC)
47 #define INT_UART0    8  ///< SAM3N UART 0 (UART0)
48 #define INT_UART1    9  ///< SAM3N UART 1 (UART1)
49 #define INT_PIOA    11  ///< SAM3N Parallel I/O Controller A (PIOA)
50 #define INT_PIOB    12  ///< SAM3N Parallel I/O Controller B (PIOB)
51 #define INT_PIOC    13  ///< SAM3N Parallel I/O Controller C (PIOC)
52 #define INT_USART0  14  ///< SAM3N USART 0 (USART0)
53 #define INT_USART1  15  ///< SAM3N USART 1 (USART1)
54 #define INT_TWI0    19  ///< SAM3N Two Wire Interface 0 (TWI0)
55 #define INT_TWI1    20  ///< SAM3N Two Wire Interface 1 (TWI1)
56 #define INT_SPI     21  ///< SAM3N Serial Peripheral Interface (SPI)
57 #define INT_TC0     23  ///< SAM3N Timer/Counter 0 (TC0)
58 #define INT_TC1     24  ///< SAM3N Timer/Counter 1 (TC1)
59 #define INT_TC2     25  ///< SAM3N Timer/Counter 2 (TC2)
60 #define INT_TC3     26  ///< SAM3N Timer/Counter 3 (TC3)
61 #define INT_TC4     27  ///< SAM3N Timer/Counter 4 (TC4)
62 #define INT_TC5     28  ///< SAM3N Timer/Counter 5 (TC5)
63 #define INT_ADC     29  ///< SAM3N Analog To Digital Converter (ADC)
64 #define INT_DACC    30  ///< SAM3N Digital To Analog Converter (DACC)
65 #define INT_PWM     31  ///< SAM3N Pulse Width Modulation (PWM)
66
67 /**
68  * PMC registers.
69  */
70 /*\{*/
71 #define PMC_SCER_R  (*((reg32_t *)0x400E0400))   ///< System Clock Enable Register
72 #define PMC_SCDR_R  (*((reg32_t *)0x400E0404))   ///< System Clock Disable Register
73 #define PMC_SCSR_R  (*((reg32_t *)0x400E0408))   ///< System Clock Status Register
74 #define PMC_PCER_R  (*((reg32_t *)0x400E0410))   ///< Peripheral Clock Enable Register
75 #define PMC_PCDR_R  (*((reg32_t *)0x400E0414))   ///< Peripheral Clock Disable Register
76 #define PMC_PCSR_R  (*((reg32_t *)0x400E0418))   ///< Peripheral Clock Status Register
77 #define PMC_MOR_R   (*((reg32_t *)0x400E0420))   ///< Main Oscillator Register
78 #define PMC_MCFR_R  (*((reg32_t *)0x400E0424))   ///< Main Clock Frequency Register
79 #define PMC_PLLR_R  (*((reg32_t *)0x400E0428))   ///< PLL Register
80 #define PMC_MCKR_R  (*((reg32_t *)0x400E0430))   ///< Master Clock Register
81 #define PMC_PCK_R   (*((reg32_t *)0x400E0440))   ///< Programmable Clock 0 Register
82 #define PMC_IER_R   (*((reg32_t *)0x400E0460))   ///< Interrupt Enable Register
83 #define PMC_IDR_R   (*((reg32_t *)0x400E0464))   ///< Interrupt Disable Register
84 #define PMC_SR_R    (*((reg32_t *)0x400E0468))   ///< Status Register
85 #define PMC_IMR_R   (*((reg32_t *)0x400E046C))   ///< Interrupt Mask Register
86 #define PMC_FSMR_R  (*((reg32_t *)0x400E0470))   ///< Fast Startup Mode Register
87 #define PMC_FSPR_R  (*((reg32_t *)0x400E0474))   ///< Fast Startup Polarity Register
88 #define PMC_FOCR_R  (*((reg32_t *)0x400E0478))   ///< Fault Output Clear Register
89 #define PMC_WPMR_R  (*((reg32_t *)0x400E04E4))   ///< Write Protect Mode Register
90 #define PMC_WPSR_R  (*((reg32_t *)0x400E04E8))   ///< Write Protect Status Register
91 #define PMC_OCR_R   (*((reg32_t *)0x400E0510))   ///< Oscillator Calibration Register
92 /*\}*/
93
94 /**
95  * PMC register addresses.
96  */
97 /*\{*/
98 #define PMC_SCER  0x400E0400   ///< System Clock Enable Register
99 #define PMC_SCDR  0x400E0404   ///< System Clock Disable Register
100 #define PMC_SCSR  0x400E0408   ///< System Clock Status Register
101 #define PMC_PCER  0x400E0410   ///< Peripheral Clock Enable Register
102 #define PMC_PCDR  0x400E0414   ///< Peripheral Clock Disable Register
103 #define PMC_PCSR  0x400E0418   ///< Peripheral Clock Status Register
104 #define PMC_MOR   0x400E0420   ///< Main Oscillator Register
105 #define PMC_MCFR  0x400E0424   ///< Main Clock Frequency Register
106 #define PMC_PLLR  0x400E0428   ///< PLL Register
107 #define PMC_MCKR  0x400E0430   ///< Master Clock Register
108 #define PMC_PCK   0x400E0440   ///< Programmable Clock 0 Register
109 #define PMC_IER   0x400E0460   ///< Interrupt Enable Register
110 #define PMC_IDR   0x400E0464   ///< Interrupt Disable Register
111 #define PMC_SR    0x400E0468   ///< Status Register
112 #define PMC_IMR   0x400E046C   ///< Interrupt Mask Register
113 #define PMC_FSMR  0x400E0470   ///< Fast Startup Mode Register
114 #define PMC_FSPR  0x400E0474   ///< Fast Startup Polarity Register
115 #define PMC_FOCR  0x400E0478   ///< Fault Output Clear Register
116 #define PMC_WPMR  0x400E04E4   ///< Write Protect Mode Register
117 #define PMC_WPSR  0x400E04E8   ///< Write Protect Status Register
118 #define PMC_OCR   0x400E0510   ///< Oscillator Calibration Register
119 /*\}*/
120
121 /**
122  * Defines for bit fields in PMC_SCER register.
123  */
124 /*\{*/
125 #define PMC_SCER_PCK0  BV(8)   ///< Programmable Clock 0 Output Enable
126 #define PMC_SCER_PCK1  BV(9)   ///< Programmable Clock 1 Output Enable
127 #define PMC_SCER_PCK2  BV(10)  ///< Programmable Clock 2 Output Enable
128 /*\}*/
129
130 /**
131  * Defines for bit fields in PMC_SCDR register.
132  */
133 /*\{*/
134 #define PMC_SCDR_PCK0  BV(8)   ///< Programmable Clock 0 Output Disable
135 #define PMC_SCDR_PCK1  BV(9)   ///< Programmable Clock 1 Output Disable
136 #define PMC_SCDR_PCK2  BV(10)  ///< Programmable Clock 2 Output Disable
137 /*\}*/
138
139 /**
140  * Defines for bit fields in PMC_SCSR register.
141  */
142 /*\{*/
143 #define PMC_SCSR_PCK0  BV(8)   ///< Programmable Clock 0 Output Status
144 #define PMC_SCSR_PCK1  BV(9)   ///< Programmable Clock 1 Output Status
145 #define PMC_SCSR_PCK2  BV(10)  ///< Programmable Clock 2 Output Status
146 /*\}*/
147
148 /**
149  * Defines for bit fields in PMC_PCER register.
150  */
151 /*\{*/
152 #define PMC_PCER_PID2   BV(2)    ///< Peripheral Clock 2 Enable
153 #define PMC_PCER_PID3   BV(3)    ///< Peripheral Clock 3 Enable
154 #define PMC_PCER_PID4   BV(4)    ///< Peripheral Clock 4 Enable
155 #define PMC_PCER_PID5   BV(5)    ///< Peripheral Clock 5 Enable
156 #define PMC_PCER_PID6   BV(6)    ///< Peripheral Clock 6 Enable
157 #define PMC_PCER_PID7   BV(7)    ///< Peripheral Clock 7 Enable
158 #define PMC_PCER_PID8   BV(8)    ///< Peripheral Clock 8 Enable
159 #define PMC_PCER_PID9   BV(9)    ///< Peripheral Clock 9 Enable
160 #define PMC_PCER_PID10  BV(10)   ///< Peripheral Clock 10 Enable
161 #define PMC_PCER_PID11  BV(11)   ///< Peripheral Clock 11 Enable
162 #define PMC_PCER_PID12  BV(12)   ///< Peripheral Clock 12 Enable
163 #define PMC_PCER_PID13  BV(13)   ///< Peripheral Clock 13 Enable
164 #define PMC_PCER_PID14  BV(14)   ///< Peripheral Clock 14 Enable
165 #define PMC_PCER_PID15  BV(15)   ///< Peripheral Clock 15 Enable
166 #define PMC_PCER_PID16  BV(16)   ///< Peripheral Clock 16 Enable
167 #define PMC_PCER_PID17  BV(17)   ///< Peripheral Clock 17 Enable
168 #define PMC_PCER_PID18  BV(18)   ///< Peripheral Clock 18 Enable
169 #define PMC_PCER_PID19  BV(19)   ///< Peripheral Clock 19 Enable
170 #define PMC_PCER_PID20  BV(20)   ///< Peripheral Clock 20 Enable
171 #define PMC_PCER_PID21  BV(21)   ///< Peripheral Clock 21 Enable
172 #define PMC_PCER_PID22  BV(22)   ///< Peripheral Clock 22 Enable
173 #define PMC_PCER_PID23  BV(23)   ///< Peripheral Clock 23 Enable
174 #define PMC_PCER_PID24  BV(24)   ///< Peripheral Clock 24 Enable
175 #define PMC_PCER_PID25  BV(25)   ///< Peripheral Clock 25 Enable
176 #define PMC_PCER_PID26  BV(26)   ///< Peripheral Clock 26 Enable
177 #define PMC_PCER_PID27  BV(27)   ///< Peripheral Clock 27 Enable
178 #define PMC_PCER_PID28  BV(28)   ///< Peripheral Clock 28 Enable
179 #define PMC_PCER_PID29  BV(29)   ///< Peripheral Clock 29 Enable
180 #define PMC_PCER_PID30  BV(30)   ///< Peripheral Clock 30 Enable
181 #define PMC_PCER_PID31  BV(31)   ///< Peripheral Clock 31 Enable
182 /*\}*/
183
184 /**
185  * Defines for bit fields in PMC_PCDR register.
186  */
187 /*\{*/
188 #define PMC_PCDR_PID2   BV(2)   ///< Peripheral Clock 2 Disable
189 #define PMC_PCDR_PID3   BV(3)   ///< Peripheral Clock 3 Disable
190 #define PMC_PCDR_PID4   BV(4)   ///< Peripheral Clock 4 Disable
191 #define PMC_PCDR_PID5   BV(5)   ///< Peripheral Clock 5 Disable
192 #define PMC_PCDR_PID6   BV(6)   ///< Peripheral Clock 6 Disable
193 #define PMC_PCDR_PID7   BV(7)   ///< Peripheral Clock 7 Disable
194 #define PMC_PCDR_PID8   BV(8)   ///< Peripheral Clock 8 Disable
195 #define PMC_PCDR_PID9   BV(9)   ///< Peripheral Clock 9 Disable
196 #define PMC_PCDR_PID10  BV(10)  ///< Peripheral Clock 10 Disable
197 #define PMC_PCDR_PID11  BV(11)  ///< Peripheral Clock 11 Disable
198 #define PMC_PCDR_PID12  BV(12)  ///< Peripheral Clock 12 Disable
199 #define PMC_PCDR_PID13  BV(13)  ///< Peripheral Clock 13 Disable
200 #define PMC_PCDR_PID14  BV(14)  ///< Peripheral Clock 14 Disable
201 #define PMC_PCDR_PID15  BV(15)  ///< Peripheral Clock 15 Disable
202 #define PMC_PCDR_PID16  BV(16)  ///< Peripheral Clock 16 Disable
203 #define PMC_PCDR_PID17  BV(17)  ///< Peripheral Clock 17 Disable
204 #define PMC_PCDR_PID18  BV(18)  ///< Peripheral Clock 18 Disable
205 #define PMC_PCDR_PID19  BV(19)  ///< Peripheral Clock 19 Disable
206 #define PMC_PCDR_PID20  BV(20)  ///< Peripheral Clock 20 Disable
207 #define PMC_PCDR_PID21  BV(21)  ///< Peripheral Clock 21 Disable
208 #define PMC_PCDR_PID22  BV(22)  ///< Peripheral Clock 22 Disable
209 #define PMC_PCDR_PID23  BV(23)  ///< Peripheral Clock 23 Disable
210 #define PMC_PCDR_PID24  BV(24)  ///< Peripheral Clock 24 Disable
211 #define PMC_PCDR_PID25  BV(25)  ///< Peripheral Clock 25 Disable
212 #define PMC_PCDR_PID26  BV(26)  ///< Peripheral Clock 26 Disable
213 #define PMC_PCDR_PID27  BV(27)  ///< Peripheral Clock 27 Disable
214 #define PMC_PCDR_PID28  BV(28)  ///< Peripheral Clock 28 Disable
215 #define PMC_PCDR_PID29  BV(29)  ///< Peripheral Clock 29 Disable
216 #define PMC_PCDR_PID30  BV(30)  ///< Peripheral Clock 30 Disable
217 #define PMC_PCDR_PID31  BV(31)  ///< Peripheral Clock 31 Disable
218 /*\}*/
219
220 /**
221  * Defines for bit fields in PMC_PCSR register.
222  */
223 /*\{*/
224 #define PMC_PCSR_PID2   BV(2)   ///< Peripheral Clock 2 Status
225 #define PMC_PCSR_PID3   BV(3)   ///< Peripheral Clock 3 Status
226 #define PMC_PCSR_PID4   BV(4)   ///< Peripheral Clock 4 Status
227 #define PMC_PCSR_PID5   BV(5)   ///< Peripheral Clock 5 Status
228 #define PMC_PCSR_PID6   BV(6)   ///< Peripheral Clock 6 Status
229 #define PMC_PCSR_PID7   BV(7)   ///< Peripheral Clock 7 Status
230 #define PMC_PCSR_PID8   BV(8)   ///< Peripheral Clock 8 Status
231 #define PMC_PCSR_PID9   BV(9)   ///< Peripheral Clock 9 Status
232 #define PMC_PCSR_PID10  BV(10)  ///< Peripheral Clock 10 Status
233 #define PMC_PCSR_PID11  BV(11)  ///< Peripheral Clock 11 Status
234 #define PMC_PCSR_PID12  BV(12)  ///< Peripheral Clock 12 Status
235 #define PMC_PCSR_PID13  BV(13)  ///< Peripheral Clock 13 Status
236 #define PMC_PCSR_PID14  BV(14)  ///< Peripheral Clock 14 Status
237 #define PMC_PCSR_PID15  BV(15)  ///< Peripheral Clock 15 Status
238 #define PMC_PCSR_PID16  BV(16)  ///< Peripheral Clock 16 Status
239 #define PMC_PCSR_PID17  BV(17)  ///< Peripheral Clock 17 Status
240 #define PMC_PCSR_PID18  BV(18)  ///< Peripheral Clock 18 Status
241 #define PMC_PCSR_PID19  BV(19)  ///< Peripheral Clock 19 Status
242 #define PMC_PCSR_PID20  BV(20)  ///< Peripheral Clock 20 Status
243 #define PMC_PCSR_PID21  BV(21)  ///< Peripheral Clock 21 Status
244 #define PMC_PCSR_PID22  BV(22)  ///< Peripheral Clock 22 Status
245 #define PMC_PCSR_PID23  BV(23)  ///< Peripheral Clock 23 Status
246 #define PMC_PCSR_PID24  BV(24)  ///< Peripheral Clock 24 Status
247 #define PMC_PCSR_PID25  BV(25)  ///< Peripheral Clock 25 Status
248 #define PMC_PCSR_PID26  BV(26)  ///< Peripheral Clock 26 Status
249 #define PMC_PCSR_PID27  BV(27)  ///< Peripheral Clock 27 Status
250 #define PMC_PCSR_PID28  BV(28)  ///< Peripheral Clock 28 Status
251 #define PMC_PCSR_PID29  BV(29)  ///< Peripheral Clock 29 Status
252 #define PMC_PCSR_PID30  BV(30)  ///< Peripheral Clock 30 Status
253 #define PMC_PCSR_PID31  BV(31)  ///< Peripheral Clock 31 Status
254 /*\}*/
255
256 /**
257  * Defines for bit fields in CKGR_MOR register.
258  */
259 /*\{*/
260 #define CKGR_MOR_MOSCXTEN         BV(0)   ///< Main Crystal Oscillator Enable
261 #define CKGR_MOR_MOSCXTBY         BV(1)   ///< Main Crystal Oscillator Bypass
262 #define CKGR_MOR_WAITMODE         BV(2)   ///< Wait Mode Command
263 #define CKGR_MOR_MOSCRCEN         BV(3)   ///< Main On-Chip RC Oscillator Enable
264 #define CKGR_MOR_MOSCRCF_S        4
265 #define CKGR_MOR_MOSCRCF_M        (0x7 << CKGR_MOR_MOSCRCF_S)   ///< Main On-Chip RC Oscillator Frequency Selection
266 #define CKGR_MOR_MOSCRCF(value)   ((CKGR_MOR_MOSCRCF_M & ((value) << CKGR_MOR_MOSCRCF_S)))
267 #define   CKGR_MOR_MOSCRCF_4MHZ   (0x0 << CKGR_MOR_MOSCRCF_S)
268 #define   CKGR_MOR_MOSCRCF_8MHZ   (0x1 << CKGR_MOR_MOSCRCF_S)
269 #define   CKGR_MOR_MOSCRCF_12MHZ  (0x2 << CKGR_MOR_MOSCRCF_S)
270 #define CKGR_MOR_MOSCXTST_S       8
271 #define CKGR_MOR_MOSCXTST_M       (0xff << CKGR_MOR_MOSCXTST_S)   ///< Main Crystal Oscillator Start-up Time
272 #define CKGR_MOR_MOSCXTST(value)  ((CKGR_MOR_MOSCXTST_M & ((value) << CKGR_MOR_MOSCXTST_S)))
273 #define CKGR_MOR_KEY_S            16
274 #define CKGR_MOR_KEY_M            (0xffu << CKGR_MOR_KEY_S)   ///< Password
275 #define CKGR_MOR_KEY(value)       ((CKGR_MOR_KEY_M & ((value) << CKGR_MOR_KEY_S)))
276 #define CKGR_MOR_MOSCSEL          BV(24)   ///< Main Oscillator Selection
277 #define CKGR_MOR_CFDEN            BV(25)   ///< Clock Failure Detector Enable
278 /*\}*/
279
280 /**
281  * Defines for bit fields in CKGR_MCFR register.
282  */
283 /*\{*/
284 #define CKGR_MCFR_MAINF_M   0xffffu   ///< Main Clock Frequency mask
285 #define CKGR_MCFR_MAINFRDY  BV(16)    ///< Main Clock Ready
286 /*\}*/
287
288 /**
289  * Defines for bit fields in CKGR_PLLR register.
290  */
291 /*\{*/
292 #define CKGR_PLLR_DIV_M           0xff   ///< Divider mask
293 #define CKGR_PLLR_DIV(value)      ((CKGR_PLLR_DIV_M & (value))
294 #define CKGR_PLLR_PLLCOUNT_S      8
295 #define CKGR_PLLR_PLLCOUNT_M      (0x3f << CKGR_PLLR_PLLCOUNT_S)   ///< PLL Counter mask
296 #define CKGR_PLLR_PLLCOUNT(value) ((CKGR_PLLR_PLLCOUNT_M & ((value) << CKGR_PLLR_PLLCOUNT_S)))
297 #define CKGR_PLLR_MUL_S           16
298 #define CKGR_PLLR_MUL_M           (0x7ff << CKGR_PLLR_MUL_S)   ///< PLL Multiplier mask
299 #define CKGR_PLLR_MUL(value)      ((CKGR_PLLR_MUL_M & ((value) << CKGR_PLLR_MUL_S)))
300 #define CKGR_PLLR_STUCKTO1        BV(29)
301 /*\}*/
302
303 /**
304  * Defines for bit fields in PMC_MCKR register.
305  */
306 /*\{*/
307 #define PMC_MCKR_CSS_M           0x3   ///< Master Clock Source Selection mask
308 #define   PMC_MCKR_CSS_SLOW_CLK  0x0   ///< Slow Clock is selected
309 #define   PMC_MCKR_CSS_MAIN_CLK  0x1   ///< Main Clock is selected
310 #define   PMC_MCKR_CSS_PLL_CLK   0x2   ///< PLL Clock is selected
311 #define PMC_MCKR_PRES_S          4
312 #define PMC_MCKR_PRES_M          (0x7u << PMC_MCKR_PRES_S)    ///< Processor Clock Prescaler mask
313 #define   PMC_MCKR_PRES_CLK      (0x0u << PMC_MCKR_PRES_S)   ///< Selected clock
314 #define   PMC_MCKR_PRES_CLK_2    (0x1u << PMC_MCKR_PRES_S)   ///< Selected clock divided by 2
315 #define   PMC_MCKR_PRES_CLK_4    (0x2u << PMC_MCKR_PRES_S)   ///< Selected clock divided by 4
316 #define   PMC_MCKR_PRES_CLK_8    (0x3u << PMC_MCKR_PRES_S)   ///< Selected clock divided by 8
317 #define   PMC_MCKR_PRES_CLK_16   (0x4u << PMC_MCKR_PRES_S)   ///< Selected clock divided by 16
318 #define   PMC_MCKR_PRES_CLK_32   (0x5u << PMC_MCKR_PRES_S)   ///< Selected clock divided by 32
319 #define   PMC_MCKR_PRES_CLK_64   (0x6u << PMC_MCKR_PRES_S)   ///< Selected clock divided by 64
320 #define   PMC_MCKR_PRES_CLK_3    (0x7u << PMC_MCKR_PRES_S)   ///< Selected clock divided by 3
321 #define PMC_MCKR_PLLDIV2         BV(12)   ///< PLL Divisor by 2
322 /*\}*/
323
324 /**
325  * Defines for bit fields in PMC_PCK[3] register.
326  */
327 /*\{*/
328 #define PMC_PCK_CSS_M          0x7   ///< Master Clock Source Selection mask
329 #define   PMC_PCK_CSS_SLOW     0x0   ///< Slow Clock is selected
330 #define   PMC_PCK_CSS_MAIN     0x1   ///< Main Clock is selected
331 #define   PMC_PCK_CSS_PLL      0x2   ///< PLL Clock is selected
332 #define   PMC_PCK_CSS_MCK      0x4   ///< Master Clock is selected
333 #define PMC_PCK_PRES_S 4
334 #define PMC_PCK_PRES_M         (0x7u << PMC_PCK_PRES_S)   ///< Programmable Clock Prescaler
335 #define   PMC_PCK_PRES_CLK     (0x0u << PMC_PCK_PRES_S)   ///< Selected clock
336 #define   PMC_PCK_PRES_CLK_2   (0x1u << PMC_PCK_PRES_S)   ///< Selected clock divided by 2
337 #define   PMC_PCK_PRES_CLK_4   (0x2u << PMC_PCK_PRES_S)   ///< Selected clock divided by 4
338 #define   PMC_PCK_PRES_CLK_8   (0x3u << PMC_PCK_PRES_S)   ///< Selected clock divided by 8
339 #define   PMC_PCK_PRES_CLK_16  (0x4u << PMC_PCK_PRES_S)   ///< Selected clock divided by 16
340 #define   PMC_PCK_PRES_CLK_32  (0x5u << PMC_PCK_PRES_S)   ///< Selected clock divided by 32
341 #define   PMC_PCK_PRES_CLK_64  (0x6u << PMC_PCK_PRES_S)   ///< Selected clock divided by 64
342 /*\}*/
343
344 /**
345  * Defines for bit fields in PMC_IER register.
346  */
347 /*\{*/
348 #define PMC_IER_MOSCXTS   BV(0)   ///< Main Crystal Oscillator Status Interrupt Enable
349 #define PMC_IER_LOCK      BV(1)   ///< PLL Lock Interrupt Enable
350 #define PMC_IER_MCKRDY    BV(3)   ///< Master Clock Ready Interrupt Enable
351 #define PMC_IER_PCKRDY0   BV(8)   ///< Programmable Clock Ready 0 Interrupt Enable
352 #define PMC_IER_PCKRDY1   BV(9)   ///< Programmable Clock Ready 1 Interrupt Enable
353 #define PMC_IER_PCKRDY2   BV(10)  ///< Programmable Clock Ready 2 Interrupt Enable
354 #define PMC_IER_MOSCSELS  BV(16)  ///< Main Oscillator Selection Status Interrupt Enable
355 #define PMC_IER_MOSCRCS   BV(17)  ///< Main On-Chip RC Status Interrupt Enable
356 #define PMC_IER_CFDEV     BV(18)  ///< Clock Failure Detector Event Interrupt Enable
357 /*\}*/
358
359 /**
360  * Defines for bit fields in PMC_IDR register.
361  */
362 /*\{*/
363 #define PMC_IDR_MOSCXTS   BV(0)   ///< Main Crystal Oscillator Status Interrupt Disable
364 #define PMC_IDR_LOCK      BV(1)   ///< PLL Lock Interrupt Disable
365 #define PMC_IDR_MCKRDY    BV(3)   ///< Master Clock Ready Interrupt Disable
366 #define PMC_IDR_PCKRDY0   BV(8)   ///< Programmable Clock Ready 0 Interrupt Disable
367 #define PMC_IDR_PCKRDY1   BV(9)   ///< Programmable Clock Ready 1 Interrupt Disable
368 #define PMC_IDR_PCKRDY2   BV(10)  ///< Programmable Clock Ready 2 Interrupt Disable
369 #define PMC_IDR_MOSCSELS  BV(16)  ///< Main Oscillator Selection Status Interrupt Disable
370 #define PMC_IDR_MOSCRCS   BV(17)  ///< Main On-Chip RC Status Interrupt Disable
371 #define PMC_IDR_CFDEV     BV(18)  ///< Clock Failure Detector Event Interrupt Disable
372 /*\}*/
373
374 /**
375  * Defines for bit fields in PMC_SR register.
376  */
377 /*\{*/
378 #define PMC_SR_MOSCXTS   BV(0)   ///< Main XTAL Oscillator Status
379 #define PMC_SR_LOCK      BV(1)   ///< PLL Lock Status
380 #define PMC_SR_MCKRDY    BV(3)   ///< Master Clock Status
381 #define PMC_SR_OSCSELS   BV(7)   ///< Slow Clock Oscillator Selection
382 #define PMC_SR_PCKRDY0   BV(8)   ///< Programmable Clock Ready Status
383 #define PMC_SR_PCKRDY1   BV(9)   ///< Programmable Clock Ready Status
384 #define PMC_SR_PCKRDY2   BV(10)  ///< Programmable Clock Ready Status
385 #define PMC_SR_MOSCSELS  BV(16)  ///< Main Oscillator Selection Status
386 #define PMC_SR_MOSCRCS   BV(17)  ///< Main On-Chip RC Oscillator Status
387 #define PMC_SR_CFDEV     BV(18)  ///< Clock Failure Detector Event
388 #define PMC_SR_CFDS      BV(19)  ///< Clock Failure Detector Status
389 #define PMC_SR_FOS       BV(20)  ///< Clock Failure Detector Fault Output Status
390 /*\}*/
391
392 /**
393  * Defines for bit fields in PMC_IMR register.
394  */
395 /*\{*/
396 #define PMC_IMR_MOSCXTS   BV(0)   ///< Main Crystal Oscillator Status Interrupt Mask
397 #define PMC_IMR_LOCK      BV(1)   ///< PLL Lock Interrupt Mask
398 #define PMC_IMR_MCKRDY    BV(3)   ///< Master Clock Ready Interrupt Mask
399 #define PMC_IMR_PCKRDY0   BV(8)   ///< Programmable Clock Ready 0 Interrupt Mask
400 #define PMC_IMR_PCKRDY1   BV(9)   ///< Programmable Clock Ready 1 Interrupt Mask
401 #define PMC_IMR_PCKRDY2   BV(10)  ///< Programmable Clock Ready 2 Interrupt Mask
402 #define PMC_IMR_MOSCSELS  BV(16)  ///< Main Oscillator Selection Status Interrupt Mask
403 #define PMC_IMR_MOSCRCS   BV(17)  ///< Main On-Chip RC Status Interrupt Mask
404 #define PMC_IMR_CFDEV     BV(18)  ///< Clock Failure Detector Event Interrupt Mask
405 /*\}*/
406
407 /**
408  * Defines for bit fields in PMC_FSMR register.
409  */
410 /*\{*/
411 #define PMC_FSMR_FSTT0   BV(0)   ///< Fast Startup Input Enable 0
412 #define PMC_FSMR_FSTT1   BV(1)   ///< Fast Startup Input Enable 1
413 #define PMC_FSMR_FSTT2   BV(2)   ///< Fast Startup Input Enable 2
414 #define PMC_FSMR_FSTT3   BV(3)   ///< Fast Startup Input Enable 3
415 #define PMC_FSMR_FSTT4   BV(4)   ///< Fast Startup Input Enable 4
416 #define PMC_FSMR_FSTT5   BV(5)   ///< Fast Startup Input Enable 5
417 #define PMC_FSMR_FSTT6   BV(6)   ///< Fast Startup Input Enable 6
418 #define PMC_FSMR_FSTT7   BV(7)   ///< Fast Startup Input Enable 7
419 #define PMC_FSMR_FSTT8   BV(8)   ///< Fast Startup Input Enable 8
420 #define PMC_FSMR_FSTT9   BV(9)   ///< Fast Startup Input Enable 9
421 #define PMC_FSMR_FSTT10  BV(10)  ///< Fast Startup Input Enable 10
422 #define PMC_FSMR_FSTT11  BV(11)  ///< Fast Startup Input Enable 11
423 #define PMC_FSMR_FSTT12  BV(12)  ///< Fast Startup Input Enable 12
424 #define PMC_FSMR_FSTT13  BV(13)  ///< Fast Startup Input Enable 13
425 #define PMC_FSMR_FSTT14  BV(14)  ///< Fast Startup Input Enable 14
426 #define PMC_FSMR_FSTT15  BV(15)  ///< Fast Startup Input Enable 15
427 #define PMC_FSMR_RTTAL   BV(16)  ///< RTT Alarm Enable
428 #define PMC_FSMR_RTCAL   BV(17)  ///< RTC Alarm Enable
429 #define PMC_FSMR_LPM     BV(20)  ///< Low Power Mode
430 /*\}*/
431
432 /**
433  * Defines for bit fields in PMC_FSPR register.
434  */
435 /*\{*/
436 #define PMC_FSPR_FSTP0   BV(0)   ///< Fast Startup Input Polarityx
437 #define PMC_FSPR_FSTP1   BV(1)   ///< Fast Startup Input Polarityx
438 #define PMC_FSPR_FSTP2   BV(2)   ///< Fast Startup Input Polarityx
439 #define PMC_FSPR_FSTP3   BV(3)   ///< Fast Startup Input Polarityx
440 #define PMC_FSPR_FSTP4   BV(4)   ///< Fast Startup Input Polarityx
441 #define PMC_FSPR_FSTP5   BV(5)   ///< Fast Startup Input Polarityx
442 #define PMC_FSPR_FSTP6   BV(6)   ///< Fast Startup Input Polarityx
443 #define PMC_FSPR_FSTP7   BV(7)   ///< Fast Startup Input Polarityx
444 #define PMC_FSPR_FSTP8   BV(8)   ///< Fast Startup Input Polarityx
445 #define PMC_FSPR_FSTP9   BV(9)   ///< Fast Startup Input Polarityx
446 #define PMC_FSPR_FSTP10  BV(10)  ///< Fast Startup Input Polarityx
447 #define PMC_FSPR_FSTP11  BV(11)  ///< Fast Startup Input Polarityx
448 #define PMC_FSPR_FSTP12  BV(12)  ///< Fast Startup Input Polarityx
449 #define PMC_FSPR_FSTP13  BV(13)  ///< Fast Startup Input Polarityx
450 #define PMC_FSPR_FSTP14  BV(14)  ///< Fast Startup Input Polarityx
451 #define PMC_FSPR_FSTP15  BV(15)  ///< Fast Startup Input Polarityx
452 /*\}*/
453
454 /**
455  * Defines for bit fields in PMC_FOCR register.
456  */
457 /*\{*/
458 #define PMC_FOCR_FOCLR  BV(0)   ///< Fault Output Clear
459 /*\}*/
460
461 /**
462  * Defines for bit fields in PMC_WPMR register.
463  */
464 /*\{*/
465 #define PMC_WPMR_WPEN          BV(0)   ///< Write Protect Enable
466 #define PMC_WPMR_WPKEY_S       8
467 #define PMC_WPMR_WPKEY_M       (0xffffff << PMC_WPMR_WPKEY_S)   ///< Write Protect key mask
468 #define PMC_WPMR_WPKEY(value)  ((PMC_WPMR_WPKEY_M & ((value) << PMC_WPMR_WPKEY_S)))
469 /*\}*/
470
471 /**
472  * Defines for bit fields in PMC_WPSR register.
473  */
474 /*\{*/
475 #define PMC_WPSR_WPVS      BV(0)   ///< Write Protect Violation Status
476 #define PMC_WPSR_WPVSRC_S  8
477 #define PMC_WPSR_WPVSRC_M  (0xffff << PMC_WPSR_WPVSRC_S)   ///< Write Protect Violation Source mask
478 /*\}*/
479
480 /**
481  * Defines for bit fields in PMC_OCR register.
482  */
483 /*\{*/
484 #define PMC_OCR_CAL4_M        0x7f  ///< RC Oscillator Calibration bits for 4 MHz mask
485 #define PMC_OCR_CAL4(value)   (PMC_OCR_CAL4_M & (value))
486 #define PMC_OCR_SEL4          BV(7)   ///< Selection of RC Oscillator Calibration bits for 4 MHz
487 #define PMC_OCR_CAL8_S        8
488 #define PMC_OCR_CAL8_M        (0x7f << PMC_OCR_CAL8_S)   ///< RC Oscillator Calibration bits for 8 MHz mask
489 #define PMC_OCR_CAL8(value)   ((PMC_OCR_CAL8_M & ((value) << PMC_OCR_CAL8_S)))
490 #define PMC_OCR_SEL8          BV(15)  ///< Selection of RC Oscillator Calibration bits for 8 MHz
491 #define PMC_OCR_CAL12_S       16
492 #define PMC_OCR_CAL12_M       (0x7f << PMC_OCR_CAL12_S)   ///< RC Oscillator Calibration bits for 12 MHz mask
493 #define PMC_OCR_CAL12(value)  ((PMC_OCR_CAL12_M & ((value) << PMC_OCR_CAL12_S)))
494 #define PMC_OCR_SEL12         BV(23)   ///< Selection of RC Oscillator Calibration bits for 12 MHz
495 /*\}*/
496
497
498 #endif /* SAM3_PMC_H */