Dallas' 1-Wire bus protocol library

Dependents:   DS1825 DISCO-F746-Dessiccateur-V1 watersenor_and_temp_code DS1820 ... more

Revision:
10:c89b9ad6097c
Parent:
9:4af0015b0f47
Child:
11:bc8ed7280966
--- a/OneWire.h	Sat Jan 26 21:21:27 2019 +0000
+++ b/OneWire.h	Sun Jan 27 14:11:28 2019 +0000
@@ -4,6 +4,21 @@
 #include <inttypes.h>
 #include <mbed.h>
 
+#if defined(TARGET_STM)
+    #define MODE(x)      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 WRITE(x)    write(x)
+#else
+    #define MODE()      mode(PullUp)
+    #define INPUT()     input()
+    #define OUTPUT()    output()
+    #define READ()      read()
+    #define WRITE(x)    write(x)
+#endif
+
 // You can exclude certain features from OneWire.  In theory, this
 // might save some space.  In practice, the compiler automatically
 // removes unused code (technically, the linker, using -fdata-sections
@@ -140,5 +155,3 @@
 };
 
 #endif
-
-