mirror of
https://github.com/adafruit/DHT-sensor-library.git
synced 2023-10-23 22:20:38 +03:00
Merge pull request #36 from Zirientis/master
Cause interrupts to be reenabled if a timeout occurs while waiting for the sensor
This commit is contained in:
commit
9419315c50
7
DHT.cpp
7
DHT.cpp
@ -140,7 +140,8 @@ boolean DHT::read(void) {
|
||||
|
||||
// Turn off interrupts temporarily because the next sections are timing critical
|
||||
// and we don't want any interruptions.
|
||||
noInterrupts();
|
||||
{
|
||||
InterruptLock lock;
|
||||
|
||||
// End the start signal by setting data line high for 40 microseconds.
|
||||
digitalWrite(_pin, HIGH);
|
||||
@ -193,9 +194,9 @@ boolean DHT::read(void) {
|
||||
// cycle count so this must be a zero. Nothing needs to be changed in the
|
||||
// stored data.
|
||||
}
|
||||
// Timing critical code is now complete.
|
||||
|
||||
// Re-enable interrupts, timing critical code is complete.
|
||||
interrupts();
|
||||
}
|
||||
|
||||
DEBUG_PRINTLN(F("Received:"));
|
||||
DEBUG_PRINT(data[0], HEX); DEBUG_PRINT(F(", "));
|
||||
|
Loading…
Reference in New Issue
Block a user