Browse Source

sam: Add convenience function for clock setup using internal 4MHz.

pull/151/merge
Gareth McMullin 12 years ago
committed by Piotr Esden-Tempski
parent
commit
662a2cb8fa
  1. 1
      include/libopencm3/sam/pmc.h
  2. 14
      lib/sam/common/pmc.c

1
include/libopencm3/sam/pmc.h

@ -140,6 +140,7 @@ void pmc_plla_config(u8 mul, u8 div);
void pmc_peripheral_clock_enable(u8 pid);
void pmc_peripheral_clock_disable(u8 pid);
void pmc_clock_setup_in_xtal_12mhz_out_84mhz(void);
void pmc_clock_setup_in_rc_4mhz_out_84mhz(void);
#endif

14
lib/sam/common/pmc.c

@ -79,3 +79,17 @@ void pmc_clock_setup_in_xtal_12mhz_out_84mhz(void)
pmc_mck_frequency = 84000000;
}
void pmc_clock_setup_in_rc_4mhz_out_84mhz(void)
{
eefc_set_latency(4);
/* Select as main oscillator */
CKGR_MOR = CKGR_MOR_KEY |
(CKGR_MOR & ~(CKGR_MOR_MOSCSEL | CKGR_MOR_MOSCRCF_MASK));
/* Multiply by 21 for 84MHz */
pmc_plla_config(21, 1);
pmc_mck_set_source(MCK_SRC_PLLA);
pmc_mck_frequency = 84000000;
}

Loading…
Cancel
Save