Skip to content

Commit 0fa37dd

Browse files
ABOSTMfpistm
authored andcommitted
cores(C0): Some peripherals have HSIKER source instead of HSI
C0 doesn't have RCC_USART1CLKSOURCE_HSI but instead RCC_USART1CLKSOURCE_HSIKER Note: both HSI and HSIKER have the same HSI48 base, but each have a dedicated prescaler. This apply to UART1 and I2C1 Signed-off-by: Alexandre Bourdiol <[email protected]>
1 parent b7c4c13 commit 0fa37dd

File tree

2 files changed

+14
-0
lines changed
  • cores/arduino/stm32
  • libraries/Wire/src/utility

2 files changed

+14
-0
lines changed

cores/arduino/stm32/uart.h

+9
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ struct serial_s {
8888
/* Exported constants --------------------------------------------------------*/
8989
#define TX_TIMEOUT 1000
9090

91+
#if !defined(RCC_USART1CLKSOURCE_HSI)
92+
/* Some series like C0 have 2 derivated clock from HSI: HSIKER (for peripherals)
93+
* and HSISYS (for system clock). But each have a dedicated prescaler.
94+
* To avoid changing Arduino implementation,
95+
* remap RCC_USART1CLKSOURCE_HSI to RCC_USART1CLKSOURCE_HSIKER
96+
*/
97+
#define RCC_USART1CLKSOURCE_HSI RCC_USART1CLKSOURCE_HSIKER
98+
#endif
99+
91100
#if defined(USART2_BASE) && !defined(USART2_IRQn)
92101
#if defined(STM32G0xx)
93102
#if defined(LPUART2_BASE)

libraries/Wire/src/utility/twi.c

+5
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ static uint32_t i2c_getClkFreq(I2C_TypeDef *i2c)
210210
clkSrcFreq = HSI_VALUE;
211211
break;
212212
#endif
213+
#ifdef RCC_I2C1CLKSOURCE_HSIKER
214+
case RCC_I2C1CLKSOURCE_HSIKER:
215+
clkSrcFreq = __LL_RCC_CALC_HSIKER_FREQ(LL_RCC_HSIKER_GetDivider());
216+
break;
217+
#endif
213218
#ifdef RCC_I2C1CLKSOURCE_SYSCLK
214219
case RCC_I2C1CLKSOURCE_SYSCLK:
215220
clkSrcFreq = SystemCoreClock;

0 commit comments

Comments
 (0)