Advertisement
Guest User

plackisagorace

a guest
Dec 6th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <system.h>
  4. #include <io.h>
  5.  
  6. void main(void)
  7. {
  8. unsigned int sw = 0x00, hex = 0x00, cnt = 0x00, jed=0x00,
  9. dzi=0x00,set=0x00;
  10. unsigned char adamiswrong1 = 0x01;
  11. unsigned char adamiswrong2 = 0x02, adamiswrong3 = 0x04, adamiswrong4=0x08;
  12.  
  13. printf("And its lights out and away we go\n");
  14. printf("Silver Arrows are up to a great start\n");
  15.  
  16. while(1)
  17. {
  18.  
  19. sw = IORD(PIO_SW_BASE, 0x00);
  20. IOWR(PIO_LED_BASE, 0x00, sw);
  21. if((sw & adamiswrong1) != 0)
  22. {
  23. if((sw & adamiswrong2) != 0)
  24. {
  25. cnt++;
  26. }
  27. else
  28. {
  29. if (cnt==0)
  30. {
  31. cnt=999;
  32. }
  33. else
  34. {
  35. cnt--;
  36. }
  37. }
  38. cnt %= 1000;
  39. jed = cnt%10;
  40. dzi = (cnt%100-jed)/10;
  41. set = cnt/100;
  42. hex |= 0x01000000;
  43. hex |= 0x02000000;
  44. hex |= 0x04000000;
  45. hex &= ~0xFFFFFF;
  46. hex |= jed;
  47. hex |= dzi<<4;
  48. hex |= set<<8;
  49. IOWR(PIO_HEX_BASE, 0x00, hex);
  50. if (((sw & adamiswrong3 ) != 0) && ((sw & adamiswrong4) != 0))
  51. {
  52. usleep(125000);
  53. }
  54. else if (((sw & adamiswrong3 ) == 0) && ((sw & adamiswrong4) != 0))
  55. {
  56. usleep(250000);
  57. }
  58. else if (((sw & adamiswrong3 ) != 0) && ((sw & adamiswrong4) == 0))
  59. {
  60. usleep(500000);
  61. }
  62. else if (((sw & adamiswrong3 ) == 0) && ((sw & adamiswrong4) == 0))
  63. {
  64. usleep(1000000);
  65. }
  66. }
  67.  
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement