Navigation Menu

Skip to content

Commit

Permalink
drivers: i2c: Add STM32F10X slave support
Browse files Browse the repository at this point in the history
Add i2c-slave support for STM3210X SoC series.

Signed-off-by: Pavlo Hamov <pavlo_hamov@jabil.com>
  • Loading branch information
Pavlo Hamov authored and galak committed Jul 31, 2019
1 parent b8b8d46 commit dca45cb
Show file tree
Hide file tree
Showing 3 changed files with 454 additions and 142 deletions.
1 change: 1 addition & 0 deletions drivers/i2c/Kconfig.stm32
Expand Up @@ -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.
Expand Down
12 changes: 1 addition & 11 deletions drivers/i2c/i2c_ll_stm32.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dca45cb

Please sign in to comment.