00001
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef _POWER_CLOCKS_LIB_H_
00050 #define _POWER_CLOCKS_LIB_H_
00051
00052 #ifdef __cplusplus
00053 extern "C" {
00054 #endif
00055
00056 #include <avr32/io.h>
00057 #include "compiler.h"
00058
00059 #ifndef AVR32_PM_VERSION_RESETVALUE
00060
00061 #include "pm.h"
00062 #else
00064 #if UC3L
00065 #include "pm_uc3l.h"
00066 #include "scif_uc3l.h"
00067 #include "flashcdw.h"
00068 #elif UC3C
00069 #include "pm_uc3c.h"
00070 #include "scif_uc3c.h"
00071 #include "flashc.h"
00072 #endif
00073 #endif
00074
00077
00078
00080 typedef enum
00081 {
00082 PCL_OSC0 = 0,
00083 PCL_OSC1 = 1
00084 } pcl_osc_t;
00085
00087 typedef enum
00088 {
00089 PCL_DFLL0 = 0,
00090 PCL_DFLL1 = 1
00091 } pcl_dfll_t;
00092
00094 typedef enum
00095 {
00096 PCL_MC_RCSYS,
00097 PCL_MC_OSC0,
00098 PCL_MC_OSC1,
00099 PCL_MC_OSC0_PLL0,
00100 PCL_MC_OSC1_PLL0,
00101 PCL_MC_OSC0_PLL1,
00102 PCL_MC_OSC1_PLL1,
00103 PCL_MC_DFLL0,
00104 PCL_MC_DFLL1,
00105 PCL_MC_RC120M,
00106 PCL_MC_RC8M,
00107 PCL_MC_CRIPOSC
00108 } pcl_mainclk_t;
00109
00111
00112 #ifndef AVR32_PM_VERSION_RESETVALUE
00113
00114 #define pcl_freq_param_t pm_freq_param_t // See pm.h
00115 #else
00116
00117 typedef struct
00118 {
00120 pcl_mainclk_t main_clk_src;
00121
00123 unsigned long cpu_f;
00124
00126 unsigned long pba_f;
00127
00129 unsigned long pbb_f;
00130
00132 unsigned long pbc_f;
00133
00135 unsigned long osc0_f;
00136
00138 unsigned long osc0_startup;
00139
00141 unsigned long dfll_f;
00142
00144
00145
00146 void *pextra_params;
00147 } pcl_freq_param_t;
00148 #endif
00149
00151 #define PCL_NOT_SUPPORTED (-10000)
00152
00175 extern long int pcl_configure_clocks(pcl_freq_param_t *param);
00176
00201 extern long int pcl_configure_clocks_rcsys(pcl_freq_param_t *param);
00202
00227 extern long int pcl_configure_clocks_rc120m(pcl_freq_param_t *param);
00228
00256 extern long int pcl_configure_clocks_osc0(pcl_freq_param_t *param);
00257
00289 extern long int pcl_configure_clocks_dfll0(pcl_freq_param_t *param);
00290
00301 extern long int pcl_switch_to_osc(pcl_osc_t osc, unsigned int fcrystal, unsigned int startup);
00302
00314 #ifndef AVR32_PM_VERSION_RESETVALUE
00315
00316 #define pcl_enable_module(module) pm_enable_module(&AVR32_PM, module)
00317 #else
00318
00319 #define pcl_enable_module(module) pm_enable_module(module)
00320 #endif
00321
00333 #ifndef AVR32_PM_VERSION_RESETVALUE
00334
00335 #define pcl_disable_module(module) pm_disable_module(&AVR32_PM, module)
00336 #else
00337
00338 #define pcl_disable_module(module) pm_disable_module(module)
00339 #endif
00340
00348 extern long int pcl_configure_usb_clock(void);
00349
00351
00354
00355
00361 extern unsigned long pcl_read_gplp(unsigned long gplp);
00362
00363
00369 extern void pcl_write_gplp(unsigned long gplp, unsigned long value);
00370
00372
00373 #ifdef __cplusplus
00374 }
00375 #endif
00376
00377 #endif // _POWER_CLOCKS_LIB_H_