- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# pm.h

Go to the documentation of this file.

    00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
    00016 /* Copyright (c) 2009 Atmel Corporation. All rights reserved.
    00017  *
    00018  * Redistribution and use in source and binary forms, with or without
    00019  * modification, are permitted provided that the following conditions are met:
    00020  *
    00021  * 1. Redistributions of source code must retain the above copyright notice, this
    00022  * list of conditions and the following disclaimer.
    00023  *
    00024  * 2. Redistributions in binary form must reproduce the above copyright notice,
    00025  * this list of conditions and the following disclaimer in the documentation
    00026  * and/or other materials provided with the distribution.
    00027  *
    00028  * 3. The name of Atmel may not be used to endorse or promote products derived
    00029  * from this software without specific prior written permission.
    00030  *
    00031  * 4. This software may only be redistributed and used in connection with an Atmel
    00032  * AVR product.
    00033  *
    00034  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
    00035  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00036  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
    00037  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
    00038  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    00039  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    00040  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00041  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00042  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    00043  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
    00044  *
    00045  */
    00046
    00047 #ifndef _PM_H_
    00048 #define _PM_H_
    00049
    00050 #include <avr32/io.h>
    00051 #include "compiler.h"
    00052 #include "preprocessor.h"
    00053
    00054
    00065 #define SLEEP(mode)   {__asm__ __volatile__ ("sleep "STRINGZ(mode));}
    00066
    00067
    00069 typedef struct
    00070 {
    00072   unsigned long cpu_f;
    00073
    00075   unsigned long pba_f;
    00076
    00078   unsigned long osc0_f;
    00079
    00081   unsigned long osc0_startup;
    00082 } pm_freq_param_t;
    00083
    00084 #define PM_FREQ_STATUS_FAIL   (-1)
    00085 #define PM_FREQ_STATUS_OK     (0)
    00086
    00087
    00095 #if (defined __GNUC__)
    00096 __attribute__((__always_inline__))
    00097 #endif
    00098 extern __inline__ unsigned int pm_get_reset_cause(volatile avr32_pm_t *pm)
    00099 {
    00100   return pm->rcause;
    00101 }
    00102
    00103
    00108 extern void pm_enable_osc0_ext_clock(volatile avr32_pm_t *pm);
    00109
    00110
    00116 extern void pm_enable_osc0_crystal(volatile avr32_pm_t *pm, unsigned int fosc0);
    00117
    00118
    00124 extern void pm_enable_clk0(volatile avr32_pm_t *pm, unsigned int startup);
    00125
    00126
    00131 extern void pm_disable_clk0(volatile avr32_pm_t *pm);
    00132
    00133
    00139 extern void pm_enable_clk0_no_wait(volatile avr32_pm_t *pm, unsigned int startup);
    00140
    00141
    00146 extern void pm_wait_for_clk0_ready(volatile avr32_pm_t *pm);
    00147
    00148
    00153 extern void pm_enable_osc1_ext_clock(volatile avr32_pm_t *pm);
    00154
    00155
    00161 extern void pm_enable_osc1_crystal(volatile avr32_pm_t *pm, unsigned int fosc1);
    00162
    00163
    00169 extern void pm_enable_clk1(volatile avr32_pm_t *pm, unsigned int startup);
    00170
    00171
    00176 extern void pm_disable_clk1(volatile avr32_pm_t *pm);
    00177
    00178
    00184 extern void pm_enable_clk1_no_wait(volatile avr32_pm_t *pm, unsigned int startup);
    00185
    00186
    00191 extern void pm_wait_for_clk1_ready(volatile avr32_pm_t *pm);
    00192
    00193
    00198 extern void pm_enable_osc32_ext_clock(volatile avr32_pm_t *pm);
    00199
    00200
    00205 extern void pm_enable_osc32_crystal(volatile avr32_pm_t *pm);
    00206
    00207
    00213 extern void pm_enable_clk32(volatile avr32_pm_t *pm, unsigned int startup);
    00214
    00215
    00220 extern void pm_disable_clk32(volatile avr32_pm_t *pm);
    00221
    00222
    00228 extern void pm_enable_clk32_no_wait(volatile avr32_pm_t *pm, unsigned int startup);
    00229
    00230
    00235 extern void pm_wait_for_clk32_ready(volatile avr32_pm_t *pm);
    00236
    00237
    00248 extern void pm_cksel(volatile avr32_pm_t *pm, unsigned int pbadiv, unsigned int pbasel, unsigned int pbbdiv, unsigned int pbbsel, unsigned int hsbdiv, unsigned int hsbsel);
    00249
    00250
    00260 extern void pm_gc_setup(volatile avr32_pm_t *pm, unsigned int gc, unsigned int osc_or_pll, unsigned int pll_osc, unsigned int diven, unsigned int div);
    00261
    00262
    00268 extern void pm_gc_enable(volatile avr32_pm_t *pm, unsigned int gc);
    00269
    00270
    00276 extern void pm_gc_disable(volatile avr32_pm_t *pm, unsigned int gc);
    00277
    00278
    00288 extern void pm_pll_setup(volatile avr32_pm_t *pm, unsigned int pll, unsigned int mul, unsigned int div, unsigned int osc, unsigned int lockcount);
    00289
    00290
    00299 extern void pm_pll_set_option(volatile avr32_pm_t *pm, unsigned int pll, unsigned int  pll_freq, unsigned int  pll_div2, unsigned int  pll_wbwdisable);
    00300
    00301
    00308 extern unsigned int pm_pll_get_option(volatile avr32_pm_t *pm, unsigned int pll);
    00309
    00310
    00316 extern void pm_pll_enable(volatile avr32_pm_t *pm, unsigned int pll);
    00317
    00318
    00324 extern void pm_pll_disable(volatile avr32_pm_t *pm, unsigned int pll);
    00325
    00326
    00331 extern void pm_wait_for_pll0_locked(volatile avr32_pm_t *pm);
    00332
    00333
    00338 extern void pm_wait_for_pll1_locked(volatile avr32_pm_t *pm);
    00339
    00340
    00346 extern void pm_switch_to_clock(volatile avr32_pm_t *pm, unsigned long clock);
    00347
    00348
    00355 extern void pm_switch_to_osc0(volatile avr32_pm_t *pm, unsigned int fosc0, unsigned int startup);
    00356
    00357
    00362 extern void pm_bod_enable_irq(volatile avr32_pm_t *pm);
    00363
    00364
    00369 extern void pm_bod_disable_irq(volatile avr32_pm_t *pm);
    00370
    00371
    00376 extern void pm_bod_clear_irq(volatile avr32_pm_t *pm);
    00377
    00378
    00386 extern unsigned long pm_bod_get_irq_status(volatile avr32_pm_t *pm);
    00387
    00388
    00396 extern unsigned long pm_bod_get_irq_enable_bit(volatile avr32_pm_t *pm);
    00397
    00398
    00406 extern unsigned long pm_bod_get_level(volatile avr32_pm_t *pm);
    00407
    00408
    00416 extern unsigned long pm_read_gplp(volatile avr32_pm_t *pm, unsigned long gplp);
    00417
    00418
    00425 extern void pm_write_gplp(volatile avr32_pm_t *pm, unsigned long gplp, unsigned long value);
    00426
    00427
    00439 extern long pm_enable_module(volatile avr32_pm_t *pm, unsigned long module);
    00440
    00452 extern long pm_disable_module(volatile avr32_pm_t *pm, unsigned long module);
    00453
    00454
    00455
    00480 extern int pm_configure_clocks(pm_freq_param_t *param);
    00481
    00482
    00488 extern void pm_configure_usb_clock(void);
    00489
    00490
    00491 #endif  // _PM_H_