blob: 4bf823513f02f860da93538f2cdc85c2947ac542 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// L�sung zu Termin2
// Aufgabe 4
// Namen: __________; ___________
// Matr.: __________; ___________
// vom : __________
//
#include "pio.h"
#include "pmc.h"
#include "aic.h"
StructPMC* myPMC = PMC_BASE;
StructAIC* myAIC = AIC_BASE;
StructPIO* myPIOB = PIOB_BASE;
void taste_irq_handler (void) __interrupt__ ((interrupt));
void taste_irq_handler (void)
{
// do the things here
// necessary??
//myPIOB->PIO_ISR; // Read Interrupt Status Register to enable
// Interrupt again
// switch LED1
myAIC->AIC_EOICR = 0x00000000; // Write to End of Interrupt Command Register
// to signal end of Interrupt Service Routine
}
int main(void)
{
myPMC->PMC_PCER = 0x14; // Clock PIO B
// Initialize PIOB
myPIOB->PIO_PER = KEY1|KEY2|LED1|LED2; // Enable PIO for SW1,SW2,LED1,LED2
myPIOB->PIO_OER = LED1|LED2; // Set LED1 and LED2 as output
myPIOB->PIO_CODR = 0x000000FF; // Clear Output Data Register
// Enable Interrupts in CPU
// done by OS
// Enable Interrupt for PIOB in AIC
//myAIC->AIC_SMR[] = ; // which register? what to put in it?
//myAIC->AIC_SVR[]= taste_irq_handler // Address of Interrupt handling routine...
myAIC->AIC_IECR = PIOB_ID; // Enable Interrupt for PIOB
// enable PIOB Interrupt
//myPIOB->PIO_IER = ; // what to put here?
// loop to infinity
while(1)
{
}
return 0;
}
|