Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. /**
  2. * EE3173 Lab 3
  3. * Mark Furland
  4. * 2015-02-06
  5. **/
  6. #include <alt_types.h>
  7.  
  8. void main(){
  9. alt_32 count = 0;
  10.  
  11. alt_32 switchHist = 0;
  12. alt_32 buttonHist = 0;
  13.  
  14. alt_32 delay = 0;
  15.  
  16. volatile alt_32* display = 0x11050;
  17. volatile alt_32* switches = 0x11030;
  18. volatile alt_32* buttons = 0x11040;
  19.  
  20. display[1] = 0xFFFFFFFF;//Set display direction to output
  21.  
  22. for(;;){
  23. //If a switch goes high, it will be marked here.
  24. switchHist |= switches[0];
  25. if(switchHist != switches[0]){
  26. //A switch has gone low
  27. //This will miss multiple switches at the same time,
  28. //but I think this is acceptable?
  29. count++;
  30. switchHist = switches[0];
  31. }
  32.  
  33. buttonHist |= buttons[0];
  34. if(buttonHist != buttons[0]){
  35. //A button is pressed
  36. count++;
  37. buttonHist = buttons[0];
  38. }
  39.  
  40. //Set display to show count
  41. display[0] = count;
  42.  
  43. for(delay=0;delay<1001;delay++) ;
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement