#264 adjust unit test and autodetect unit test 6.2 irq
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// WiringPi test program: 3.16 new ISR2 function with Kernel char device interface / sysfs successor
|
// WiringPi test program: 6.1 new ISR2 function with Kernel char device interface / sysfs successor
|
||||||
// Compile: gcc -Wall wiringpi_test1_device.c -o wiringpi_test1_device -lwiringPi
|
// Compile: gcc -Wall wiringpi_test61_isr2.c -o wiringpi_test61_isr2 -lwiringPi
|
||||||
|
|
||||||
#include "wpi_test.h"
|
#include "wpi_test.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -189,7 +189,17 @@ int main (void) {
|
|||||||
|
|
||||||
wiringPiVersion(&major, &minor);
|
wiringPiVersion(&major, &minor);
|
||||||
|
|
||||||
printf("WiringPi GPIO test program 6b (using GPIO%d (output) and GPIO%d (input))\n", GPIO, GPIOIN);
|
int result = piBoard40Pin();
|
||||||
|
CheckNotSame("40-Pin board: ", result, -1);
|
||||||
|
if (result==0) {
|
||||||
|
printf("Old 28pin system\n");
|
||||||
|
//GPIO = 23;
|
||||||
|
//GPIOIN = 24;
|
||||||
|
GPIO = 17;
|
||||||
|
GPIOIN = 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("WiringPi GPIO test program 6.2 (using GPIO%d (output) and GPIO%d (input))\n", GPIO, GPIOIN);
|
||||||
printf("ISR and ISR2 test (WiringPi %d.%d)\n", major, minor);
|
printf("ISR and ISR2 test (WiringPi %d.%d)\n", major, minor);
|
||||||
|
|
||||||
wiringPiSetupGpio();
|
wiringPiSetupGpio();
|
||||||
@@ -206,15 +216,16 @@ int main (void) {
|
|||||||
accuracy = 0.02;
|
accuracy = 0.02;
|
||||||
bounce_acc = 2.7;
|
bounce_acc = 2.7;
|
||||||
break;
|
break;
|
||||||
|
case PI_MODEL_ZERO:
|
||||||
|
case PI_MODEL_ZERO_W: //ARM=1000MHz
|
||||||
|
accuracy = 0.02;
|
||||||
|
bounce_acc = 2.5;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
accuracy = 0.012;
|
accuracy = 0.012;
|
||||||
bounce_acc = 1.0;
|
bounce_acc = 1.0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!piBoard40Pin()) {
|
|
||||||
GPIO = 23;
|
|
||||||
GPIOIN = 24;
|
|
||||||
}
|
|
||||||
int IRQpin = GPIOIN;
|
int IRQpin = GPIOIN;
|
||||||
int OUTpin = GPIO;
|
int OUTpin = GPIO;
|
||||||
|
|
||||||
|
|||||||
@@ -76,15 +76,24 @@ int main (void) {
|
|||||||
|
|
||||||
CheckNotSame("piBoardId", RaspberryPiModel, 0);
|
CheckNotSame("piBoardId", RaspberryPiModel, 0);
|
||||||
|
|
||||||
int IRQpin = GPIOIN;
|
int _is40pin = is40pin();
|
||||||
int OUTpin = GPIO;
|
CheckNotSame("is40pin", _is40pin, -1);
|
||||||
|
|
||||||
switch(RaspberryPiModel) {
|
if (_is40pin) {
|
||||||
case PI_MODEL_4B:
|
|
||||||
case PI_MODEL_5:
|
int IRQpin = GPIOIN;
|
||||||
pinMode(IRQpin, INPUT);
|
int OUTpin = GPIO;
|
||||||
pinMode(OUTpin, OUTPUT);
|
|
||||||
digitalWrite (OUTpin, LOW) ;
|
pinMode(IRQpin, INPUT);
|
||||||
|
pinMode(OUTpin, OUTPUT);
|
||||||
|
digitalWrite(OUTpin, LOW);
|
||||||
|
delayMicroseconds(100);
|
||||||
|
CheckNotSame("Input", digitalRead(IRQpin), LOW);
|
||||||
|
digitalWrite(OUTpin, HIGH);
|
||||||
|
delayMicroseconds(100);
|
||||||
|
if (digitalRead(IRQpin)==HIGH) {
|
||||||
|
digitalWrite(OUTpin, LOW);
|
||||||
|
delayMicroseconds(100);
|
||||||
|
|
||||||
printf("\nTesting IRQ @ WPI-GPIO%d with trigger @ WPI-GPIO%d rising\n", IRQpin, OUTpin);
|
printf("\nTesting IRQ @ WPI-GPIO%d with trigger @ WPI-GPIO%d rising\n", IRQpin, OUTpin);
|
||||||
CheckSame("wiringPiISR", wiringPiISR(IRQpin, INT_EDGE_RISING, &wfiup), 0);
|
CheckSame("wiringPiISR", wiringPiISR(IRQpin, INT_EDGE_RISING, &wfiup), 0);
|
||||||
@@ -108,12 +117,12 @@ int main (void) {
|
|||||||
|
|
||||||
printf("Error check - next call must be wrong!\n");
|
printf("Error check - next call must be wrong!\n");
|
||||||
CheckSame("wiringPiISRStop with wrong pin, result code:", wiringPiISRStop(5555), EINVAL);
|
CheckSame("wiringPiISRStop with wrong pin, result code:", wiringPiISRStop(5555), EINVAL);
|
||||||
|
} else {
|
||||||
pinMode(OUTpin, INPUT);
|
printf("Hardware connection for unit test missing!\n");
|
||||||
break;
|
printf("unit test, need connection between Wiringpi pin 28 and 29!\n");
|
||||||
default:
|
}
|
||||||
printf("unit test not possible with this hardware, need connection between Wiringpi pin 28 and 29!\n");
|
} else {
|
||||||
break;
|
printf("unit test is for 40-pin hardware only!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return UnitTestState();
|
return UnitTestState();
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ int main (void) {
|
|||||||
case PI_MODEL_ZERO_W: //ARM=1000MHz
|
case PI_MODEL_ZERO_W: //ARM=1000MHz
|
||||||
fExpectTimedigitalWrite = 0.104; //us;
|
fExpectTimedigitalWrite = 0.104; //us;
|
||||||
fExpectTimedigitalRead = 0.135; //us
|
fExpectTimedigitalRead = 0.135; //us
|
||||||
fExpectTimepinMode = 0.280; //us
|
fExpectTimepinMode = 0.360; //us
|
||||||
break;
|
break;
|
||||||
case PI_MODEL_2:
|
case PI_MODEL_2:
|
||||||
ToggleValue /= 4;
|
ToggleValue /= 4;
|
||||||
|
|||||||
Reference in New Issue
Block a user