Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

58 righe
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. int GPIO = 24; //BCM 19
  8. 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. if (!piBoard40Pin()) {
  18. GPIO = 4; //BCM 23
  19. GPIOIN = 5; //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. }