drivers/pmc/pmc.h
Go to the documentation of this file.
1 
33 /*
34  * Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
35  */
36 
37 #ifndef PMC_H_INCLUDED
38 #define PMC_H_INCLUDED
39 
40 #include "compiler.h"
41 
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 
51 #define PMC_MASK_STATUS0 (0xFFFFFFFC)
52 
54 #define PMC_MASK_STATUS1 (0xFFFFFFFF)
55 
57 #if !(SAME70)
58 #define PMC_TIMEOUT (2048)
59 #else
60 #define PMC_TIMEOUT (4096)
61 #endif
62 
64 #ifndef CKGR_MOR_KEY_PASSWD
65 #define CKGR_MOR_KEY_PASSWD CKGR_MOR_KEY(0x37U)
66 #endif
67 
69 #ifndef SUPC_CR_KEY_PASSWD
70 #define SUPC_CR_KEY_PASSWD SUPC_CR_KEY(0xA5U)
71 #endif
72 
73 #ifndef SUPC_MR_KEY_PASSWD
74 #define SUPC_MR_KEY_PASSWD SUPC_MR_KEY(0xA5U)
75 #endif
76 
78 #define PMC_FAST_STARTUP_Msk (0x7FFFFu)
79 
81 #ifndef PMC_WPMR_WPKEY_PASSWD
82 #define PMC_WPMR_WPKEY_PASSWD PMC_WPMR_WPKEY((uint32_t) 0x504D43)
83 #endif
84 
86 #define PMC_OSC_XTAL 0
87 
89 #define PMC_OSC_BYPASS 1
90 
91 #define PMC_PCK_0 0 /* PCK0 ID */
92 #define PMC_PCK_1 1 /* PCK1 ID */
93 #define PMC_PCK_2 2 /* PCK2 ID */
94 #if (SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70)
95 #define PMC_PCK_3 3 /* PCK3 ID */
96 #define PMC_PCK_4 4 /* PCK4 ID */
97 #define PMC_PCK_5 5 /* PCK5 ID */
98 #define PMC_PCK_6 6 /* PCK6 ID */
99 #if SAMG55
100 #define PMC_PCK_7 7 /* PCK7 ID */
101 #endif
102 #endif
103 
104 #if (SAM4S || SAM4E || SAM4N || SAM4C || SAM4CM || SAMG || SAM4CP || SAMV71 || SAMV70 || SAME70 || SAMS70)
105 
106 #define PMC_WAIT_MODE_FLASH_STANDBY PMC_FSMR_FLPM_FLASH_STANDBY
107 #define PMC_WAIT_MODE_FLASH_DEEP_POWERDOWN PMC_FSMR_FLPM_FLASH_DEEP_POWERDOWN
108 #define PMC_WAIT_MODE_FLASH_IDLE PMC_FSMR_FLPM_FLASH_IDLE
109 #endif
110 
112 #define pmc_us_to_moscxtst(startup_us, slowck_freq) \
113  ((startup_us * slowck_freq / 8 / 1000000) < 0x100 ? \
114  (startup_us * slowck_freq / 8 / 1000000) : 0xFF)
115 
123 
124 void pmc_mck_set_prescaler(uint32_t ul_pres);
125 #if SAMV71 || SAMV70 || SAME70 || SAMS70
126 void pmc_mck_set_division(uint32_t ul_div);
127 #endif
128 void pmc_mck_set_source(uint32_t ul_source);
129 uint32_t pmc_switch_mck_to_sclk(uint32_t ul_pres);
130 uint32_t pmc_switch_mck_to_mainck(uint32_t ul_pres);
131 uint32_t pmc_switch_mck_to_pllack(uint32_t ul_pres);
132 #if (SAM3S || SAM4S || SAM4C || SAM4CM || SAM4CP || SAMG55)
133 uint32_t pmc_switch_mck_to_pllbck(uint32_t ul_pres);
134 #endif
135 #if (SAM3XA || SAM3U || SAMV71 || SAMV70 || SAME70 || SAMS70)
136 uint32_t pmc_switch_mck_to_upllck(uint32_t ul_pres);
137 #endif
138 #if (SAM4S || SAM4E || SAM4N || SAM4C || SAM4CM || SAMG || SAM4CP || SAMV71 || SAMV70 || SAME70 || SAMS70)
139 void pmc_set_flash_in_wait_mode(uint32_t ul_flash_state);
140 #endif
141 
142 
144 
150 
151 void pmc_switch_sclk_to_32kxtal(uint32_t ul_bypass);
152 uint32_t pmc_osc_is_ready_32kxtal(void);
153 
155 
161 
162 void pmc_switch_mainck_to_fastrc(uint32_t ul_moscrcf);
163 void pmc_osc_enable_fastrc(uint32_t ul_rc);
164 void pmc_osc_disable_fastrc(void);
165 uint32_t pmc_osc_is_ready_fastrc(void);
166 void pmc_osc_enable_main_xtal(uint32_t ul_xtal_startup_time);
167 void pmc_osc_bypass_main_xtal(void);
168 void pmc_osc_disable_main_xtal(void);
169 uint32_t pmc_osc_is_bypassed_main_xtal(void);
170 uint32_t pmc_osc_is_ready_main_xtal(void);
171 void pmc_switch_mainck_to_xtal(uint32_t ul_bypass,
172  uint32_t ul_xtal_startup_time);
173 void pmc_osc_disable_xtal(uint32_t ul_bypass);
174 uint32_t pmc_osc_is_ready_mainck(void);
175 void pmc_mainck_osc_select(uint32_t ul_xtal_rc);
176 
178 
184 
185 void pmc_enable_pllack(uint32_t mula, uint32_t pllacount, uint32_t diva);
186 void pmc_disable_pllack(void);
187 uint32_t pmc_is_locked_pllack(void);
188 
189 #if (SAM3S || SAM4S || SAM4C || SAM4CM || SAM4CP || SAMG55)
190 void pmc_enable_pllbck(uint32_t mulb, uint32_t pllbcount, uint32_t divb);
191 void pmc_disable_pllbck(void);
192 uint32_t pmc_is_locked_pllbck(void);
193 #endif
194 
195 #if (SAM3XA || SAM3U || SAMV71 || SAMV70 || SAME70 || SAMS70)
196 void pmc_enable_upll_clock(void);
197 void pmc_disable_upll_clock(void);
198 uint32_t pmc_is_locked_upll(void);
199 #endif
200 
202 
208 
209 uint32_t pmc_enable_periph_clk(uint32_t ul_id);
210 uint32_t pmc_disable_periph_clk(uint32_t ul_id);
211 void pmc_enable_all_periph_clk(void);
212 void pmc_disable_all_periph_clk(void);
213 uint32_t pmc_is_periph_clk_enabled(uint32_t ul_id);
214 
216 
224 
225 void pmc_pck_set_prescaler(uint32_t ul_id, uint32_t ul_pres);
226 void pmc_pck_set_source(uint32_t ul_id, uint32_t ul_source);
227 uint32_t pmc_switch_pck_to_sclk(uint32_t ul_id, uint32_t ul_pres);
228 uint32_t pmc_switch_pck_to_mainck(uint32_t ul_id, uint32_t ul_pres);
229 uint32_t pmc_switch_pck_to_pllack(uint32_t ul_id, uint32_t ul_pres);
230 #if (SAM4C || SAM4CM || SAM4CP)
231 void pmc_enable_cpck(void);
232 void pmc_disable_cpck(void);
233 bool pmc_is_cpck_enabled(void);
234 void pmc_enable_cpbmck(void);
235 void pmc_disable_cpbmck(void);
236 bool pmc_is_cpbmck_enabled(void);
237 void pmc_cpck_set_prescaler(uint32_t ul_pres);
238 void pmc_cpck_set_source(uint32_t ul_source);
239 #endif
240 #if (SAM3S || SAM4S || SAM4C || SAM4CM || SAM4CP || SAMG55)
241 uint32_t pmc_switch_pck_to_pllbck(uint32_t ul_id, uint32_t ul_pres);
242 #endif
243 #if (SAM3XA || SAM3U || SAMV71 || SAMV70 || SAME70 || SAMS70)
244 uint32_t pmc_switch_pck_to_upllck(uint32_t ul_id, uint32_t ul_pres);
245 #endif
246 uint32_t pmc_switch_pck_to_mck(uint32_t ul_id, uint32_t ul_pres);
247 void pmc_enable_pck(uint32_t ul_id);
248 void pmc_disable_pck(uint32_t ul_id);
249 void pmc_enable_all_pck(void);
250 void pmc_disable_all_pck(void);
251 uint32_t pmc_is_pck_enabled(uint32_t ul_id);
252 
254 
260 
261 #if (SAM3S || SAM3XA || SAM4S || SAM4E || SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70)
262 void pmc_switch_udpck_to_pllack(uint32_t ul_usbdiv);
263 #endif
264 #if (SAM3S || SAM4S || SAMG55)
265 void pmc_switch_udpck_to_pllbck(uint32_t ul_usbdiv);
266 #endif
267 #if (SAM3XA || SAMV71 || SAMV70 || SAME70 || SAMS70)
268 void pmc_switch_udpck_to_upllck(uint32_t ul_usbdiv);
269 #endif
270 #if (SAM3S || SAM3XA || SAM4S || SAM4E || SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70)
271 void pmc_enable_udpck(void);
272 void pmc_disable_udpck(void);
273 #endif
274 #if SAMG55
275 void pmc_switch_uhpck_to_pllack(uint32_t ul_usbdiv);
276 void pmc_switch_uhpck_to_pllbck(uint32_t ul_usbdiv);
277 void pmc_enable_uhpck(void);
278 #endif
279 
281 
287 
288 void pmc_enable_interrupt(uint32_t ul_sources);
289 void pmc_disable_interrupt(uint32_t ul_sources);
290 uint32_t pmc_get_interrupt_mask(void);
291 uint32_t pmc_get_status(void);
292 
294 
302 
303 void pmc_set_fast_startup_input(uint32_t ul_inputs);
304 void pmc_clr_fast_startup_input(uint32_t ul_inputs);
305 #if (SAM4C || SAM4CM || SAM4CP)
306 void pmc_cp_set_fast_startup_input(uint32_t ul_inputs);
307 void pmc_cp_clr_fast_startup_input(uint32_t ul_inputs);
308 #endif
309 void pmc_enable_sleepmode(uint8_t uc_type);
310 void pmc_enable_waitmode(void);
311 #if (!(SAMG51 || SAMG53 || SAMG54))
312 void pmc_enable_backupmode(void);
313 #endif
314 
315 
321 
324 
326 
327 #if (SAM4N || SAM4C || SAM4CM || SAM4CP || SAMV71 || SAMV70 || SAME70 || SAMS70)
328 
333 
334 void pmc_enable_sclk_osc_freq_monitor(void);
335 void pmc_disable_sclk_osc_freq_monitor(void);
336 
338 #endif
339 
345 
346 void pmc_set_writeprotect(uint32_t ul_enable);
347 uint32_t pmc_get_writeprotect_status(void);
348 
350 
351 #if (SAMG53 || SAMG54 || SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70)
352 
357 
358 uint32_t pmc_enable_sleepwalking(uint32_t ul_id);
359 uint32_t pmc_disable_sleepwalking(uint32_t ul_id);
360 uint32_t pmc_get_sleepwalking_status0(void);
361 uint32_t pmc_get_active_status0(void);
362 #if (SAMV71 || SAMV70 || SAME70 || SAMS70)
363 uint32_t pmc_get_sleepwalking_status1(void);
364 uint32_t pmc_get_active_status1(void);
365 #endif
366 
367 #endif
368 
370 
371 #ifdef __cplusplus
372 }
373 #endif
374 
375 
378 
540 #endif /* PMC_H_INCLUDED */
void pmc_disable_all_periph_clk(void)
Disable all peripheral clocks.
Definition: pmc.c:776
void pmc_disable_clock_failure_detector(void)
Disable Clock Failure Detector.
Definition: pmc.c:1494
uint32_t pmc_get_writeprotect_status(void)
Return write protect status.
Definition: pmc.c:1542
void pmc_switch_mainck_to_xtal(uint32_t ul_bypass, uint32_t ul_xtal_startup_time)
Switch main clock source selection to external Xtal/Bypass.
Definition: pmc.c:485
uint32_t pmc_switch_pck_to_sclk(uint32_t ul_id, uint32_t ul_pres)
Switch programmable clock source selection to slow clock.
Definition: pmc.c:874
uint32_t pmc_osc_is_ready_32kxtal(void)
Check if the external 32k Xtal is ready.
Definition: pmc.c:336
void pmc_disable_all_pck(void)
Disable all programmable clocks.
Definition: pmc.c:1046
void pmc_enable_sleepmode(uint8_t uc_type)
Enable Sleep Mode. Enter condition: (WFE or WFI) + (SLEEPDEEP bit = 0) + (LPM bit = 0) ...
Definition: pmc.c:1348
void pmc_enable_pck(uint32_t ul_id)
Enable the specified programmable clock.
Definition: pmc.c:1020
void pmc_osc_bypass_main_xtal(void)
Bypass main XTAL.
Definition: pmc.c:430
uint32_t pmc_switch_mck_to_pllack(uint32_t ul_pres)
Switch master clock source selection to PLLA clock.
Definition: pmc.c:218
void pmc_enable_waitmode(void)
Enable Wait Mode. Enter condition: WFE + (SLEEPDEEP bit = 0) + (LPM bit = 1)
Definition: pmc.c:1433
void pmc_disable_interrupt(uint32_t ul_sources)
Disable PMC interrupts.
Definition: pmc.c:1265
uint32_t pmc_is_pck_enabled(uint32_t ul_id)
Check if the specified programmable clock is enabled.
Definition: pmc.c:1059
void pmc_osc_disable_main_xtal(void)
Disable the main Xtal.
Definition: pmc.c:443
void pmc_mck_set_prescaler(uint32_t ul_pres)
Set the prescaler of the MCK.
Definition: pmc.c:96
uint32_t pmc_switch_mck_to_sclk(uint32_t ul_pres)
Switch master clock source selection to slow clock.
Definition: pmc.c:154
void pmc_enable_clock_failure_detector(void)
Enable Clock Failure Detector.
Definition: pmc.c:1484
uint32_t pmc_disable_periph_clk(uint32_t ul_id)
Disable the specified peripheral clock.
Definition: pmc.c:722
uint32_t pmc_enable_periph_clk(uint32_t ul_id)
Enable the specified peripheral clock.
Definition: pmc.c:682
void pmc_switch_sclk_to_32kxtal(uint32_t ul_bypass)
Switch slow clock source selection to external 32k (Xtal or Bypass).
Definition: pmc.c:319
uint32_t pmc_osc_is_ready_main_xtal(void)
Check if the main crystal is ready.
Definition: pmc.c:467
void pmc_enable_all_periph_clk(void)
Enable all peripheral clocks.
Definition: pmc.c:755
uint32_t pmc_osc_is_ready_mainck(void)
Check if the MAINCK is ready. Depending on MOSCEL, MAINCK can be one of Xtal, bypass or internal RC...
Definition: pmc.c:528
void pmc_set_writeprotect(uint32_t ul_enable)
Enable or disable write protect of PMC registers.
Definition: pmc.c:1528
void pmc_disable_pck(uint32_t ul_id)
Disable the specified programmable clock.
Definition: pmc.c:1030
void pmc_enable_all_pck(void)
Enable all programmable clocks.
Definition: pmc.c:1038
void pmc_enable_interrupt(uint32_t ul_sources)
Enable PMC interrupts.
Definition: pmc.c:1255
Commonly used includes, types and macros.
void pmc_set_fast_startup_input(uint32_t ul_inputs)
Set the wake-up inputs for fast startup mode registers (event generation).
Definition: pmc.c:1296
void pmc_enable_pllack(uint32_t mula, uint32_t pllacount, uint32_t diva)
Enable PLLA clock.
Definition: pmc.c:558
void pmc_clr_fast_startup_input(uint32_t ul_inputs)
Clear the wake-up inputs for fast startup mode registers (remove event generation).
Definition: pmc.c:1308
uint32_t pmc_is_locked_pllack(void)
Is PLLA locked?
Definition: pmc.c:591
void pmc_mainck_osc_select(uint32_t ul_xtal_rc)
Select Main Crystal or internal RC as main clock source.
Definition: pmc.c:540
uint32_t pmc_switch_pck_to_pllack(uint32_t ul_id, uint32_t ul_pres)
Switch programmable clock source selection to PLLA clock.
Definition: pmc.c:922
uint32_t pmc_get_status(void)
Get current status.
Definition: pmc.c:1285
void pmc_pck_set_source(uint32_t ul_id, uint32_t ul_source)
Set the source oscillator for the specified programmable clock.
Definition: pmc.c:857
void pmc_enable_backupmode(void)
Enable Backup Mode. Enter condition: WFE/(VROFF bit = 1) + (SLEEPDEEP bit = 1)
Definition: pmc.c:1459
void pmc_switch_mainck_to_fastrc(uint32_t ul_moscrcf)
Switch main clock source selection to internal fast RC.
Definition: pmc.c:351
void pmc_osc_disable_xtal(uint32_t ul_bypass)
Disable the external Xtal.
Definition: pmc.c:509
uint32_t pmc_switch_pck_to_mck(uint32_t ul_id, uint32_t ul_pres)
Switch programmable clock source selection to mck.
Definition: pmc.c:1000
void pmc_mck_set_source(uint32_t ul_source)
Set the source of the MCK.
Definition: pmc.c:139
void pmc_osc_enable_main_xtal(uint32_t ul_xtal_startup_time)
Enable main XTAL oscillator.
Definition: pmc.c:416
uint32_t pmc_switch_mck_to_mainck(uint32_t ul_pres)
Switch master clock source selection to main clock.
Definition: pmc.c:186
uint32_t pmc_switch_pck_to_mainck(uint32_t ul_id, uint32_t ul_pres)
Switch programmable clock source selection to main clock.
Definition: pmc.c:898
void pmc_pck_set_prescaler(uint32_t ul_id, uint32_t ul_pres)
Set the prescaler for the specified programmable clock.
Definition: pmc.c:843
uint32_t pmc_is_periph_clk_enabled(uint32_t ul_id)
Check if the specified peripheral clock is enabled.
Definition: pmc.c:804
void pmc_osc_disable_fastrc(void)
Disable the internal fast RC.
Definition: pmc.c:393
void pmc_osc_enable_fastrc(uint32_t ul_rc)
Enable fast RC oscillator.
Definition: pmc.c:376
uint32_t pmc_osc_is_bypassed_main_xtal(void)
Check if the main crystal is bypassed.
Definition: pmc.c:455
uint32_t pmc_get_interrupt_mask(void)
Get PMC interrupt mask.
Definition: pmc.c:1275
uint32_t pmc_osc_is_ready_fastrc(void)
Check if the main fastrc is ready.
Definition: pmc.c:406
void pmc_disable_pllack(void)
Disable PLLA clock.
Definition: pmc.c:576


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:58