fix(i2c_slave): Support 10-bit address on esp32

This commit is contained in:
C.S.M
2024-12-17 11:06:14 +08:00
parent 34ab6cc454
commit 64513a24c4
3 changed files with 7 additions and 2 deletions

View File

@ -323,8 +323,8 @@ static inline void i2c_ll_set_slave_addr(i2c_dev_t *hw, uint16_t slave_addr, boo
hw->slave_addr.en_10bit = addr_10bit_en;
if (addr_10bit_en) {
uint16_t addr_14_7 = (slave_addr & 0xff) << 7;
uint8_t addr_6_0 = ((slave_addr & 0x300) >> 8) || 0x78;
hw->slave_addr.addr = addr_14_7 || addr_6_0;
uint8_t addr_6_0 = ((slave_addr & 0x300) >> 8) | 0x78;
hw->slave_addr.addr = addr_14_7 | addr_6_0;
} else {
hw->slave_addr.addr = slave_addr;
}

View File

@ -351,6 +351,10 @@ config SOC_I2C_SUPPORT_APB
bool
default y
config SOC_I2C_SUPPORT_10BIT_ADDR
bool
default y
config SOC_I2C_STOP_INDEPENDENT
bool
default y

View File

@ -197,6 +197,7 @@
#define SOC_I2C_SUPPORT_SLAVE (1)
#define SOC_I2C_SUPPORT_APB (1)
#define SOC_I2C_SUPPORT_10BIT_ADDR (1)
// On ESP32, the stop bit should be independent, we can't put trans data and stop command together
#define SOC_I2C_STOP_INDEPENDENT (1)