Skip to content

Commit 251459e

Browse files
committed
STM32: Remove i2c_read() and i2c_write() redirects to HAL_I2C_IsDeviceReady()
Some I2C devices require specific zero length read/write sequences which the HAL_I2C_IsDeviceReady() redirect interferes with. After Removing these redirects, it was confirmed that zero length reads and writes would both still work correctly for detecting presence/absence of an I2C device on a bus.
1 parent 1af8aef commit 251459e

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

targets/TARGET_STM/i2c_api.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -743,13 +743,6 @@ int i2c_read(i2c_t *obj, int address, char *data, int length, int stop) {
743743
int count = I2C_ERROR_BUS_BUSY, ret = 0;
744744
uint32_t timeout = 0;
745745

746-
if((length == 0) || (data == 0)) {
747-
if(HAL_I2C_IsDeviceReady(handle, address, 1, 10) == HAL_OK)
748-
return 0;
749-
else
750-
return I2C_ERROR_BUS_BUSY;
751-
}
752-
753746
if ((obj_s->XferOperation == I2C_FIRST_AND_LAST_FRAME) ||
754747
(obj_s->XferOperation == I2C_LAST_FRAME)) {
755748
if (stop)
@@ -802,13 +795,6 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) {
802795
int count = I2C_ERROR_BUS_BUSY, ret = 0;
803796
uint32_t timeout = 0;
804797

805-
if((length == 0) || (data == 0)) {
806-
if(HAL_I2C_IsDeviceReady(handle, address, 1, 10) == HAL_OK)
807-
return 0;
808-
else
809-
return I2C_ERROR_BUS_BUSY;
810-
}
811-
812798
if ((obj_s->XferOperation == I2C_FIRST_AND_LAST_FRAME) ||
813799
(obj_s->XferOperation == I2C_LAST_FRAME)) {
814800
if (stop)

0 commit comments

Comments
 (0)