- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# power_clocks_lib.h

Go to the documentation of this file.

    00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
    00018 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
    00019  *
    00020  * Redistribution and use in source and binary forms, with or without
    00021  * modification, are permitted provided that the following conditions are met:
    00022  *
    00023  * 1. Redistributions of source code must retain the above copyright notice, this
    00024  * list of conditions and the following disclaimer.
    00025  *
    00026  * 2. Redistributions in binary form must reproduce the above copyright notice,
    00027  * this list of conditions and the following disclaimer in the documentation
    00028  * and/or other materials provided with the distribution.
    00029  *
    00030  * 3. The name of Atmel may not be used to endorse or promote products derived
    00031  * from this software without specific prior written permission.
    00032  *
    00033  * 4. This software may only be redistributed and used in connection with an Atmel
    00034  * AVR product.
    00035  *
    00036  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
    00037  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00038  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
    00039  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
    00040  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    00041  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    00042  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00043  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00044  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    00045  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
    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 // Support for UC3A, UC3A3, UC3B parts.
    00061   #include "pm.h"
    00062 #else
    00064 #if (( defined (__GNUC__) && ( defined (__AVR32_UC3L016__) || defined (__AVR32_UC3L032__) || defined (__AVR32_UC3L064__))) \
    00065     ||(defined (__ICCAVR32__) && (defined (__AT32UC3L016__) || defined (__AT32UC3L032__) || defined (__AT32UC3L064__)  )))
    00066   #include "pm_uc3l.h"
    00067   #include "scif_uc3l.h"
    00068   #include "flashcdw.h"
    00069 #elif ( defined (__GNUC__) && ( defined (__AVR32_UC3C064C__) || defined (__AVR32_UC3C0128C__) || defined (__AVR32_UC3C0256C__) || defined (__AVR32_UC3C0512C__) || defined (__AVR32_UC3C164C__) || defined (__AVR32_UC3C1128C__) || defined (__AVR32_UC3C1256C__) || defined (__AVR32_UC3C1512C__) || defined (__AVR32_UC3C264C__) || defined (__AVR32_UC3C2128C__) || defined (__AVR32_UC3C2256C__) || defined (__AVR32_UC3C2512C__))) \
    00070   ||( defined (__ICCAVR32__) && ( defined (__AT32UC3C064C__) || defined (__AT32UC3C0128C__) || defined (__AT32UC3C0256C__) || defined (__AT32UC3C0512C__) || defined (__AT32UC3C164C__) || defined (__AT32UC3C1128C__) || defined (__AT32UC3C1256C__) || defined (__AT32UC3C1512C__) || defined (__AT32UC3C264C__) || defined (__AT32UC3C2128C__) || defined (__AT32UC3C2256C__) || defined (__AT32UC3C2512C__)))
    00071   #include "pm_uc3c.h"
    00072   #include "scif_uc3c.h"
    00073   #include "flashc.h"
    00074 #endif
    00075 #endif
    00076
    00077
    00079 typedef enum
    00080 {
    00081   PCL_OSC0  = 0,
    00082   PCL_OSC1  = 1
    00083 } pcl_osc_t;
    00084
    00086 typedef enum
    00087 {
    00088   PCL_DFLL0  = 0,
    00089   PCL_DFLL1  = 1
    00090 } pcl_dfll_t;
    00091
    00093 typedef enum
    00094 {
    00095   PCL_MC_RCSYS,      // Default main clock source, supported by all (aka Slow Clock)
    00096   PCL_MC_OSC0,       // Supported by all
    00097   PCL_MC_OSC1,       // Supported by UC3C only
    00098   PCL_MC_OSC0_PLL0,  // Supported by UC3A, UC3B, UC3A3, UC3C (the main clock source is PLL0 with OSC0 as reference)
    00099   PCL_MC_OSC1_PLL0,  // Supported by UC3A, UC3B, UC3A3, UC3C (the main clock source is PLL0 with OSC1 as reference)
    00100   PCL_MC_OSC0_PLL1,  // Supported by UC3C  (the main clock source is PLL1 with OSC0 as reference)
    00101   PCL_MC_OSC1_PLL1,  // Supported by UC3C  (the main clock source is PLL1 with OSC1 as reference)
    00102   PCL_MC_DFLL0,      // Supported by UC3L
    00103   PCL_MC_DFLL1,      // Not supported yet
    00104   PCL_MC_RC120M,     // Supported by UC3L, UC3C
    00105   PCL_MC_RC8M,       // Supported by UC3C
    00106   PCL_MC_CRIPOSC     // Supported by UC3C
    00107 } pcl_mainclk_t;
    00108
    00110 // NOTE: regarding the frequency settings, always abide by the datasheet rules and min & max supported frequencies.
    00111 #ifndef AVR32_PM_VERSION_RESETVALUE
    00112 // Support for UC3A, UC3A3, UC3B parts.
    00113 #define pcl_freq_param_t  pm_freq_param_t // See pm.h
    00114 #else
    00115 // Support for UC3C, UC3L parts.
    00116 typedef struct
    00117 {
    00119   pcl_mainclk_t main_clk_src;
    00120
    00122   unsigned long cpu_f;
    00123
    00125   unsigned long pba_f;
    00126
    00128   unsigned long pbb_f;
    00129
    00131   unsigned long pbc_f;
    00132
    00134   unsigned long osc0_f;
    00135
    00137   unsigned long osc0_startup;
    00138
    00140   unsigned long dfll_f;
    00141 } pcl_freq_param_t;
    00142 #endif
    00143
    00145 #define PCL_NOT_SUPPORTED (-10000)
    00146
    00147
    00170 extern long int pcl_configure_clocks(pcl_freq_param_t *param);
    00171
    00196 extern long int pcl_configure_clocks_rcsys(pcl_freq_param_t *param);
    00197
    00222 extern long int pcl_configure_clocks_rc120m(pcl_freq_param_t *param);
    00223
    00251 extern long int pcl_configure_clocks_osc0(pcl_freq_param_t *param);
    00252
    00284 extern long int pcl_configure_clocks_dfll0(pcl_freq_param_t *param);
    00285
    00296 extern long int pcl_switch_to_osc(pcl_osc_t osc, unsigned int fcrystal, unsigned int startup);
    00297
    00309 #ifndef AVR32_PM_VERSION_RESETVALUE
    00310 // Implementation for UC3A, UC3A3, UC3B parts.
    00311 #define pcl_enable_module(module) pm_enable_module(&AVR32_PM, module)
    00312 #else
    00313 // Implementation for UC3C, UC3L parts.
    00314 #define pcl_enable_module(module) pm_enable_module(module)
    00315 #endif
    00316
    00328 #ifndef AVR32_PM_VERSION_RESETVALUE
    00329 // Implementation for UC3A, UC3A3, UC3B parts.
    00330 #define pcl_disable_module(module)  pm_disable_module(&AVR32_PM, module)
    00331 #else
    00332 // Implementation for UC3C, UC3L parts.
    00333 #define pcl_disable_module(module)  pm_disable_module(module)
    00334 #endif
    00335
    00344 extern long int pcl_configure_usb_clock(void);
    00345
    00346 #ifdef __cplusplus
    00347 }
    00348 #endif
    00349
    00350 #endif  // _POWER_CLOCKS_LIB_H_