From c7457d0d8a3158bdb55c4eae76b0cc223c334342 Mon Sep 17 00:00:00 2001 From: ntruchsess Date: Tue, 23 Feb 2016 17:23:54 +0100 Subject: [PATCH] fix missing detection of reset during write of zero-bits --- OneWireSlave.cpp | 7 +++++++ OneWireSlave.h | 1 + 2 files changed, 8 insertions(+) diff --git a/OneWireSlave.cpp b/OneWireSlave.cpp index aaf6ade..01fd9c2 100644 --- a/OneWireSlave.cpp +++ b/OneWireSlave.cpp @@ -209,6 +209,12 @@ void OneWireSlave::beginResetDetection_() resetStart_ = micros() - 50; } +void OneWireSlave::beginResetDetectionSendZero_() +{ + setTimerEvent_(ResetMinDuration - SendBitDuration - 50, &OneWireSlave::resetCheck_); + resetStart_ = micros() - SendBitDuration - 50; +} + void OneWireSlave::cancelResetDetection_() { disableTimer_(); @@ -298,6 +304,7 @@ void OneWireSlave::endSendBitZero_() onEnterInterrupt_(); releaseBus_(); + beginResetDetectionSendZero_(); bitSentCallback_(false); onLeaveInterrupt_(); diff --git a/OneWireSlave.h b/OneWireSlave.h index 7291a61..5cc906c 100644 --- a/OneWireSlave.h +++ b/OneWireSlave.h @@ -53,6 +53,7 @@ private: static void beginSendBit_(bool bit, void(*completeCallback)(bool error)); static void beginResetDetection_(); + static void beginResetDetectionSendZero_(); static void cancelResetDetection_(); static void beginWaitReset_();