maygapixel

Untitled

Dec 16th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.04 KB | None | 0 0
  1. #include <LPC21xx.h>
  2. #include <stdio.h>
  3. #include "EXT.h"
  4. #include "uart0.h"
  5.  
  6. unsigned int a=1,b=1,c=1,buf=0,buf1=0,abuf=0,abuf1=0;
  7. void ExtInt(void)
  8. {
  9.     PINSEL0 |= 0x80000000;          //Enable the EXTINT2 interrupt
  10.     PINSEL0 |= 0x20000000;          //Enable the EXTINT1 interrupt
  11.     PINSEL0 |= 0x000C0000;          //Enable the EXTINT3 interrupt
  12.     VICVectCntl1    = 0x00000020 | 0x0000000F;          //select a priority slot for a given interrupt
  13.     VICVectAddr1    = (unsigned)EXTINT1VectoredIRQ;     //pass the address of the IRQ into the VIC slot
  14.     VICVectCntl2    = 0x00000020 | 0x00000010;          //select a priority slot for a given interrupt
  15.     VICVectAddr2    = (unsigned)EXTINT2VectoredIRQ;     //pass the address of the IRQ into the VIC slot
  16.     VICVectCntl3    = 0x00000020 | 0x00000011;          //select a priority slot for a given interrupt
  17.     VICVectAddr3    = (unsigned)EXTINT3VectoredIRQ;     //pass the address of the IRQ into the VIC slot
  18.  
  19.     VICIntEnable    |= 0x00020000;                      //enable EXTINT3 interrupt
  20.     VICIntEnable    |= 0x00010000;                      //enable EXTINT2 interrupt
  21.     VICIntEnable    |= 0x00008000;                      //enable EXTINT1 interrupt
  22.  
  23. }
  24. void EXTINT1VectoredIRQ (void)__irq
  25. {  
  26.     delay(2500000);
  27.     if (a == 1)
  28.     {
  29.         printf("current time\n");
  30.         a++;
  31.         buf=0;
  32.         buf1=0;
  33.     }
  34.     else if(a == 2){
  35.         printf("alarm time\n");
  36.         a= 1;
  37.         abuf=0;
  38.         abuf1=0;
  39.     }
  40.      
  41.     EXTINT  = 0x00000002;                   //Clear the peripheral interrupt flag
  42.     VICVectAddr     = 0x00000000;           //Dummy write to signal end of interrupt
  43. }
  44. void EXTINT2VectoredIRQ (void)__irq
  45. {
  46.     delay(2500000);
  47.     if (a == 2)
  48.     {
  49.        if(b==1 && buf==0){
  50.             printf("current time ok\n");
  51.             b++;
  52.             buf=1;
  53.             abuf1=0;
  54.        }
  55.        else if (b==2 && buf==1){
  56.             printf("current hour\n");
  57.             b++;
  58.             abuf1=0;
  59.        }
  60.        else if (b==3 && buf==1){
  61.             printf("current min\n");
  62.             b++;
  63.             abuf1=0;
  64.        }
  65.        else if (b==4 && buf==1){
  66.             printf("current sec\n");
  67.             b= 2;
  68.             abuf1=0;
  69.        }
  70.     }
  71.     else if (a == 1){
  72.        if(c==1 && abuf==0){
  73.             printf("alarm time ok\n");
  74.             abuf++;
  75.             c++;
  76.             abuf1=0;
  77.        }
  78.        else if (c==2 && abuf==1){
  79.             printf("alarm hour\n");
  80.             c++;
  81.             abuf1=0;
  82.        }
  83.        else if (c==3 && abuf==1){
  84.             printf("alarm min\n");
  85.             c++;
  86.             abuf1=0;
  87.        }
  88.        else if (c==4 && abuf==1){
  89.             printf("alarm sec\n");
  90.             c= 2;
  91.             abuf1=0;
  92.        }
  93.    
  94.     }
  95.     EXTINT  = 0x00000004;                   //Clear the peripheral interrupt flag
  96.     VICVectAddr     = 0x00000000;
  97. }
  98. void EXTINT3VectoredIRQ (void)__irq
  99. {
  100.     delay(2500000);
  101.     if (a == 2 && b==2)
  102.     {   if(buf1==0){
  103.             printf("set sec ok\n");
  104.             buf1=1;
  105.             }
  106.         else if (buf1==1){
  107.             if(SEC>58){
  108.                 SEC=0;
  109.                 printf("%d\n",SEC);
  110.             }
  111.             else{
  112.             printf("%d\n",SEC+1)    ;
  113.             SEC++;
  114.            
  115.             }
  116.          }
  117.     }
  118.     else if (a == 2 && b==4)
  119.     {   if(buf1==0){
  120.             printf("set min ok\n");
  121.             buf1=1;
  122.             }
  123.         else if (buf1==1){
  124.             if(MIN>58){
  125.                 MIN=0;
  126.                 printf("%d\n",MIN);
  127.             }
  128.             else{
  129.                 printf("%d\n",MIN+1)    ;
  130.                 MIN++;
  131.            
  132.             }
  133.          }
  134.      }
  135.      else if (a == 2 && b==3)
  136.     {   if(buf1==0){
  137.             printf("set hour ok\n");
  138.             buf1=1;
  139.             }
  140.         else if (buf1==1){
  141.             if(HOUR>22){
  142.                 HOUR=0;
  143.                 printf("%d\n",HOUR);
  144.             }
  145.             else{
  146.             printf("%d\n",HOUR+1)   ;
  147.             HOUR++;
  148.            
  149.             }
  150.          }
  151.     }    
  152.     if (a == 1 && c==2)
  153.     {   if(abuf1==0){
  154.             printf("set sec ok\n");
  155.             abuf1=1;
  156.             }
  157.         else if (abuf1==1){
  158.             if(ALSEC>58){
  159.                 ALSEC=0;
  160.                 printf("%d\n",ALSEC);
  161.             }
  162.             else{
  163.             printf("%d\n",ALSEC+1)  ;
  164.             ALSEC++;
  165.            
  166.             }
  167.          }
  168.     }
  169.     else if (a == 1 && c==4)
  170.     {   if(abuf1==0){
  171.             printf("set min ok\n");
  172.             abuf1=1;
  173.             }
  174.         else if (abuf1==1){
  175.             if(ALMIN>58){
  176.                 ALMIN=0;
  177.                 printf("%d\n",ALMIN);
  178.             }
  179.             else{
  180.                 printf("%d\n",ALMIN+1)  ;
  181.                 ALMIN++;
  182.            
  183.             }
  184.          }
  185.      }
  186.     else if (a == 1 && c==3)
  187.     {   if(abuf1==0){
  188.             printf("set hour ok\n");
  189.             abuf1=1;
  190.             }
  191.         else if (abuf1==1){
  192.             if(ALHOUR>22){
  193.                 ALHOUR=0;
  194.                 printf("%d\n",ALHOUR);
  195.             }
  196.             else{
  197.             printf("%d\n",ALHOUR+1) ;
  198.             ALHOUR++;
  199.            
  200.             }
  201.          }
  202.     }    
  203.  
  204.  
  205.  
  206.     EXTINT  = 0x00000008;                   //Clear the peripheral interrupt flag
  207.     VICVectAddr     = 0x00000000;           //Dummy write to signal end of interrupt
  208. }
Advertisement
Add Comment
Please, Sign In to add comment