You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

58 regels
1.4 KiB

  1. // WiringPi test program: Kernel char device interface / sysfs successor
  2. // Compile: gcc -Wall wiringpi_test2_device.c -o wiringpi_test2_device -lwiringPi
  3. #include "wpi_test.h"
  4. #include <signal.h>
  5. #include <time.h>
  6. #include <sys/time.h>
  7. int GPIO = 19;
  8. int GPIOIN = 26;
  9. const int ToggleValue = 4;
  10. int main (void) {
  11. printf("WiringPi GPIO test program 2 (using GPIO%d (output) and GPIO%d (input) via sys)\n", GPIO, GPIOIN);
  12. printf(" testing pullUpDnControl and pinMode PM_OFF\n");
  13. if (wiringPiSetupSys() == -1) {
  14. printf("wiringPiSetupSys failed\n\n");
  15. exit(EXIT_FAILURE);
  16. }
  17. if (!piBoard40Pin()) {
  18. GPIO = 23;
  19. GPIOIN = 24;
  20. }
  21. pinMode(GPIOIN, INPUT);
  22. pinMode(GPIO, OUTPUT);
  23. printf("\nTest output\n");
  24. digitalWriteEx(GPIO, GPIOIN, HIGH);
  25. delayMicroseconds(600000);
  26. digitalWriteEx(GPIO, GPIOIN, LOW);
  27. delayMicroseconds(600000);
  28. printf("\nTest output off with pull up\n");
  29. pinMode(GPIO, OUTPUT);
  30. digitalWriteEx(GPIO, GPIOIN, LOW);
  31. pullUpDnControl (GPIO, PUD_UP);
  32. pinMode(GPIO, PM_OFF);
  33. delayMicroseconds(600000);
  34. printf("out = off ");
  35. CheckGPIO(GPIO, GPIOIN, HIGH);
  36. delayMicroseconds(600000);
  37. printf("\nTest output off with pull down\n");
  38. pullUpDnControl (GPIO, PUD_DOWN);
  39. pinMode(GPIO, PM_OFF);
  40. delayMicroseconds(600000);
  41. printf("out = off ");
  42. CheckGPIO(GPIO, GPIOIN, LOW);
  43. delayMicroseconds(600000);
  44. return UnitTestState();
  45. }