37 #ifndef PMC_H_INCLUDED    38 #define PMC_H_INCLUDED    51 #define PMC_MASK_STATUS0        (0xFFFFFFFC)    54 #define PMC_MASK_STATUS1        (0xFFFFFFFF)    58 #define PMC_TIMEOUT             (2048)    60 #define PMC_TIMEOUT             (4096)    64 #ifndef CKGR_MOR_KEY_PASSWD    65 #define CKGR_MOR_KEY_PASSWD    CKGR_MOR_KEY(0x37U)    69 #ifndef SUPC_CR_KEY_PASSWD    70 #define SUPC_CR_KEY_PASSWD    SUPC_CR_KEY(0xA5U)    73 #ifndef SUPC_MR_KEY_PASSWD    74 #define SUPC_MR_KEY_PASSWD    SUPC_MR_KEY(0xA5U)    78 #define PMC_FAST_STARTUP_Msk    (0x7FFFFu)    81 #ifndef PMC_WPMR_WPKEY_PASSWD    82 #define PMC_WPMR_WPKEY_PASSWD    PMC_WPMR_WPKEY((uint32_t) 0x504D43)    86 #define PMC_OSC_XTAL            0    89 #define PMC_OSC_BYPASS          1    94 #if (SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70)   104 #if (SAM4S || SAM4E || SAM4N || SAM4C || SAM4CM || SAMG || SAM4CP || SAMV71 || SAMV70 || SAME70 || SAMS70)   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   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)   125 #if SAMV71 || SAMV70 || SAME70 || SAMS70   126 void pmc_mck_set_division(uint32_t ul_div);
   132 #if (SAM3S || SAM4S || SAM4C || SAM4CM || SAM4CP || SAMG55)   133 uint32_t pmc_switch_mck_to_pllbck(uint32_t ul_pres);
   135 #if (SAM3XA || SAM3U || SAMV71 || SAMV70 || SAME70 || SAMS70)   136 uint32_t pmc_switch_mck_to_upllck(uint32_t ul_pres);
   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);
   172                 uint32_t ul_xtal_startup_time);
   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);
   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);
   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);
   240 #if (SAM3S || SAM4S || SAM4C || SAM4CM || SAM4CP || SAMG55)   241 uint32_t pmc_switch_pck_to_pllbck(uint32_t ul_id, uint32_t ul_pres);
   243 #if (SAM3XA || SAM3U || SAMV71 || SAMV70 || SAME70 || SAMS70)   244 uint32_t pmc_switch_pck_to_upllck(uint32_t ul_id, uint32_t ul_pres);
   261 #if (SAM3S || SAM3XA || SAM4S || SAM4E || SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70)   262 void pmc_switch_udpck_to_pllack(uint32_t ul_usbdiv);
   264 #if (SAM3S || SAM4S || SAMG55)   265 void pmc_switch_udpck_to_pllbck(uint32_t ul_usbdiv);
   267 #if (SAM3XA || SAMV71 || SAMV70 || SAME70 || SAMS70)   268 void pmc_switch_udpck_to_upllck(uint32_t ul_usbdiv);
   270 #if (SAM3S || SAM3XA || SAM4S || SAM4E || SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70)   271 void pmc_enable_udpck(
void);
   272 void pmc_disable_udpck(
void);
   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);
   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);
   311 #if (!(SAMG51 || SAMG53 || SAMG54))   327 #if (SAM4N || SAM4C || SAM4CM || SAM4CP || SAMV71 || SAMV70 || SAME70 || SAMS70)   334 void pmc_enable_sclk_osc_freq_monitor(
void);
   335 void pmc_disable_sclk_osc_freq_monitor(
void);
   351 #if (SAMG53 || SAMG54 || SAMG55 || SAMV71 || SAMV70 || SAME70 || SAMS70)   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);
 void pmc_disable_all_periph_clk(void)
Disable all peripheral clocks. 
 
void pmc_disable_clock_failure_detector(void)
Disable Clock Failure Detector. 
 
uint32_t pmc_get_writeprotect_status(void)
Return write protect status. 
 
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. 
 
uint32_t pmc_switch_pck_to_sclk(uint32_t ul_id, uint32_t ul_pres)
Switch programmable clock source selection to slow clock. 
 
uint32_t pmc_osc_is_ready_32kxtal(void)
Check if the external 32k Xtal is ready. 
 
void pmc_disable_all_pck(void)
Disable all programmable clocks. 
 
void pmc_enable_sleepmode(uint8_t uc_type)
Enable Sleep Mode. Enter condition: (WFE or WFI) + (SLEEPDEEP bit = 0) + (LPM bit = 0) ...
 
void pmc_enable_pck(uint32_t ul_id)
Enable the specified programmable clock. 
 
void pmc_osc_bypass_main_xtal(void)
Bypass main XTAL. 
 
uint32_t pmc_switch_mck_to_pllack(uint32_t ul_pres)
Switch master clock source selection to PLLA clock. 
 
void pmc_enable_waitmode(void)
Enable Wait Mode. Enter condition: WFE + (SLEEPDEEP bit = 0) + (LPM bit = 1) 
 
void pmc_disable_interrupt(uint32_t ul_sources)
Disable PMC interrupts. 
 
uint32_t pmc_is_pck_enabled(uint32_t ul_id)
Check if the specified programmable clock is enabled. 
 
void pmc_osc_disable_main_xtal(void)
Disable the main Xtal. 
 
void pmc_mck_set_prescaler(uint32_t ul_pres)
Set the prescaler of the MCK. 
 
uint32_t pmc_switch_mck_to_sclk(uint32_t ul_pres)
Switch master clock source selection to slow clock. 
 
void pmc_enable_clock_failure_detector(void)
Enable Clock Failure Detector. 
 
uint32_t pmc_disable_periph_clk(uint32_t ul_id)
Disable the specified peripheral clock. 
 
uint32_t pmc_enable_periph_clk(uint32_t ul_id)
Enable the specified peripheral clock. 
 
void pmc_switch_sclk_to_32kxtal(uint32_t ul_bypass)
Switch slow clock source selection to external 32k (Xtal or Bypass). 
 
uint32_t pmc_osc_is_ready_main_xtal(void)
Check if the main crystal is ready. 
 
void pmc_enable_all_periph_clk(void)
Enable all peripheral clocks. 
 
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...
 
void pmc_set_writeprotect(uint32_t ul_enable)
Enable or disable write protect of PMC registers. 
 
void pmc_disable_pck(uint32_t ul_id)
Disable the specified programmable clock. 
 
void pmc_enable_all_pck(void)
Enable all programmable clocks. 
 
void pmc_enable_interrupt(uint32_t ul_sources)
Enable PMC interrupts. 
 
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). 
 
void pmc_enable_pllack(uint32_t mula, uint32_t pllacount, uint32_t diva)
Enable PLLA clock. 
 
void pmc_clr_fast_startup_input(uint32_t ul_inputs)
Clear the wake-up inputs for fast startup mode registers (remove event generation). 
 
uint32_t pmc_is_locked_pllack(void)
Is PLLA locked? 
 
void pmc_mainck_osc_select(uint32_t ul_xtal_rc)
Select Main Crystal or internal RC as main clock source. 
 
uint32_t pmc_switch_pck_to_pllack(uint32_t ul_id, uint32_t ul_pres)
Switch programmable clock source selection to PLLA clock. 
 
uint32_t pmc_get_status(void)
Get current status. 
 
void pmc_pck_set_source(uint32_t ul_id, uint32_t ul_source)
Set the source oscillator for the specified programmable clock. 
 
void pmc_enable_backupmode(void)
Enable Backup Mode. Enter condition: WFE/(VROFF bit = 1) + (SLEEPDEEP bit = 1) 
 
void pmc_switch_mainck_to_fastrc(uint32_t ul_moscrcf)
Switch main clock source selection to internal fast RC. 
 
void pmc_osc_disable_xtal(uint32_t ul_bypass)
Disable the external Xtal. 
 
uint32_t pmc_switch_pck_to_mck(uint32_t ul_id, uint32_t ul_pres)
Switch programmable clock source selection to mck. 
 
void pmc_mck_set_source(uint32_t ul_source)
Set the source of the MCK. 
 
void pmc_osc_enable_main_xtal(uint32_t ul_xtal_startup_time)
Enable main XTAL oscillator. 
 
uint32_t pmc_switch_mck_to_mainck(uint32_t ul_pres)
Switch master clock source selection to main clock. 
 
uint32_t pmc_switch_pck_to_mainck(uint32_t ul_id, uint32_t ul_pres)
Switch programmable clock source selection to main clock. 
 
void pmc_pck_set_prescaler(uint32_t ul_id, uint32_t ul_pres)
Set the prescaler for the specified programmable clock. 
 
uint32_t pmc_is_periph_clk_enabled(uint32_t ul_id)
Check if the specified peripheral clock is enabled. 
 
void pmc_osc_disable_fastrc(void)
Disable the internal fast RC. 
 
void pmc_osc_enable_fastrc(uint32_t ul_rc)
Enable fast RC oscillator. 
 
uint32_t pmc_osc_is_bypassed_main_xtal(void)
Check if the main crystal is bypassed. 
 
uint32_t pmc_get_interrupt_mask(void)
Get PMC interrupt mask. 
 
uint32_t pmc_osc_is_ready_fastrc(void)
Check if the main fastrc is ready. 
 
void pmc_disable_pllack(void)
Disable PLLA clock.