00001
00030 #include <avr32/io.h>
00031 #include "board.h"
00032 #include "clocks.h"
00033 #include "pm.h"
00034 #include "flashc.h"
00035 #include "gpio.h"
00036
00040 void
00041 init_sys_clocks(void)
00042 {
00043
00044 pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP);
00045
00046 #ifndef USE_PLL
00047 return;
00048 #endif
00049
00050
00051
00052
00053 #if OSC == 1
00054
00055 pm_enable_osc1_crystal(&AVR32_PM, FOSC1);
00056 pm_enable_clk1(&AVR32_PM, OSC1_STARTUP);
00057 #endif
00058
00059
00060 pm_pll_setup(&AVR32_PM,
00061 0,
00062 PLL_MUL,
00063 1,
00064 OSC,
00065 16);
00066
00067
00068
00069
00070 pm_pll_set_option(&AVR32_PM,
00071 0,
00072 1,
00073 1,
00074 0);
00075
00076
00077
00078 pm_pll_enable(&AVR32_PM, 0);
00079 pm_wait_for_pll0_locked(&AVR32_PM);
00080
00081
00082 pm_cksel(&AVR32_PM,
00083 0,
00084 0,
00085 0,
00086 0,
00087 0,
00088 0);
00089
00090
00091 flashc_set_wait_state(1);
00092
00093
00094 pm_switch_to_clock(&AVR32_PM, AVR32_PM_MCCTRL_MCSEL_PLL0);
00095
00096 #if OSC == 1
00097 pm_configure_usb_clock();
00098 #endif
00099 }