Skip to content
Permalink
Browse files

drivers: i2c: Add STM32F10X slave support

Add i2c-slave support for STM3210X SoC series.

Signed-off-by: Pavlo Hamov <pavlo_hamov@jabil.com>
  • Loading branch information...
pavlohamov authored and galak committed Jul 16, 2019
1 parent b8b8d46 commit dca45cb29d44c47957cecb94d4063084e06f7810
Showing with 454 additions and 142 deletions.
  1. +1 −0 drivers/i2c/Kconfig.stm32
  2. +1 −11 drivers/i2c/i2c_ll_stm32.c
  3. +452 −131 drivers/i2c/i2c_ll_stm32_v1.c
@@ -17,6 +17,7 @@ config I2C_STM32_V1
depends on SOC_SERIES_STM32F1X || SOC_SERIES_STM32F4X || SOC_SERIES_STM32L1X
select HAS_DTS_I2C
select USE_STM32_LL_I2C
select I2C_STM32_INTERRUPT if I2C_SLAVE
help
Enable I2C support on the STM32 F1 and F4X family of processors. This
driver also supports the F2 and L1 series.
@@ -60,10 +60,6 @@ static int i2c_stm32_transfer(struct device *dev, struct i2c_msg *msg,
u8_t num_msgs, u16_t slave)
{
struct i2c_stm32_data *data = DEV_DATA(dev);
#if defined(CONFIG_I2C_STM32_V1)
const struct i2c_stm32_config *cfg = DEV_CFG(dev);
I2C_TypeDef *i2c = cfg->i2c;
#endif
struct i2c_msg *current, *next;
int ret = 0;

@@ -113,9 +109,6 @@ static int i2c_stm32_transfer(struct device *dev, struct i2c_msg *msg,

/* Send out messages */
k_sem_take(&data->bus_mutex, K_FOREVER);
#if defined(CONFIG_I2C_STM32_V1)
LL_I2C_Enable(i2c);
#endif

current = msg;

@@ -164,17 +157,14 @@ static int i2c_stm32_transfer(struct device *dev, struct i2c_msg *msg,
num_msgs--;
}
exit:
#if defined(CONFIG_I2C_STM32_V1)
LL_I2C_Disable(i2c);
#endif
k_sem_give(&data->bus_mutex);
return ret;
}

static const struct i2c_driver_api api_funcs = {
.configure = i2c_stm32_runtime_configure,
.transfer = i2c_stm32_transfer,
#if defined(CONFIG_I2C_SLAVE) && defined(CONFIG_I2C_STM32_V2)
#if defined(CONFIG_I2C_SLAVE)
.slave_register = i2c_stm32_slave_register,
.slave_unregister = i2c_stm32_slave_unregister,
#endif

0 comments on commit dca45cb

Please sign in to comment.
You can’t perform that action at this time.