Skip to content

Commit f71f4fa

Browse files
add as class var
1 parent c364fab commit f71f4fa

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

include/Wire.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class TwoWire
256256
uint32_t wireTimeoutUs_;
257257
bool wireTimeoutFlag_;
258258
bool wireResetOnTimeout_;
259+
bool inTimeoutHandler_;
259260

260261
void resetTxBuffer();
261262
void resetRxBuffer();

src/Wire.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ TwoWire::TwoWire()
1616
rxBufferLength_(0),
1717
wireTimeoutUs_(0),
1818
wireTimeoutFlag_(false),
19-
wireResetOnTimeout_(false)
19+
wireResetOnTimeout_(false),
20+
inTimeoutHandler_(false)
2021
{
2122
bus_.fd = -1;
2223
bus_.device_path[0] = '\0';
@@ -457,11 +458,9 @@ void TwoWire::handleTimeoutFromErrno()
457458
wireTimeoutFlag_ = true;
458459

459460
/* Prevent infinite recursion if reopenBus also times out */
460-
static bool in_timeout_handler = false;
461-
462-
if (wireResetOnTimeout_ && !in_timeout_handler)
461+
if (wireResetOnTimeout_ && !inTimeoutHandler_)
463462
{
464-
in_timeout_handler = true;
463+
inTimeoutHandler_ = true;
465464

466465
/* Attempt to reopen the bus on timeout if configured */
467466
if (!reopenBus(devicePath_))
@@ -473,7 +472,7 @@ void TwoWire::handleTimeoutFromErrno()
473472
resetTxBuffer();
474473
resetRxBuffer();
475474

476-
in_timeout_handler = false;
475+
inTimeoutHandler_ = false;
477476
}
478477
}
479478

0 commit comments

Comments
 (0)