Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "AT91SAM9263.h"
- void dbgu_print_ascii(){}
- #define A (1<<25)
- #define B (1<<24)
- #define C (1<<22)
- #define D (1<<21)
- #define E (1<<20)
- #define F (1<<27)
- #define G (1<<26)
- #define DOT (1<<23)
- #define Q1 (1<<29)
- #define Q2 (1<<28)
- #define Q3 (1<<30)
- void initLCD(){
- AT91C_BASE_PIOB->PIO_OER = (A | B | C | D | E | F | G | DOT | Q1 | Q3 | Q2 );
- AT91C_BASE_PIOB->PIO_PER = (A | B | C | D | E | F | G | DOT | Q1 | Q3 | Q2 );
- }
- void clearLCD(){
- AT91C_BASE_PIOB->PIO_CODR= (A | B | C | D | E | F | G | DOT | Q1 | Q3 | Q2 );
- }
- void delay (volatile int ms){
- volatile int i = 0;
- AT91C_BASE_PITC->PITC_PIMR = ((1<<24) | 6250);
- while (i < ms){
- if (AT91C_BASE_PITC->PITC_PISR != 0)
- {
- AT91C_BASE_PITC->PITC_PIVR;
- i++;
- }
- }
- }
- void showNumber(volatile int number){
- switch (number){
- case 0:
- AT91C_BASE_PIOB->PIO_SODR = (A | B | C | D | E | F);
- break;
- case 1:
- AT91C_BASE_PIOB->PIO_SODR = (B | C );
- break;
- case 2:
- AT91C_BASE_PIOB->PIO_SODR = (A | B | G | E | D);
- break;
- case 3:
- AT91C_BASE_PIOB->PIO_SODR = (A | B | C | D | G);
- break;
- case 4:
- AT91C_BASE_PIOB->PIO_SODR = ( B | C | F | G);
- break;
- case 5:
- AT91C_BASE_PIOB->PIO_SODR = ( A | F | D | C | G);
- break;
- case 6:
- AT91C_BASE_PIOB->PIO_SODR = (A | G | C | D | E | F);
- break;
- case 7:
- AT91C_BASE_PIOB->PIO_SODR = (A | B | C);
- break;
- case 8:
- AT91C_BASE_PIOB->PIO_SODR = (A | B | C | D | E | F | G);
- break;
- case 9:
- AT91C_BASE_PIOB->PIO_SODR = (A | B | C | D | F | G);
- break;
- }
- }
- void rightLCD(){
- AT91C_BASE_PIOB->PIO_SODR = Q2;
- AT91C_BASE_PIOB->PIO_CODR = Q3;
- }
- void leftLCD(){
- AT91C_BASE_PIOB->PIO_SODR = Q3;
- AT91C_BASE_PIOB->PIO_CODR = Q2;
- }
- int main(void){
- volatile int c = 0;
- volatile int numb = 0;
- volatile int carry = 0;
- initLCD();
- clearLCD();
- while (1){
- for (c = 0; c < 10; c++){
- delay(10);
- clearLCD();
- leftLCD();
- showNumber(carry);
- delay(10);
- clearLCD();
- rightLCD();
- showNumber(numb);
- }
- if (numb < 8){
- numb += 2;
- }
- else
- {
- if (carry < 9){
- ++carry;
- }
- else{
- carry = 0;
- }
- numb = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement