]> git.feebdaed.xyz Git - 0xmirror/WiringPi.git/commitdiff
#264 adjust unit test and fix is40pin
authormstroh76 <m.stroh76@gmail.com>
Fri, 23 May 2025 17:51:01 +0000 (19:51 +0200)
committermstroh76 <m.stroh76@gmail.com>
Fri, 23 May 2025 17:51:01 +0000 (19:51 +0200)
gpio/gpio.c
gpio/test/gpio_test6_wfi.sh
wiringPi/test/wiringpi_test61_isr2.c
wiringPi/test/wiringpi_test62_isr_wpin.c

index 2f6b683977a1193db6cb9c6b4b95782bd3e82a52..a420cd3cfc461714b802f766a16eb60643f602ae 100644 (file)
@@ -972,7 +972,7 @@ static void doVersion (char *argv [])
 
 static void doIs40Pin ()
 {
-  exit(piBoard40Pin());
+  exit(piBoard40Pin() ? EXIT_SUCCESS : EXIT_FAILURE);
 }
 
 /*
index 89f37e0d243d074f541aeaef7eaba19f3a22972b..5a0d6afc5218125636fc1cefb68b23e1e826ae15 100755 (executable)
@@ -110,11 +110,15 @@ wfis_test() {
     fi
 }
 
+gpio is40pin || { GPIOIN=17; GPIOOUT=18; echo "old 28 pin system"; }
+
+
 echo 
 echo Unit test gpio GPIO${GPIOOUT} and GPIO${GPIOIN} - functions: mode, write, wfi
 echo ------------------------------------------------------------------
 echo 
 
+
 #prepare trigger out
 gpio -g mode $GPIOOUT out
 
index 9c37cc02488ca83a61f43a97a0b4a473a60bcea7..e0d21f5dbaccd53436fc6144599d5fe4bcd0be8c 100644 (file)
@@ -12,7 +12,7 @@ int GPIO = 19;
 int GPIOIN = 26;
 const int ToggleValue = 4;
 float irq_timstamp_duration_ms = 0;
-float accuracy = 0.012;
+float accuracy = 0.015;
 float bounce_acc = 1.0;
 
 static volatile int globalCounter;
index 7447c35b789109ee98859a866fc8c5075e261f51..00a599a437538eb8d5d067f452e934b7f2f69bd2 100644 (file)
@@ -79,35 +79,41 @@ int main (void) {
   int IRQpin = GPIOIN;
   int OUTpin = GPIO;
   
-  if (RaspberryPiModel==PI_MODEL_4B) {
-    pinMode(IRQpin, INPUT);
-    pinMode(OUTpin, OUTPUT);
-    digitalWrite (OUTpin, LOW) ;
-  
-    printf("\nTesting IRQ @ WPI-GPIO%d with trigger @ WPI-GPIO%d rising\n", IRQpin, OUTpin);
-    CheckSame("wiringPiISR",  wiringPiISR(IRQpin, INT_EDGE_RISING, &wfiup), 0);
-    sleep(1);
-    StartSequence(INT_EDGE_RISING, OUTpin, 3 , 3);
-    sleep(1);
-    CheckSame("wiringPiISRStop", wiringPiISRStop(IRQpin), 0);
-    printf("\n.IRQ off\n");
-    sleep(1);
-    StartSequence(INT_EDGE_RISING, OUTpin, 2, 0);
-
-    printf("\nTesting IRQ @ WPI-GPIO%d with trigger @ WPI-GPIO%d falling\n", IRQpin, OUTpin);
-    CheckSame("wiringPiISR",  wiringPiISR(IRQpin, INT_EDGE_RISING, &wfidown), 0);
-    sleep(1);
-    StartSequence(INT_EDGE_FALLING, OUTpin, 4, -4);
-    sleep(1);
-    CheckSame("wiringPiISRStop", wiringPiISRStop(IRQpin), 0);
-    printf("\n.IRQ off\n");
-    sleep(1);
-    StartSequence(INT_EDGE_RISING, OUTpin, 2, 0);
-
-    printf("Error check - next call must be wrong!\n");
-    CheckSame("wiringPiISRStop with wrong pin, result code:", wiringPiISRStop(5555), EINVAL);
-
-    pinMode(OUTpin, INPUT);
+  switch(RaspberryPiModel) {
+    case PI_MODEL_4B:
+    case PI_MODEL_5:
+      pinMode(IRQpin, INPUT);
+      pinMode(OUTpin, OUTPUT);
+      digitalWrite (OUTpin, LOW) ;
+
+      printf("\nTesting IRQ @ WPI-GPIO%d with trigger @ WPI-GPIO%d rising\n", IRQpin, OUTpin);
+      CheckSame("wiringPiISR",  wiringPiISR(IRQpin, INT_EDGE_RISING, &wfiup), 0);
+      sleep(1);
+      StartSequence(INT_EDGE_RISING, OUTpin, 3 , 3);
+      sleep(1);
+      CheckSame("wiringPiISRStop", wiringPiISRStop(IRQpin), 0);
+      printf("\n.IRQ off\n");
+      sleep(1);
+      StartSequence(INT_EDGE_RISING, OUTpin, 2, 0);
+
+      printf("\nTesting IRQ @ WPI-GPIO%d with trigger @ WPI-GPIO%d falling\n", IRQpin, OUTpin);
+      CheckSame("wiringPiISR",  wiringPiISR(IRQpin, INT_EDGE_RISING, &wfidown), 0);
+      sleep(1);
+      StartSequence(INT_EDGE_FALLING, OUTpin, 4, -4);
+      sleep(1);
+      CheckSame("wiringPiISRStop", wiringPiISRStop(IRQpin), 0);
+      printf("\n.IRQ off\n");
+      sleep(1);
+      StartSequence(INT_EDGE_RISING, OUTpin, 2, 0);
+
+      printf("Error check - next call must be wrong!\n");
+      CheckSame("wiringPiISRStop with wrong pin, result code:", wiringPiISRStop(5555), EINVAL);
+
+      pinMode(OUTpin, INPUT);
+      break;
+    default:
+      printf("unit test not possible with this hardware, need connection between Wiringpi pin 28 and 29!\n");
+      break;
   }
 
        return UnitTestState();