MCPcopy Create free account
hub / github.com/WiringPi/WiringPi / maxDetectLowHighWait

Function maxDetectLowHighWait

wiringPi/rht03.c:40–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38 */
39
40static int maxDetectLowHighWait (const int pin)
41{
42 struct timeval now, timeOut, timeUp ;
43
44// If already high then wait for pin to go low
45
46 gettimeofday (&now, NULL) ;
47 timerclear (&timeOut) ;
48 timeOut.tv_usec = 1000 ;
49 timeradd (&now, &timeOut, &timeUp) ;
50
51 while (digitalRead (pin) == HIGH)
52 {
53 gettimeofday (&now, NULL) ;
54 if (timercmp (&now, &timeUp, >))
55 return false ;
56 }
57
58// Wait for it to go HIGH
59
60 gettimeofday (&now, NULL) ;
61 timerclear (&timeOut) ;
62 timeOut.tv_usec = 1000 ;
63 timeradd (&now, &timeOut, &timeUp) ;
64
65 while (digitalRead (pin) == LOW)
66 {
67 gettimeofday (&now, NULL) ;
68 if (timercmp (&now, &timeUp, >))
69 return false ;
70 }
71
72 return true ;
73}
74
75
76/*

Callers 2

maxDetectClockByteFunction · 0.70
maxDetectReadFunction · 0.70

Calls 1

digitalReadFunction · 0.85

Tested by

no test coverage detected