-
-
Notifications
You must be signed in to change notification settings - Fork 91
Closed
Labels
conclusion: resolvedIssue was resolvedIssue was resolvedtopic: codeRelated to content of the project itselfRelated to content of the project itselftype: imperfectionPerceived defect in any part of projectPerceived defect in any part of project
Description
The code in bot TwoWire::read_from and TwoWire::write_to includes these lines:
timeout_ms = millis() + timeout_ms;
while(millis() < timeout_ms && bus_status == WIRE_STATUS_UNSET && err == FSP_SUCCESS) {
}
which is not safe for millis rollover. In the rare occurrence that read_from or write_to is called within timeout_ms of rollover, the code will immediately timeout. The AVR code for this is written using subtraction as is preached daily on the forum.
startMicros = micros();
while(TWI_MRX == twi_state){
if((twi_timeout_us > 0ul) && ((micros() - startMicros) > twi_timeout_us)) {
twi_handleTimeout(twi_do_reset_on_timeout);
return 0;
}
}
I propose fixing the code to use subtraction like the AVR code.
Metadata
Metadata
Assignees
Labels
conclusion: resolvedIssue was resolvedIssue was resolvedtopic: codeRelated to content of the project itselfRelated to content of the project itselftype: imperfectionPerceived defect in any part of projectPerceived defect in any part of project