summaryrefslogtreecommitdiffstats
path: root/Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Termin2Aufgabe4b.c
blob: fd850c7effdbff744083cab39b09cad4ba348f25 (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
#include "init4.h"

void taste_irq_handler (void) __attribute__ ((interrupt));

void taste_irq_handler (void)
{

}

int main(void)
{   
    *pmc_PCER = 0x4000;    // Enable Peripheral Clock

    *pioB_PER = 0x118;    // LED1=0x100; SW1=0x8; SW2=0x10 -> addieren

    *pioB_OER = 0x100;    // Enable Output: LED1, WICHTIG: LED1 hier an!
   
    *aic_SVR = (int)taste_irq_handler;
    *aic_SMR = 1;
   
    for ( ; ; )   
    {
        if (!(*pioB_PDSR & 0x8))    // wenn SW1 dann LED1=ON (! -> low-active)
        {
            *pioB_CODR = 0x100;        // Clear LED DS1 -> LED = AN
            *aic_EOICR = 1;
        }
       
        if (!(*pioB_PDSR & 0x10))    // wenn SW2 dann LED1=OFF (! -> low-active)
        {
            *pioB_SODR = 0x100;        // Set LED DS1 -> LED = AUS
            *aic_EOICR = 1;
        }
    }

    return 0;
}