Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <system.h>
- #include <io.h>
- void main(void)
- {
- unsigned int sw = 0x00, hex = 0x00, cnt = 0x00, jed=0x00,
- dzi=0x00,set=0x00;
- unsigned char adamiswrong1 = 0x01;
- unsigned char adamiswrong2 = 0x02, adamiswrong3 = 0x04, adamiswrong4=0x08;
- printf("And its lights out and away we go\n");
- printf("Silver Arrows are up to a great start\n");
- while(1)
- {
- sw = IORD(PIO_SW_BASE, 0x00);
- IOWR(PIO_LED_BASE, 0x00, sw);
- if((sw & adamiswrong1) != 0)
- {
- if((sw & adamiswrong2) != 0)
- {
- cnt++;
- }
- else
- {
- if (cnt==0)
- {
- cnt=999;
- }
- else
- {
- cnt--;
- }
- }
- cnt %= 1000;
- jed = cnt%10;
- dzi = (cnt%100-jed)/10;
- set = cnt/100;
- hex |= 0x01000000;
- hex |= 0x02000000;
- hex |= 0x04000000;
- hex &= ~0xFFFFFF;
- hex |= jed;
- hex |= dzi<<4;
- hex |= set<<8;
- IOWR(PIO_HEX_BASE, 0x00, hex);
- if (((sw & adamiswrong3 ) != 0) && ((sw & adamiswrong4) != 0))
- {
- usleep(125000);
- }
- else if (((sw & adamiswrong3 ) == 0) && ((sw & adamiswrong4) != 0))
- {
- usleep(250000);
- }
- else if (((sw & adamiswrong3 ) != 0) && ((sw & adamiswrong4) == 0))
- {
- usleep(500000);
- }
- else if (((sw & adamiswrong3 ) == 0) && ((sw & adamiswrong4) == 0))
- {
- usleep(1000000);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement