SHARE
TWEET

Untitled

a guest Apr 24th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define PIOB_PER (volatile unsigned int * const) 0xFFFFF400
  2. #define PIOB_OER (volatile unsigned int * const) 0xFFFFF410
  3. #define PIOB_SODR (volatile unsigned int * const) 0xFFFFF430
  4. #define PIOB_CODR (volatile unsigned int * const) 0xFFFFF434
  5.  
  6. #define PIOC_PER (volatile unsigned int * const) 0xFFFFF600
  7. #define PIOC_ODR (volatile unsigned int * const) 0xFFFFF614
  8. #define PIOC_PUER (volatile unsigned int * const) 0xFFFFF664
  9. #define PIOC_PCER (volatile unsigned int * const) 0xFFFFF610
  10. #define PIOC_PDSR (volatile unsigned int * const) 0xFFFFF63C
  11. #define PIOC_SODR (volatile unsigned int * const) 0xFFFFF630
  12. #define PIOC_CODR (volatile unsigned int * const) 0xFFFFF634
  13.  
  14. #define SET_LEDL (1<<8)
  15. #define SET_LED (1<<29)
  16. #define BTNL (1<<5)
  17. #define BTNR (1<<4)
  18. void dbgu_print_ascii(const char* string){}
  19.  
  20. void delay()
  21. {
  22.     volatile unsigned int i;
  23.     for(i=0;i<1000000;i++);
  24. }
  25.  
  26. int main()
  27. {
  28.     *(PIOB_PER) = SET_LEDL;
  29.     *(PIOB_OER) = SET_LEDL;
  30.  
  31.     *(PIOC_ODR) = BTNL;
  32.     *(PIOC_PUER) = BTNL;
  33.     *(PIOC_PER) = SET_LED|BTNL|BTNR;
  34.    
  35.     while(1)
  36.     {
  37.         *(PIOB_CODR) = SET_LEDL;
  38.         delay();
  39.        
  40.         if((*PIOC_PDSR & BTNL) == 0)
  41.         {
  42.             *(PIOB_SODR) = SET_LEDL;
  43.             delay();
  44.         }  
  45.         else if((*PIOC_PDSR & BTNR) == 0)
  46.         {
  47.             *(PIOB_SODR) = SET_LEDL;
  48.             delay();
  49.         }
  50.    
  51.         *(PIOB_SODR) = SET_LEDL;
  52.         delay();
  53.        
  54.         if((*PIOC_PDSR & BTNL) == 0)
  55.         {
  56.             *(PIOC_CODR) = SET_LEDL;
  57.             delay();
  58.         }  
  59.         else if((*PIOC_PDSR & BTNR) == 0)
  60.         {
  61.             *(PIOC_CODR) = SET_LEDL;
  62.             delay();
  63.         }
  64.    
  65.     }
  66.  
  67.     return 0;
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top