// Lösung zu Termin2 // Aufgabe 4 // Namen: __________; ___________ // Matr.: __________; ___________ // vom : __________ // #include "../mi2/h/pio.h" #include "../mi2/h/pmc.h" #include "../mi2/h/aic.h" StructPMC* myPMC = PMC_BASE; StructAIC* myAIC = AIC_BASE; StructPIO* myPIOB = PIOB_BASE; void taste_irq_handler (void) __attribute__ ((interrupt)); void taste_irq_handler (void) { volatile int keyPressed = myPIOB->PIO_ISR; if (!(keyPressed & KEY1)) myPIOB->PIO_SODR = LED1; //if (!(myPIOB->PIO_PDSR & KEY2)) if (!(keyPressed & KEY2)) myPIOB->PIO_CODR = LED1; myAIC->AIC_EOICR = 0x01; // write something to register // to signal end of Interrupt Service Routine } int main(void) { myAIC->AIC_EOICR = myPIOB->PIO_ISR; // disable all interrupt sources of pio myPIOB->PIO_IDR = 0xFFFFFFFF; // Initialize PIOB myPIOB->PIO_PER = KEY1|KEY2|LED1; // Enable PIO for SW1,SW2,LED1,LED2 //myPIOB->PIO_OER = LED1|LED2; // Set LED1 and LED2 as output myPIOB->PIO_OER = LED1; // Set LED1 and LED2 as output myPIOB->PIO_CODR = LED1; // Clear Output Data Register // Enable Interrupts in CPU // done by OS // disable PIOB Interrupt in AIC myAIC->AIC_IDCR = (1<AIC_SMR[PIOB_ID] = AIC_SRCTYPE_EXT_LOW_LEVEL; // which register? what to put in it? 0x1 for low myAIC->AIC_SVR[PIOB_ID] = (volatile unsigned int)&taste_irq_handler; // Address of Interrupt handling routine... // enable PIOB Interrupt in AIC myAIC->AIC_IECR = (1<PIO_IER = KEY1|KEY2; // what to put here? myPMC->PMC_PCER = (1<