Skip to content

Commit a9c3dde

Browse files
committed
driver: i2c: cc13xx_cc26xx: to support i2c scan
Sending address without data, make `i2c scan I2C_0` work. Signed-off-by: Baozhu Zuo <[email protected]>
1 parent 76c4591 commit a9c3dde

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

drivers/i2c/i2c_cc13xx_cc26xx.c

+11-3
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,20 @@ static int i2c_cc13xx_cc26xx_transmit(const struct device *dev,
5858
const uint32_t base = get_dev_config(dev)->base;
5959
struct i2c_cc13xx_cc26xx_data *data = get_dev_data(dev);
6060

61-
/* Sending address without data is not supported */
61+
I2CMasterSlaveAddrSet(base, addr, false);
62+
63+
/* Sending address without data is not supported, for `i2c scan` or other
64+
* function still neeed send i2c address check the device status.
65+
*/
6266
if (len == 0) {
63-
return -EIO;
67+
68+
I2CMasterControl(base, I2C_MASTER_CMD_SINGLE_SEND);
69+
70+
k_sem_take(&data->complete, K_FOREVER);
71+
72+
return data->error == I2C_MASTER_ERR_NONE ? 0 : -EIO;
6473
}
6574

66-
I2CMasterSlaveAddrSet(base, addr, false);
6775

6876
/* The following assumes a single master. Use I2CMasterBusBusy() if
6977
* wanting to implement multiple master support.

0 commit comments

Comments
 (0)