Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.43 KB | None | 0 0
  1. #include <targets\AT91SAM7.h>
  2. #include <stdbool.h>
  3. #include <PCF8833U8_lcd.h>
  4.  
  5.  
  6. void wait(int ms){
  7.   volatile int i,j;
  8.   for(i=0;i<ms;i++){
  9.     for(j=0;j<3000;j++){
  10.       __asm__("NOP");
  11.     }
  12.   }
  13. }
  14.  
  15. int main(void){
  16.   int x1=20;
  17.   int y1=20;
  18.   int x2=30;
  19.   int y2=30;
  20.   PMC_PCER = 1<<3 | 1<<2;
  21.   PIOA_PER = 1<<7 | 1<<8 | 1<<9 | 1<<14 | 1<<15;
  22.  
  23.  
  24.  
  25.   PIOB_PER = 1<<20 | 1<<24;
  26.   PIOB_OER = 1<<20;
  27.   PIOB_ODR = 1<<24;
  28.   PIOA_ODR = 1<<7 | 1<<8 | 1<<9 | 1<<14 | 1<<15;
  29.   PIOB_SODR = 1<<20;
  30.   PIOB_OWER = 1<<20;
  31.   InitLCD();
  32.   SetContrast(5);
  33.   Backlight(BL_ON);
  34.   LCDClearScreen();
  35.   LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
  36.   while(1){
  37.     if(!(PIOA_PDSR&(1<<7))){
  38.       LCDSetRect(x1,y1,x2,y2,FILL,BLACK);
  39.       y1-=5;
  40.       y2-=5;
  41.       LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
  42.       //PIOB_ODSR ^= (1<<20);
  43.       wait(50);
  44.     }
  45.     if(!(PIOA_PDSR&(1<<14))){
  46.       LCDSetRect(x1,y1,x2,y2,FILL,BLACK);
  47.       y1+=5;
  48.       y2+=5;
  49.       LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
  50.       //PIOB_ODSR ^= (1<<20);
  51.       wait(50);
  52.     }
  53.     if(!(PIOA_PDSR&(1<<8))){
  54.       LCDSetRect(x1,y1,x2,y2,FILL,BLACK);
  55.       x1+=5;
  56.       x2+=5;
  57.       LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
  58.       //PIOB_ODSR ^= (1<<20);
  59.       wait(50);
  60.     }
  61.     if(!(PIOA_PDSR&(1<<9))){
  62.       LCDSetRect(x1,y1,x2,y2,FILL,BLACK);
  63.       x1-=5;
  64.       x2-=5;
  65.       LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
  66.       //PIOB_ODSR ^= (1<<20);
  67.       wait(50);
  68.     }
  69.   }
  70.  
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement