Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion DFRobot_IICSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ size_t DFRobot_IICSerial::read(void *pBuf, size_t size){
}
void DFRobot_IICSerial::flush(void){
sFsrReg_t fsr = readFIFOStateReg();
while(fsr.tDat == 1);
uint32_t start = millis();
while (millis() - start < IICSERIAL_FLUSH_TIMEOUT) {
sFsrReg_t fsr = readFIFOStateReg();
if (fsr.tDat != 1) {
break;
}
}
}


Expand Down
4 changes: 4 additions & 0 deletions DFRobot_IICSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#define DBG(...)
#endif

#if !defined(IICSERIAL_FLUSH_TIMEOUT)
#define IICSERIAL_FLUSH_TIMEOUT 8
#endif

#if !defined(SERIAL_RX_BUFFER_SIZE)
#if ((RAMEND - RAMSTART) < 1023)
#define SERIAL_RX_BUFFER_SIZE 16
Expand Down