Skip to content

Commit f2babd5

Browse files
authored
Merge pull request #45 from CommunityGD32Cores/f/i2c-timeouts
The underlying i2c implementation would always block infinitely on reads
2 parents e467afa + d540c90 commit f2babd5

File tree

1 file changed

+1
-1
lines changed
  • libraries/Wire/src/utility

1 file changed

+1
-1
lines changed

libraries/Wire/src/utility/twi.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ i2c_status_enum i2c_master_receive(i2c_t *obj, uint8_t address, uint8_t *data, u
347347
}
348348
}
349349
timeout = FLAG_TIMEOUT;
350-
while(!i2c_flag_get(obj->i2c, I2C_FLAG_RBNE));
350+
while((!i2c_flag_get(obj->i2c, I2C_FLAG_RBNE)) && (--timeout != 0));
351351
data[count] = i2c_data_receive(obj->i2c);
352352
}
353353

0 commit comments

Comments
 (0)