Statistics
| Branch: | Tag: | Revision:

root / LUFA / Platform / UC3 / InterruptManagement.c @ 978b99e5

History | View | Annotate | Download (2.29 KB)

1
/*
2
             LUFA Library
3
     Copyright (C) Dean Camera, 2011.
4

5
  dean [at] fourwalledcubicle [dot] com
6
           www.lufa-lib.org
7
*/
8

    
9
/*
10
  Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com)
11

12
  Permission to use, copy, modify, distribute, and sell this
13
  software and its documentation for any purpose is hereby granted
14
  without fee, provided that the above copyright notice appear in
15
  all copies and that both that the copyright notice and this
16
  permission notice and warranty disclaimer appear in supporting
17
  documentation, and that the name of the author not be used in
18
  advertising or publicity pertaining to distribution of the
19
  software without specific, written prior permission.
20

21
  The author disclaim all warranties with regard to this
22
  software, including all implied warranties of merchantability
23
  and fitness.  In no event shall the author be liable for any
24
  special, indirect or consequential damages or any damages
25
  whatsoever resulting from loss of use, data or profits, whether
26
  in an action of contract, negligence or other tortious action,
27
  arising out of or in connection with the use or performance of
28
  this software.
29
*/
30

    
31
#include "InterruptManagement.h"
32

    
33
/** Interrupt vector table, containing the ISR to call for each interrupt group */
34
InterruptHandlerPtr_t InterruptHandlers[AVR32_INTC_NUM_INT_GRPS];
35

    
36
/** ISR for unhandled interrupt groups */
37
ISR(Unhandled_Interrupt)
38
{
39
        for (;;);
40
}
41

    
42
/** Retrieves the associated interrupt handler for the interrupt group currently being fired. This
43
 *  is called directly from the exception handler routine before dispatching to the ISR.
44
 */
45
InterruptHandlerPtr_t INTC_GetInterruptHandler(const uint_reg_t InterruptLevel)
46
{
47
        return InterruptHandlers[AVR32_INTC.icr[AVR32_INTC_INT3 - InterruptLevel]];
48
}
49

    
50
/** Initializes the interrupt controller ready to handle interrupts. This must be called at the
51
 *  start of the user program before any interrupts are registered or enabled.
52
 */
53
void INTC_Init(void)
54
{
55
        for (uint8_t InterruptGroup = 0; InterruptGroup < AVR32_INTC_NUM_INT_GRPS; InterruptGroup++)
56
        {
57
                InterruptHandlers[InterruptGroup] = Unhandled_Interrupt;
58
                AVR32_INTC.ipr[InterruptGroup]    = Autovector_Table[AVR32_INTC_INT0];
59
        }
60

    
61
        __builtin_mtsr(AVR32_EVBA, (uintptr_t)&EVBA_Table);
62
}