- Main Page
- Related Pages
- Data Structures
- Files

# pm_at32ap7000.h

Go to the documentation of this file.

    00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
    00016 /* Copyright (C) 2006-2008, 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,
    00022  * this 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  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
    00032  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00033  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
    00034  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
    00035  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    00036  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    00037  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    00038  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00039  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    00040  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00041  */
    00042
    00043 #ifndef _pm_h_
    00044 #define _pm_h_
    00045
    00046 #include "compiler.h"
    00047 #include <avr32/io.h>
    00048 #include "board.h"
    00049 #include "ap7_errno.h"
    00050
    00051 /* The timeguard used for polling in ticks */
    00052 #define PM_TIMEOUT 100000
    00053
    00054 /* Define "not supported" for the power manager features */
    00055 #define PM_NOT_SUPPORTED (-10000)
    00056
    00057 /* For PLLs that doesn't lock */
    00058 #define PM_LOCK_ERROR (-10001)
    00059
    00060 /* osc opt defs */
    00061 #define PM_OSC_OPT_CRYSTAL  1
    00062 #define PM_OSC_OPT_CLOCK    2
    00063
    00064 #if defined(__AVR32_AP7000__)|| defined(__AT32AP7000__)
    00065
    00066 /* CPUMASK */
    00067 #define PM_CPU_DOMAIN 0
    00068 #define PM_CPU_DOMAIN_SIZE 1
    00069 #define PM_CPU_PICO 0
    00070
    00071 /* HSB */
    00072 #define PM_HSB_DOMAIN 1
    00073 #define PM_HSB_DOMAIN_SIZE 11
    00074 #define PM_HSB_HEBI 32
    00075 #define PM_HSB_PBA 33
    00076 #define PM_HSB_PBB 34
    00077 #define PM_HSB_HRAMC 35
    00078 #define PM_HSB_HSBBRIDGE 36
    00079 #define PM_HSB_HISI 37
    00080 #define PM_HSB_USB 38
    00081 #define PM_HSB_LCDC 39
    00082 #define PM_HSB_MACB0 40
    00083 #define PM_HSB_MACB1 41
    00084 #define PM_HSB_DMAC 42
    00085
    00086 /* PBA */
    00087 #define PM_PBA_DOMAIN 2
    00088 #define PM_PBA_DOMAIN_SIZE 17
    00089 #define PM_PBA_SPI0 64
    00090 #define PM_PBA_SPI1 65
    00091 #define PM_PBA_TWI 66
    00092 #define PM_PBA_USART0 67
    00093 #define PM_PBA_USART1 68
    00094 #define PM_PBA_USART2 69
    00095 #define PM_PBA_USART3 70
    00096 #define PM_PBA_SSC0 71
    00097 #define PM_PBA_SSC1 72
    00098 #define PM_PBA_SSC2 73
    00099 #define PM_PBA_PIOA 74
    00100 #define PM_PBA_PIOB 75
    00101 #define PM_PBA_PIOC 76
    00102 #define PM_PBA_PIOD 77
    00103 #define PM_PBA_PIOE 78
    00104 #define PM_PBA_PIOF 80
    00105 #define PM_PBA_HPDC 81
    00106
    00107 /* PBB */
    00108 #define PM_PBB_DOMAIN 3
    00109 #define PM_PBB_DOMAIN_SIZE 15
    00110 #define PM_PBB_SM 96
    00111 #define PM_PBB_INTC 97
    00112 #define PM_PBB_HMATRIX 98
    00113 #define PM_PBB_TIMER0 99
    00114 #define PM_PBB_TIMER1 100
    00115 #define PM_PBB_PWM 101
    00116 #define PM_PBB_MACB0 102
    00117 #define PM_PBB_MACB1 103
    00118 #define PM_PBB_DAC 104
    00119 #define PM_PBB_MMCI 105
    00120 #define PM_PBB_AUDIOC 106
    00121 #define PM_PBB_HISI 107
    00122 #define PM_PBB_USB 108
    00123 #define PM_PBB_HSMC 109
    00124 #define PM_PBB_HSDRAMC 110
    00125 #define PM_PBB_HECC 111
    00126
    00127 #endif // #if defined(__AVR32_AP7000__)|| defined(__AT32AP7000__)
    00128
    00132 enum pm_clock_source_e {
    00133   PM_OSC0=0,
    00134   PM_OSC1=1,
    00135   PM_OSC32=2,
    00136   PM_PLL0=3,
    00137   PM_PLL1=4
    00138 };
    00139
    00140
    00144 typedef struct {
    00146   unsigned char divider;
    00148   int clock_source;
    00149 } pm_gen_clk_opt_t;
    00150
    00151
    00155 typedef struct {
    00157   unsigned char osc_id;
    00159   unsigned char startup;
    00161   unsigned char mode;
    00162 } pm_osc_opt_t;
    00163
    00164
    00169 typedef struct {
    00171   unsigned char pll_id;
    00173   unsigned char osc_id;
    00175   unsigned char mul;
    00177   unsigned char div;
    00179   unsigned char count;
    00181   unsigned char options;
    00183   Bool wait_for_lock;
    00184 } pm_pll_opt_t;
    00185
    00186
    00190 enum pm_calibration_src_e {
    00191   PM_RC_OSCILLATOR,
    00192   PM_BOD_CONTROL,
    00193   PM_BANDGAP_CALIBRATION,
    00194   PM_VOLTAGE
    00195 };
    00196
    00197
    00204 int pm_reset(void);
    00205
    00206
    00213 unsigned int pm_get_reset_cause(void);
    00214
    00215
    00224 int pm_start_osc(const pm_osc_opt_t *opt);
    00225
    00226
    00235 int pm_stop_osc(int osc_id);
    00236
    00237
    00246 int pm_start_pll(pm_pll_opt_t *opt);
    00247
    00248
    00259 int pm_start_pll_freq(int pll_id, unsigned int freq, Bool wait_for_lock);
    00260
    00261
    00270 int pm_stop_pll(int pll_id);
    00271
    00272
    00281 int pm_get_clock_source_freq_hz(int clock_source);
    00282
    00283
    00292 int pm_wait_for_clock_source_lock(int clock_source);
    00293
    00294
    00303 int pm_wait_for_status(unsigned int status);
    00304
    00305
    00314 int pm_enable_interrupt(unsigned int mask);
    00315
    00316
    00325 int pm_disable_interrupt(unsigned int mask);
    00326
    00327
    00333 unsigned int pm_get_enabled_interrupts(void);
    00334
    00335
    00341 unsigned int pm_get_interrupt_status(void);
    00342
    00343
    00352 int pm_clear_interrupt_status(unsigned int mask);
    00353
    00354
    00364 int pm_calibrate(int source, unsigned int calibration_value);
    00365
    00366
    00377 int pm_set_bod_settings(unsigned int bod_control, Bool hysteresis, unsigned char level);
    00378
    00379
    00386 int pm_get_bod_settings(unsigned int bod_control, Bool hysteresis, unsigned char level);
    00387
    00388
    00397 int pm_set_mclk_source(int clock_source);
    00398
    00399
    00405 int pm_get_mclk_source(void);
    00406
    00407
    00413 int pm_get_mclk_freq_hz(void);
    00414
    00415
    00424 int pm_read_clock_domain_scaler(unsigned int clock_domain);
    00425
    00426
    00436 int pm_set_clock_domain_scaler(unsigned int clock_domain, int divider);
    00437
    00438
    00447 int pm_read_module_freq_hz(unsigned int module);
    00448
    00449
    00458 int pm_enable_module(unsigned int module);
    00459
    00460
    00469 int pm_disable_module(unsigned int module);
    00470
    00471
    00481 int pm_start_generic_clock(unsigned int clock, const pm_gen_clk_opt_t *opt);
    00482
    00483
    00492 int pm_stop_generic_clock(unsigned int clock);
    00493
    00494 #endif /* _pm_h_ */
    00495