1 | __attribute__((__interrupt__)) static void int4_handler(void)
|
2 | {
|
3 | printf("Pressed IGR\r\n");
|
4 | eic_clear_interrupt_line(&AVR32_EIC, EXT_INT4);
|
5 | }
|
6 | void InitInterrupts(void)
|
7 | {
|
8 | static const eic_options_t eic_options =
|
9 | {
|
10 | // Enable edge-triggered interrupt.
|
11 | .eic_mode = EIC_MODE_EDGE_TRIGGERED,
|
12 | // Interrupt will trigger on falling edge.
|
13 | .eic_edge = EIC_EDGE_FALLING_EDGE,
|
14 | // Initialize in synchronous mode : interrupt is synchronized to the clock
|
15 | .eic_async = EIC_ASYNCH_MODE,
|
16 | // Set the interrupt line number.
|
17 | .eic_line = EXT_INT4,
|
18 | // Enable filter.
|
19 | .eic_filter = EIC_FILTER_DISABLED, };
|
20 |
|
21 | static const gpio_map_t EIC_GPIO_MAP =
|
22 | {
|
23 | { AVR32_EIC_EXTINT_4_2_PIN, AVR32_EIC_EXTINT_4_2_FUNCTION }, };
|
24 |
|
25 | gpio_enable_module(EIC_GPIO_MAP,
|
26 | sizeof(EIC_GPIO_MAP) / sizeof(EIC_GPIO_MAP[0]));
|
27 |
|
28 | // gpio_enable_pin_interrupt(AVR32_EIC_EXTINT_4_2_PIN, GPIO_FALLING_EDGE);
|
29 |
|
30 | INTC_register_interrupt(&int4_handler, AVR32_EIC_IRQ_4, AVR32_INTC_INT0);
|
31 |
|
32 | eic_init(&AVR32_EIC, &eic_options, 1);
|
33 |
|
34 | eic_enable_lines(&AVR32_EIC, (1 << eic_options.eic_line));
|
35 | eic_enable_interrupt_lines(&AVR32_EIC, (1 << eic_options.eic_line));
|
36 |
|
37 | for (int i = 0; i < 9; ++i)
|
38 | {
|
39 | printf("Is Line %u enabled %u\r\n", i,
|
40 | eic_is_line_enabled(&AVR32_EIC, i));
|
41 | printf("Is Line Interrupt %u enabled %u \r\n", i,
|
42 | eic_is_interrupt_line_enabled(&AVR32_EIC, i));
|
43 | }
|
44 |
|
45 | }
|