Skip to content

Commit 0f760ed

Browse files
jurenatfabiobaltieri
authored andcommitted
drivers: clock: stm32c0: Add an option to enable CRS for HSI48
Allows enabling the Clock Recovery System (CRS) for HSI48 to achieve the expected accuracy for USB transfers. Uses USB SOF packet by default. Signed-off-by: Tomáš Juřena <[email protected]>
1 parent a7a9570 commit 0f760ed

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/clock_control/clock_stm32c0.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <soc.h>
1010
#include <stm32_ll_bus.h>
11+
#include <stm32_ll_crs.h>
1112
#include <stm32_ll_rcc.h>
1213
#include <stm32_ll_utils.h>
1314
#include <zephyr/drivers/clock_control.h>
@@ -22,4 +23,11 @@ void config_enable_default_clocks(void)
2223
{
2324
/* Enable the power interface clock */
2425
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
26+
27+
#if IS_ENABLED(STM32_HSI48_CRS_USB_SOF)
28+
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_CRS);
29+
LL_CRS_SetSyncSignalSource(LL_CRS_SYNC_SOURCE_USB);
30+
LL_CRS_EnableAutoTrimming();
31+
LL_CRS_EnableFreqErrorCounter();
32+
#endif
2533
}

0 commit comments

Comments
 (0)