Merge pull request #191 from ondras12345/unknown-F_CPU

Fix infinite loop on STM32F103
This commit is contained in:
Limor "Ladyada" Fried 2022-06-25 21:18:53 -04:00 committed by GitHub
commit 5273ef06a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -360,7 +360,9 @@ bool DHT::read(bool force) {
// in the very latest IDE versions):
// https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/wiring_pulse.c
uint32_t DHT::expectPulse(bool level) {
#if (F_CPU > 16000000L)
// F_CPU is not be known at compile time on platforms such as STM32F103.
// The preprocessor seems to evaluate it to zero in that case.
#if (F_CPU > 16000000L) || (F_CPU == 0L)
uint32_t count = 0;
#else
uint16_t count = 0; // To work fast enough on slower AVR boards