cpu/stm32_common: disable i2c in release

the hardware peripheral should be disabled before stopping the
peripheral clock.
This commit is contained in:
Toon Stegen 2019-08-26 12:31:54 +02:00
parent e32c772eb4
commit ac9afbe4f5
2 changed files with 16 additions and 0 deletions

View File

@ -143,6 +143,9 @@ int i2c_acquire(i2c_t dev)
periph_clk_en(i2c_config[dev].bus, i2c_config[dev].rcc_mask);
/* enable device */
i2c_config[dev].dev->CR1 |= I2C_CR1_PE;
return 0;
}
@ -150,6 +153,11 @@ void i2c_release(i2c_t dev)
{
assert(dev < I2C_NUMOF);
/* disable device */
i2c_config[dev].dev->CR1 &= ~(I2C_CR1_PE);
_wait_for_bus(i2c_config[dev].dev);
periph_clk_dis(i2c_config[dev].bus, i2c_config[dev].rcc_mask);
mutex_unlock(&locks[dev]);

View File

@ -193,6 +193,9 @@ int i2c_acquire(i2c_t dev)
periph_clk_en(i2c_config[dev].bus, i2c_config[dev].rcc_mask);
/* enable device */
i2c_config[dev].dev->CR1 |= I2C_CR1_PE;
return 0;
}
@ -200,6 +203,11 @@ void i2c_release(i2c_t dev)
{
assert(dev < I2C_NUMOF);
/* disable device */
i2c_config[dev].dev->CR1 &= ~(I2C_CR1_PE);
_wait_for_bus(i2c_config[dev].dev);
periph_clk_dis(i2c_config[dev].bus, i2c_config[dev].rcc_mask);
#ifdef STM32_PM_STOP