eic_example1.c File Reference


Detailed Description

External Interrupt Controller Example 1.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file eic_example1.c.

#include <avr32/io.h>
#include "compiler.h"
#include "gpio.h"
#include "power_clocks_lib.h"
#include "board.h"
#include "eic.h"

Go to the source code of this file.

Defines

External Interrupt pin Mappings
#define EXT_INT_EXAMPLE_FUNCTION_LINE   AVR32_EIC_EXTINT_6_FUNCTION
#define EXT_INT_EXAMPLE_LINE   EXT_INT6
#define EXT_INT_EXAMPLE_PIN_LINE   AVR32_EIC_EXTINT_6_PIN

Functions

int main (void)
static void ToggleLed0Delay (void)


Define Documentation

#define EXT_INT_EXAMPLE_FUNCTION_LINE   AVR32_EIC_EXTINT_6_FUNCTION

Definition at line 123 of file eic_example1.c.

Referenced by main().

#define EXT_INT_EXAMPLE_LINE   EXT_INT6

Definition at line 124 of file eic_example1.c.

Referenced by main().

#define EXT_INT_EXAMPLE_PIN_LINE   AVR32_EIC_EXTINT_6_PIN

Definition at line 122 of file eic_example1.c.

Referenced by main().


Function Documentation

int main ( void   ) 

Definition at line 170 of file eic_example1.c.

References eic_options_t::eic_async, EIC_ASYNCH_MODE, eic_clear_interrupt_line(), eic_enable_line(), eic_options_t::eic_filter, EIC_FILTER_ENABLED, eic_init(), eic_options_t::eic_level, EIC_LEVEL_LOW_LEVEL, eic_options_t::eic_line, eic_options_t::eic_mode, EIC_MODE_LEVEL_TRIGGERED, EXT_INT_EXAMPLE_FUNCTION_LINE, EXT_INT_EXAMPLE_LINE, EXT_INT_EXAMPLE_PIN_LINE, and ToggleLed0Delay().

00171 {
00172   eic_options_t eic_options;  // Structure holding the configuration parameters
00173                               // of the EIC module.
00174 
00175   // Enable LED0_GPIO on the EVK
00176   gpio_enable_gpio_pin(LED0_GPIO);
00177 
00178   // Enable level-triggered interrupt.
00179   eic_options.eic_mode   = EIC_MODE_LEVEL_TRIGGERED;
00180   // Interrupt will trigger on low-level.
00181   eic_options.eic_level  = EIC_LEVEL_LOW_LEVEL;
00182   // Enable filter.
00183   eic_options.eic_filter  = EIC_FILTER_ENABLED;
00184   // For Wake Up mode, initialize in asynchronous mode
00185   eic_options.eic_async  = EIC_ASYNCH_MODE;
00186   // Choose External Interrupt Controller Line
00187   eic_options.eic_line = EXT_INT_EXAMPLE_LINE; // Enable the chosen external interrupt line.
00188 
00189   // Map the interrupt line to the GPIO pin with the right peripheral function.
00190   gpio_enable_module_pin(EXT_INT_EXAMPLE_PIN_LINE,EXT_INT_EXAMPLE_FUNCTION_LINE);
00191 
00192   // Init the EIC controller with the options
00193   eic_init(&AVR32_EIC, &eic_options,1);
00194   // Enable External Interrupt Controller Line
00195   eic_enable_line(&AVR32_EIC, EXT_INT_EXAMPLE_LINE);
00196 
00197   // Switch the CPU to static sleep mode.
00198   // When the CPU is idle, it is possible to switch off the CPU clock and optionally other
00199   // clock domains to save power. This is activated by the sleep instruction, which takes the sleep
00200   // mode index number as argument. SLEEP function is defined in \DRIVERS\PM\pm.h.
00201   // In static mode, all oscillators, including 32KHz and RC oscillator are stopped.
00202   // Bandgap voltage reference BOD detector is turned off.
00203   SLEEP(AVR32_PM_SMODE_STATIC);
00204 
00205   // Activate LED0 pin in GPIO output mode and switch LED0 off.
00206   gpio_set_gpio_pin(LED0_GPIO);
00207 
00208   // Cpu now is in static sleep mode. When the wake-up external interrupt occurs,
00209   // the CPU resumes execution here and enter the while(1) loop.
00210   while(1)
00211   {
00212     ToggleLed0Delay();  // Toggle LED0 for a short while
00213     // Interrupt Line must be cleared to enable next SLEEP action
00214     eic_clear_interrupt_line(&AVR32_EIC, EXT_INT_EXAMPLE_LINE);
00215 
00216     SLEEP(AVR32_PM_SMODE_STATIC); // re-enter sleep mode.
00217     // Cpu now is in static sleep mode. When the wake-up external interrupt occurs,
00218     // the CPU resumes execution back from the top of the while loop.
00219   }
00220 }

static void ToggleLed0Delay ( void   )  [static]

Definition at line 154 of file eic_example1.c.

Referenced by main().

00155 {
00156   volatile int i;
00157   volatile int j = 30;
00158   do{
00159     j--;
00160     i=1000;
00161     while(i--);
00162     gpio_tgl_gpio_pin(LED0_GPIO); // Toggle the LED0.
00163   }while(j);
00164 }


Generated on Fri Feb 19 02:24:36 2010 for AVR32 UC3 - EIC Driver Example 1 by  doxygen 1.5.5