Start I2C clock based on selected I2C

This commit is contained in:
Daniel Fekete 2017-04-20 20:50:46 +02:00
parent 61a5e43c58
commit dbe4023b10
1 changed files with 20 additions and 1 deletions

View File

@ -17,7 +17,26 @@ void TwoWire::begin(void) {
stm32AfI2CInit(handle.Instance, sdaPort, sdaPin, sclPort, sclPin);
__HAL_RCC_I2C1_CLK_ENABLE();
#ifdef I2C1
if (handle.Instance == I2C1) {
__HAL_RCC_I2C1_CLK_ENABLE();
}
#endif
#ifdef I2C2
if (handle.Instance == I2C2) {
__HAL_RCC_I2C2_CLK_ENABLE();
}
#endif
#ifdef I2C3
if (handle.Instance == I2C3) {
__HAL_RCC_I2C3_CLK_ENABLE();
}
#endif
#ifdef I2C4
if (handle.Instance == I2C4) {
__HAL_RCC_I2C4_CLK_ENABLE();
}
#endif
#if defined(STM32F1) || defined(STM32F2) || defined(STM32F4) || defined(STM32L1)
handle.Init.ClockSpeed = 100000;