zzz
Diff: OneWire.cpp
- Revision:
- 7:acf3f0ee66d2
- Parent:
- 6:d6e084297fb9
- Child:
- 8:87fbdaba5535
--- a/OneWire.cpp Sun Jan 20 10:10:20 2019 +0000 +++ b/OneWire.cpp Sun Jan 20 19:52:50 2019 +0000 @@ -118,7 +118,10 @@ OneWire::OneWire(PinName pin): wire(pin) -{ +{ + wire.mode(PullUp); + timer.stop(); + timer.reset(); #if ONEWIRE_SEARCH reset_search(); #endif @@ -182,12 +185,15 @@ uint8_t OneWire::read_bit(void) { uint8_t r; + int t; wire.output(); wire = 0; timer.start(); wire.input(); - wait_us(12 - timer.read_us()); + t = timer.read_us(); + if (t < 10) + wait_us(10 - t); r = wire.read(); timer.stop(); timer.reset();