Definition in file clock_masking_example.c.
#include <avr32/io.h>
#include "board.h"
#include "pm.h"
#include "gpio.h"
Go to the source code of this file.
Defines | |
| #define | CLOCK_DIV_OFF 0 |
| #define | CLOCK_DIV_ON 1 |
| #define | DIV_FOURTH 1 |
| #define | DIV_HALF 0 |
Functions | |
| int | main (void) |
| main function : Disable/enable module clocks according to pressed button | |
| #define CLOCK_DIV_OFF 0 |
| #define CLOCK_DIV_ON 1 |
The LED signal following situations: LED0 = PBB clocks are active LED1 = All modules on PBA are clocked
Definition at line 88 of file clock_masking_example.c.
Referenced by main().
| #define DIV_FOURTH 1 |
| #define DIV_HALF 0 |
| int main | ( | void | ) |
main function : Disable/enable module clocks according to pressed button
Definition at line 96 of file clock_masking_example.c.
References FOSC0, gpio_clr_gpio_pin(), gpio_get_pin_value(), GPIO_PUSH_BUTTON_0, GPIO_PUSH_BUTTON_1, GPIO_PUSH_BUTTON_2, gpio_set_gpio_pin(), LED0_GPIO, LED1_GPIO, OSC0_STARTUP, and pm_switch_to_osc0().
00096 { 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