[riot-notifications] [RIOT-OS/RIOT] drivers/dht: Bugfixes (#11876)

Marian Buschsieweke notifications at github.com
Tue Jul 23 21:46:43 CEST 2019


maribu commented on this pull request.



>      uint16_t res = 0;
 
     for (int i = 0; i < bits; i++) {
         uint32_t start, end;
         res <<= 1;
         /* measure the length between the next rising and falling flanks (the
          * time the pin is high - smoke up :-) */
-        while (!gpio_read(pin)) {}
+        unsigned counter = 0;
+        while (!gpio_read(pin)) {

Counting backwards could indeed be more intuitive. But I think counter would underflow that way, wouldn't it? E.g. it would break the loop when `counter` reaches zero, but than still does the post-decrement, right?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11876#discussion_r306500388
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190723/b62382ad/attachment.htm>


More information about the notifications mailing list