From 9ff4f1bb2f7be2b98ed92cd40cda1c47af3448d1 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 13 Nov 2019 22:20:29 -0500 Subject: stm32f0: Initial support for i2c on stm32f0 Signed-off-by: Kevin O'Connor --- src/stm32/stm32f0.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/stm32/stm32f0.c') diff --git a/src/stm32/stm32f0.c b/src/stm32/stm32f0.c index f9eabeab..11951920 100644 --- a/src/stm32/stm32f0.c +++ b/src/stm32/stm32f0.c @@ -128,9 +128,12 @@ pll_setup(void) while ((RCC->CFGR & RCC_CFGR_SWS_Msk) != RCC_CFGR_SWS_PLL) ; - // Select PLL as source for USB clock + // Setup CFGR3 register + uint32_t cfgr3 = RCC_CFGR3_I2C1SW; if (CONFIG_USBSERIAL) - RCC->CFGR3 = RCC_CFGR3_USBSW; + // Select PLL as source for USB clock + cfgr3 |= RCC_CFGR3_USBSW; + RCC->CFGR3 = cfgr3; } // Configure and enable internal 48Mhz clock on the stm32f042 @@ -153,6 +156,9 @@ hsi48_setup(void) enable_pclock(CRS_BASE); CRS->CR |= CRS_CR_AUTOTRIMEN | CRS_CR_CEN; } + + // Setup I2C1 clock + RCC->CFGR3 = RCC_CFGR3_I2C1SW; #endif } -- cgit v1.2.3-70-g09d2