00001 /*This file is prepared for Doxygen automatic documentation generation.*/ 00015 /* Copyright (c) 2007, Atmel Corporation All rights reserved. 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions are met: 00019 * 00020 * 1. Redistributions of source code must retain the above copyright notice, 00021 * this list of conditions and the following disclaimer. 00022 * 00023 * 2. Redistributions in binary form must reproduce the above copyright notice, 00024 * this list of conditions and the following disclaimer in the documentation 00025 * and/or other materials provided with the distribution. 00026 * 00027 * 3. The name of ATMEL may not be used to endorse or promote products derived 00028 * from this software without specific prior written permission. 00029 * 00030 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED 00031 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00032 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND 00033 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, 00034 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00035 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00036 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00037 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00038 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00039 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00040 */ 00041 00083 #include <avr32/io.h> 00084 #include "board.h" 00085 #include "pm.h" 00086 #include "gpio.h" 00087 00088 #define CLOCK_DIV_ON 1 00089 #define CLOCK_DIV_OFF 0 00090 #define DIV_HALF 0 00091 #define DIV_FOURTH 1 00092 00096 int main(void) { 00097 volatile avr32_pm_t *pm = &AVR32_PM; 00098 00099 // set synchronous clock source to external oscillator 0 00100 pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP); 00101 00102 gpio_clr_gpio_pin(LED0_GPIO); 00103 gpio_clr_gpio_pin(LED1_GPIO); 00104 00105 while(1){ 00106 00107 if(gpio_get_pin_value(GPIO_PUSH_BUTTON_0) == 0) { 00108 // enable all module clocks on the different clock domains 00109 pm->cpumask = 0xFFFFFFFF; 00110 pm->hsbmask = 0xFFFFFFFF; 00111 pm->pbamask = 0xFFFFFFFF; 00112 pm->pbbmask = 0xFFFFFFFF; 00113 00114 // Wait for ckrdy bit. Actually not needed here because no write or 00115 // read action is performed to any module which clock was disabled 00116 // before. 00117 while (!(pm->poscsr & AVR32_PM_POSCSR_CKRDY_MASK)); 00118 00119 gpio_clr_gpio_pin(LED0_GPIO); 00120 gpio_clr_gpio_pin(LED1_GPIO); 00121 } 00122 if(gpio_get_pin_value(GPIO_PUSH_BUTTON_1) == 0){ 00123 // turn off all modules on PBB 00124 pm->pbbmask = 0x0; 00125 gpio_set_gpio_pin(LED0_GPIO); 00126 } 00127 if(gpio_get_pin_value(GPIO_PUSH_BUTTON_2) == 0){ 00128 // turn off all modules on PBA exept PM/RTC/EIC and GPIO 00129 // because we need them to enable the modules again (PM) and to signal 00130 // the state withe LEDs 00131 pm->pbamask = 0x0000000A; 00132 gpio_set_gpio_pin(LED1_GPIO); 00133 } 00134 00135 } 00136 return 0; 00137 }
1.5.3-20071008