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

58 lines
1.5 KiB

  1. // WiringPi test program: Kernel char device interface / sysfs successor
  2. // Compile: gcc -Wall wiringpi_test4_device.c -o wiringpi_test4_device -lwiringPi
  3. #include "wpi_test.h"
  4. #include <signal.h>
  5. #include <time.h>
  6. #include <sys/time.h>
  7. int GPIO = 35; //BCM 19
  8. int GPIOIN = 37; //BCM 26;
  9. const int ToggleValue = 4;
  10. int main (void) {
  11. printf("WiringPi GPIO test program 2 (using physical 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_PHYS) == -1) {
  14. printf("wiringPiSetupGpioDevice failed\n\n");
  15. exit(EXIT_FAILURE);
  16. }
  17. if (!piBoard40Pin()) {
  18. GPIO = 16; //BCM 23
  19. GPIOIN = 18; //BCM 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. }