Working versione for L-tek FF1705

Dependents:   DS1820

Files at this revision

API Documentation at this revision

Comitter:
hudakz
Date:
Sun Jan 27 18:01:19 2019 +0000
Parent:
10:c89b9ad6097c
Child:
12:27a1b359b95c
Commit message:
Modified.

Changed in this revision

OneWire.cpp Show annotated file Show diff for this revision Revisions of this file
OneWire.h Show annotated file Show diff for this revision Revisions of this file
--- a/OneWire.cpp	Sun Jan 27 14:11:28 2019 +0000
+++ b/OneWire.cpp	Sun Jan 27 18:01:19 2019 +0000
@@ -126,9 +126,7 @@
 OneWire::OneWire(PinName pin) :
     DigitalInOut(pin)
 {
-    timer.stop();
-    timer.reset();
-    MODE(); // set mode either PullUp or OpenDrain
+    MODE(); // set mode either PullUp or OpenDrain for STM
 #if ONEWIRE_SEARCH
     reset_search();
 #endif
@@ -152,7 +150,7 @@
         if (--retries == 0)
             return 0;
         wait_us(2);
-    } while (READ() != 1);
+    } while (READ() == 0);
 
     OUTPUT();
     WRITE(0);
--- a/OneWire.h	Sun Jan 27 14:11:28 2019 +0000
+++ b/OneWire.h	Sun Jan 27 18:01:19 2019 +0000
@@ -5,11 +5,11 @@
 #include <mbed.h>
 
 #if defined(TARGET_STM)
-    #define MODE(x)      output(); \
+    #define MODE()       output(); \
                          mode(OpenDrain)
     #define INPUT()     (*gpio.reg_set = gpio.mask) // write 1 to open drain
-    #define OUTPUT()    // configured as output in the constructor and stays output forever
-    #define READ()      ((*gpio.reg_in & gpio.mask) ? 1 : 0)
+    #define OUTPUT()    // configured as output in the constructor and stays like that forever
+    #define READ()      ((*gpio.reg_in & gpio.mask) != 0)
     #define WRITE(x)    write(x)
 #else
     #define MODE()      mode(PullUp)