選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

53 行
1.3 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. const int GPIO = 19;
  8. const 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. 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. }