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.
 
 
 
 
 

53 lines
1.4 KiB

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