Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <targets\AT91SAM7.h>
- #include <stdbool.h>
- #include <PCF8833U8_lcd.h>
- void wait(int ms){
- volatile int i,j;
- for(i=0;i<ms;i++){
- for(j=0;j<3000;j++){
- __asm__("NOP");
- }
- }
- }
- int main(void){
- int x1=20;
- int y1=20;
- int x2=30;
- int y2=30;
- PMC_PCER = 1<<3 | 1<<2;
- PIOA_PER = 1<<7 | 1<<8 | 1<<9 | 1<<14 | 1<<15;
- PIOB_PER = 1<<20 | 1<<24;
- PIOB_OER = 1<<20;
- PIOB_ODR = 1<<24;
- PIOA_ODR = 1<<7 | 1<<8 | 1<<9 | 1<<14 | 1<<15;
- PIOB_SODR = 1<<20;
- PIOB_OWER = 1<<20;
- InitLCD();
- SetContrast(5);
- Backlight(BL_ON);
- LCDClearScreen();
- LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
- while(1){
- if(!(PIOA_PDSR&(1<<7))){
- LCDSetRect(x1,y1,x2,y2,FILL,BLACK);
- y1-=5;
- y2-=5;
- LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
- //PIOB_ODSR ^= (1<<20);
- wait(50);
- }
- if(!(PIOA_PDSR&(1<<14))){
- LCDSetRect(x1,y1,x2,y2,FILL,BLACK);
- y1+=5;
- y2+=5;
- LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
- //PIOB_ODSR ^= (1<<20);
- wait(50);
- }
- if(!(PIOA_PDSR&(1<<8))){
- LCDSetRect(x1,y1,x2,y2,FILL,BLACK);
- x1+=5;
- x2+=5;
- LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
- //PIOB_ODSR ^= (1<<20);
- wait(50);
- }
- if(!(PIOA_PDSR&(1<<9))){
- LCDSetRect(x1,y1,x2,y2,FILL,BLACK);
- x1-=5;
- x2-=5;
- LCDSetRect(x1,y1,x2,y2,FILL,WHITE);
- //PIOB_ODSR ^= (1<<20);
- wait(50);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement