Skip to content

Commit

Permalink
Merge pull request #196 from delta-G/DG_WireMillis
Browse files Browse the repository at this point in the history
fixing millis rollover bug x2
  • Loading branch information
aentinger authored Nov 29, 2023
2 parents 684cafc + d7e4606 commit c0f158f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libraries/Wire/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ uint8_t TwoWire::read_from(uint8_t address, uint8_t* data, uint8_t length, unsig
err = m_read(&m_i2c_ctrl,data,length,!sendStop);
}
}
timeout_ms = millis() + timeout_ms;
while(millis() < timeout_ms && bus_status == WIRE_STATUS_UNSET && err == FSP_SUCCESS) {
uint32_t const start = millis();
while(((millis() - start) < timeout_ms) && bus_status == WIRE_STATUS_UNSET && err == FSP_SUCCESS) {

}
}
Expand All @@ -505,8 +505,8 @@ uint8_t TwoWire::write_to(uint8_t address, uint8_t* data, uint8_t length, unsign
err = m_write(&m_i2c_ctrl,data,length,!sendStop);
}
}
timeout_ms = millis() + timeout_ms;
while(millis() < timeout_ms && bus_status == WIRE_STATUS_UNSET && err == FSP_SUCCESS) {
uint32_t const start = millis();
while(((millis() - start) < timeout_ms) && bus_status == WIRE_STATUS_UNSET && err == FSP_SUCCESS) {

}

Expand Down

0 comments on commit c0f158f

Please sign in to comment.