25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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