drivers: i2c: stm32: Fix routing of secondary target address

Fixes the routing of the events associated with a secondary
i2c target address being routed to the primary config. The
i2c_target_config/slave_cfg was being selected from the
driver address match but then over written by the primary.
This change fully implements the if/else of 10bit addressing
and includes a assert if the slave_cfg is NULL, and explains
why dual 10bit addresses on STM32 won't work.

Signed-off-by: Tim Woolliscroft <tim@opteran.com>
This commit is contained in:
Tim Woolliscroft 2023-11-24 10:10:03 +00:00 committed by Fabio Baltieri
parent b373079275
commit 65068fb4df

View File

@ -142,9 +142,19 @@ static void stm32_i2c_slave_event(const struct device *dev)
__ASSERT_NO_MSG(0);
return;
}
} else {
/* On STM32 the LL_I2C_GetAddressMatchCode & (ISR register) returns
* only 7bits of address match so 10 bit dual addressing is broken.
* Revert to assuming single address match.
*/
if (data->slave_cfg != NULL) {
slave_cfg = data->slave_cfg;
} else {
__ASSERT_NO_MSG(0);
return;
}
}
slave_cfg = data->slave_cfg;
slave_cb = slave_cfg->callbacks;
if (LL_I2C_IsActiveFlag_TXIS(i2c)) {