Advertisement
Guest User

Untitled

a guest
Mar 18th, 2013
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. /*
  2. * stress.c:
  3. *Â Â Â Â Â WiringPi stress test
  4. *
  5. * Copyright (c) 2012-2013 Gordon Henderson. <projects@drogon.net>
  6. ***********************************************************************
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <wiringPi.h>
  11. #include <mcp23s17.h>
  12. // #include <mcp23017.h>
  13. // #include <sr595.h>
  14.  
  15. // The first pin number for each device
  16.  
  17. #define BASE_SPI 123
  18. // #define BASE_I2C 456
  19. // #define BASE_SR 789
  20.  
  21. int main (void)
  22. {
  23. int i, bit ;
  24.  
  25. wiringPiSetup () ;
  26. //mcp23017Setup (BASE_I2C, 0x20) ;
  27. mcp23s17Setup (BASE_SPI, 0, 0) ;
  28. //sr595Setup (BASE_SR, 10, 0, BASE_SPI, BASE_I2C) ;
  29.  
  30. printf ("Raspberry Pi - MCP23S17 Test\n") ;
  31.  
  32. // For the push button to stop it...
  33.  
  34. pinMode (BASE_SPI + 15, INPUT) ;
  35. pullUpDnControl (BASE_SPI + 15, PUD_UP) ;
  36.  
  37. for (;;)
  38. {
  39. for (i = 0 ; i < 1024 ; ++i)
  40. {
  41. for (bit = 0 ; bit < 10 ; ++bit)
  42. digitalWrite (BASE_SPI + bit, i & (1 << bit)) ;
  43. delay (5) ;
  44. while (digitalRead (BASE_SPI + 15) == 0)
  45. delay (1) ;
  46. }
  47. }
  48. return 0 ;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement