Definition in file eic_example2.c.
#include <avr32/io.h>
#include "compiler.h"
#include "gpio.h"
#include "pm.h"
#include "board.h"
#include "eic.h"
#include "intc.h"
Go to the source code of this file.
Defines | |
External Interrupt pin Mappings | |
#define | EXT_INT_EXAMPLE_FUNCTION_LINE1 AVR32_EIC_EXTINT_6_FUNCTION |
#define | EXT_INT_EXAMPLE_FUNCTION_LINE2 AVR32_EIC_EXTINT_7_FUNCTION |
#define | EXT_INT_EXAMPLE_IRQ_LINE1 AVR32_EIC_IRQ_6 |
#define | EXT_INT_EXAMPLE_IRQ_LINE2 AVR32_EIC_IRQ_7 |
#define | EXT_INT_EXAMPLE_LINE1 EXT_INT6 |
#define | EXT_INT_EXAMPLE_LINE2 EXT_INT7 |
#define | EXT_INT_EXAMPLE_NB_LINES 2 |
#define | EXT_INT_EXAMPLE_PIN_LINE1 AVR32_EIC_EXTINT_6_PIN |
#define | EXT_INT_EXAMPLE_PIN_LINE2 AVR32_EIC_EXTINT_7_PIN |
Functions | |
static void | eic_int_handler1 (void) |
Interrupt handler of the External interrupt line "1". | |
static void | eic_int_handler2 (void) |
Interrupt handler of the External interrupt line "2". | |
int | main (void) |
static void | software_delay (void) |
Variables | |
static volatile Bool | bCancelSwDelay = FALSE |
Global var used to cancel the software delay if an External Interrupt occurs. | |
eic_options_t | eic_options [EXT_INT_EXAMPLE_NB_LINES] |
Structure holding the configuration parameters of the EIC module. | |
unsigned char | key_number = 0 |
Global var used to switch between different LED patterns. |
#define EXT_INT_EXAMPLE_FUNCTION_LINE1 AVR32_EIC_EXTINT_6_FUNCTION |
#define EXT_INT_EXAMPLE_FUNCTION_LINE2 AVR32_EIC_EXTINT_7_FUNCTION |
#define EXT_INT_EXAMPLE_IRQ_LINE1 AVR32_EIC_IRQ_6 |
#define EXT_INT_EXAMPLE_IRQ_LINE2 AVR32_EIC_IRQ_7 |
#define EXT_INT_EXAMPLE_LINE1 EXT_INT6 |
#define EXT_INT_EXAMPLE_LINE2 EXT_INT7 |
#define EXT_INT_EXAMPLE_NB_LINES 2 |
#define EXT_INT_EXAMPLE_PIN_LINE1 AVR32_EIC_EXTINT_6_PIN |
#define EXT_INT_EXAMPLE_PIN_LINE2 AVR32_EIC_EXTINT_7_PIN |
static void eic_int_handler1 | ( | void | ) | [static] |
Interrupt handler of the External interrupt line "1".
Definition at line 180 of file eic_example2.c.
References bCancelSwDelay, eic_clear_interrupt_line(), EXT_INT_EXAMPLE_LINE1, and key_number.
Referenced by main().
00181 { 00182 eic_clear_interrupt_line(&AVR32_EIC, EXT_INT_EXAMPLE_LINE1); 00183 key_number = 1; 00184 bCancelSwDelay = TRUE; 00185 }
static void eic_int_handler2 | ( | void | ) | [static] |
Interrupt handler of the External interrupt line "2".
Definition at line 195 of file eic_example2.c.
References bCancelSwDelay, eic_clear_interrupt_line(), EXT_INT_EXAMPLE_LINE2, and key_number.
Referenced by main().
00196 { 00197 eic_clear_interrupt_line(&AVR32_EIC, EXT_INT_EXAMPLE_LINE2); 00198 key_number = 2; 00199 bCancelSwDelay = TRUE; 00200 }
int main | ( | void | ) |
Definition at line 217 of file eic_example2.c.
References eic_options_t::eic_async, eic_options_t::eic_edge, EIC_EDGE_FALLING_EDGE, eic_enable_interrupt_line(), eic_enable_interrupt_lines(), eic_enable_line(), eic_enable_lines(), eic_init(), eic_int_handler1(), eic_int_handler2(), eic_options_t::eic_line, eic_options_t::eic_mode, EIC_MODE_EDGE_TRIGGERED, EIC_SYNCH_MODE, EXT_INT_EXAMPLE_FUNCTION_LINE1, EXT_INT_EXAMPLE_FUNCTION_LINE2, EXT_INT_EXAMPLE_IRQ_LINE1, EXT_INT_EXAMPLE_IRQ_LINE2, EXT_INT_EXAMPLE_LINE1, EXT_INT_EXAMPLE_LINE2, EXT_INT_EXAMPLE_NB_LINES, EXT_INT_EXAMPLE_PIN_LINE1, EXT_INT_EXAMPLE_PIN_LINE2, key_number, and software_delay().
00218 { 00219 // Enable edge-triggered interrupt. 00220 eic_options[0].eic_mode = EIC_MODE_EDGE_TRIGGERED; 00221 // Interrupt will trigger on falling edge. 00222 eic_options[0].eic_edge = EIC_EDGE_FALLING_EDGE; 00223 // Initialize in synchronous mode : interrupt is synchronized to the clock 00224 eic_options[0].eic_async = EIC_SYNCH_MODE; 00225 // Set the interrupt line number. 00226 eic_options[0].eic_line = EXT_INT_EXAMPLE_LINE1; 00227 00228 // Only available for EVK1101 00229 #if BOARD==EVK1101 00230 // Enable edge-triggered interrupt. 00231 eic_options[1].eic_mode = EIC_MODE_EDGE_TRIGGERED; 00232 // Interrupt will trigger on falling edge. 00233 eic_options[1].eic_edge = EIC_EDGE_FALLING_EDGE; 00234 // Initialize in synchronous mode : interrupt is synchronized to the clock 00235 eic_options[1].eic_async = EIC_SYNCH_MODE; 00236 // Set the interrupt line number. 00237 eic_options[1].eic_line = EXT_INT_EXAMPLE_LINE2; 00238 #endif 00239 00240 // Activate LED0 & LED1 pins in GPIO output mode and switch them off. 00241 gpio_set_gpio_pin(LED0_GPIO); 00242 gpio_set_gpio_pin(LED1_GPIO); 00243 00244 // Map the interrupt lines to the GPIO pins with the right peripheral functions. 00245 #if BOARD==EVK1100 || BOARD == EVK1104 00246 gpio_enable_module_pin(EXT_INT_EXAMPLE_PIN_LINE1,EXT_INT_EXAMPLE_FUNCTION_LINE1); 00247 #elif BOARD==EVK1101 00248 static const gpio_map_t EIC_GPIO_MAP = 00249 { 00250 {EXT_INT_EXAMPLE_PIN_LINE1, EXT_INT_EXAMPLE_FUNCTION_LINE1}, 00251 {EXT_INT_EXAMPLE_PIN_LINE2, EXT_INT_EXAMPLE_FUNCTION_LINE2} 00252 }; 00253 gpio_enable_module(EIC_GPIO_MAP,sizeof(EIC_GPIO_MAP) / sizeof(EIC_GPIO_MAP[0])); 00254 #endif 00255 00256 // Disable all interrupts. 00257 Disable_global_interrupt(); 00258 00259 #if BOARD==EVK1101 00260 // Initialize interrupt vectors. 00261 INTC_init_interrupts(); 00262 00263 // Register the USART interrupt handler to the interrupt controller. 00264 // usart_int_handler is the interrupt handler to register. 00265 // EXAMPLE_USART_IRQ is the IRQ of the interrupt handler to register. 00266 // AVR32_INTC_INT0 is the interrupt priority level to assign to the group of this IRQ. 00267 // void INTC_register_interrupt(__int_handler handler, unsigned int irq, unsigned int int_level); 00268 INTC_register_interrupt(&eic_int_handler1, EXT_INT_EXAMPLE_IRQ_LINE1, AVR32_INTC_INT0); 00269 INTC_register_interrupt(&eic_int_handler2, EXT_INT_EXAMPLE_IRQ_LINE2, AVR32_INTC_INT0); 00270 #endif 00271 00272 // On EVK1100, the JOYSTICK External interrupt line is assigned to the NMI. 00273 // On EVK1104, the J17.7 External interrupt line is assigned to the NMI. 00274 // Since the NMI is not an interrupt but an exception managed by the CPU, we have 00275 // to make sure that the NMI handler calls our handler: this is done in the 00276 // files exception.S(for GCC) & exception.s82(for IAR); look for the _handle_NMI 00277 // assembly label. 00278 00279 // Init the EIC controller with the options 00280 eic_init(&AVR32_EIC, eic_options,EXT_INT_EXAMPLE_NB_LINES); 00281 00282 // Enable the chosen lines and their corresponding interrupt feature. 00283 #if BOARD==EVK1100 || BOARD == EVK1104 00284 eic_enable_line(&AVR32_EIC, eic_options[0].eic_line); 00285 eic_enable_interrupt_line(&AVR32_EIC, eic_options[0].eic_line); 00286 #elif BOARD==EVK1101 00287 eic_enable_lines(&AVR32_EIC, (1<<eic_options[1].eic_line)|(1<<eic_options[0].eic_line)); 00288 eic_enable_interrupt_lines(&AVR32_EIC, (1<<eic_options[1].eic_line)|(1<<eic_options[0].eic_line)); 00289 #endif 00290 00291 // Enable all interrupts. 00292 Enable_global_interrupt(); 00293 00294 // Loop infinitely, toggling the leds depending on the latest external event. 00295 while(1) 00296 { 00297 switch (key_number) 00298 { 00299 case 1 : 00300 gpio_clr_gpio_pin(LED0_GPIO); 00301 gpio_set_gpio_pin(LED1_GPIO); 00302 key_number = 0; 00303 software_delay(); 00304 break; 00305 case 2 : 00306 gpio_set_gpio_pin(LED0_GPIO); 00307 gpio_clr_gpio_pin(LED1_GPIO); 00308 key_number = 0; 00309 software_delay(); 00310 break; 00311 default : 00312 gpio_set_gpio_pin(LED0_GPIO); 00313 gpio_set_gpio_pin(LED1_GPIO); 00314 break; 00315 } 00316 } 00317 }
static void software_delay | ( | void | ) | [static] |
Definition at line 207 of file eic_example2.c.
References bCancelSwDelay.
Referenced by main().
00208 { 00209 volatile int i; 00210 bCancelSwDelay = FALSE; 00211 for (i=10000; (i>=0)&&(FALSE == bCancelSwDelay); i--); 00212 }
volatile Bool bCancelSwDelay = FALSE [static] |
Global var used to cancel the software delay if an External Interrupt occurs.
Definition at line 141 of file eic_example2.c.
Referenced by eic_int_handler1(), eic_int_handler2(), and software_delay().
eic_options_t eic_options[EXT_INT_EXAMPLE_NB_LINES] |
Structure holding the configuration parameters of the EIC module.
Definition at line 135 of file eic_example2.c.
unsigned char key_number = 0 |
Global var used to switch between different LED patterns.
Definition at line 138 of file eic_example2.c.
Referenced by eic_int_handler1(), eic_int_handler2(), and main().