Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions libraries/Wire/examples/slave_sender/slave_sender.ino
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


#include <Wire.h>

unsigned long IICfreetime = 0;
void setup()
{
Wire.begin(2); // join i2c bus with address #2
Expand All @@ -20,7 +20,14 @@ void setup()

void loop()
{
delay(100);
if (__HAL_I2C_GET_FLAG(Wire.getHandle(), I2C_FLAG_BUSY) == RESET) {
IICfreetime = millis(); //总线不忙
} else if ((millis() - IICfreetime) > 100) { //总线忙超过100ms复位
Wire.end();
Wire.begin(2);
Wire.onRequest(requestEvent);
}
delay(1);
}

// function that executes whenever data is requested by master
Expand Down