Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define PIOB_PER (volatile unsigned int * const) 0xFFFFF400
- #define PIOB_OER (volatile unsigned int * const) 0xFFFFF410
- #define PIOB_SODR (volatile unsigned int * const) 0xFFFFF430
- #define PIOB_CODR (volatile unsigned int * const) 0xFFFFF434
- #define PIOC_PER (volatile unsigned int * const) 0xFFFFF600
- #define PIOC_ODR (volatile unsigned int * const) 0xFFFFF614
- #define PIOC_PUER (volatile unsigned int * const) 0xFFFFF664
- #define PIOC_PCER (volatile unsigned int * const) 0xFFFFF610
- #define PIOC_PDSR (volatile unsigned int * const) 0xFFFFF63C
- #define PIOC_SODR (volatile unsigned int * const) 0xFFFFF630
- #define PIOC_CODR (volatile unsigned int * const) 0xFFFFF634
- #define SET_LEDL (1<<8)
- #define SET_LED (1<<29)
- #define BTNL (1<<5)
- #define BTNR (1<<4)
- void dbgu_print_ascii(const char* string){}
- void delay()
- {
- volatile unsigned int i;
- for(i=0;i<1000000;i++);
- }
- int main()
- {
- *(PIOB_PER) = SET_LEDL;
- *(PIOB_OER) = SET_LEDL;
- *(PIOC_ODR) = BTNL;
- *(PIOC_PUER) = BTNL;
- *(PIOC_PER) = SET_LED|BTNL|BTNR;
- while(1)
- {
- *(PIOB_CODR) = SET_LEDL;
- delay();
- if((*PIOC_PDSR & BTNL) == 0)
- {
- *(PIOB_SODR) = SET_LEDL;
- delay();
- }
- else if((*PIOC_PDSR & BTNR) == 0)
- {
- *(PIOB_SODR) = SET_LEDL;
- delay();
- }
- *(PIOB_SODR) = SET_LEDL;
- delay();
- if((*PIOC_PDSR & BTNL) == 0)
- {
- *(PIOC_CODR) = SET_LEDL;
- delay();
- }
- else if((*PIOC_PDSR & BTNR) == 0)
- {
- *(PIOC_CODR) = SET_LEDL;
- delay();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement