@@ -116,7 +116,7 @@ public:
116116 Hsi16 = 0b10,
117117 Hse = 0b11,
118118%% endif
119- %% if hsi48 and target.family not in ["l4", "l5", "u5 "]
119+ %% if hsi48 and target.family in ["f0 "]
120120 /// High speed internal clock (48 MHz)
121121 Hsi48 = RCC_CFGR_PLLSRC_HSI48_PREDIV,
122122 InternalClockMHz48 = Hsi48,
@@ -171,7 +171,7 @@ public:
171171 Hsi16 = Hsi,
172172%% endif
173173 Hse = RCC_CFGR_SW_HSE,
174- %% if hsi48 and target.family != "l4"
174+ %% if hsi48 and target.family in ["f0"]
175175 Hsi48 = RCC_CFGR_SW_HSI48,
176176 InternalClockMHz48 = Hsi48,
177177%% endif
@@ -383,6 +383,12 @@ public:
383383 Pll1Q = 0b10 << RCC_CCIPR1_ICLKSEL_Pos,
384384 Msik = 0b11 << RCC_CCIPR1_ICLKSEL_Pos,
385385 };
386+ %% elif hsi48 and target.family in ["l0"]
387+ enum class Clock48Source
388+ {
389+ PllQ = 0,
390+ Hsi48 = RCC_CCIPR_HSI48SEL,
391+ };
386392%% endif
387393
388394%% if target.family in ["f2", "f4", "f7"]
@@ -456,7 +462,7 @@ public:
456462 MultiSpeedInternalClockK = (0b1001 << RCC_{{cfgr_mco}}_MCOSEL_Pos), // MSIK
457463 %% endif
458464 };
459- %% else
465+ %% elif target.family in ["f0", "f1", "f3"]
460466 enum class
461467 ClockOutputSource : uint32_t
462468 {
@@ -814,6 +820,12 @@ public:
814820 {
815821 RCC->CCIPR1 = (RCC->CCIPR1 & ~RCC_CCIPR1_ICLKSEL_Msk) | uint32_t(source);
816822 }
823+ %% elif hsi48 and target.family in ["l0"]
824+ static inline void
825+ setClock48Source(Clock48Source source)
826+ {
827+ RCC->CCIPR = (RCC->CCIPR & ~RCC_CCIPR_HSI48SEL_Msk) | uint32_t(source);
828+ }
817829%% endif
818830
819831%% if target.family == "h7"
@@ -830,6 +842,31 @@ public:
830842 {
831843 RCC->{{d2}}CCIP2R = (RCC->{{d2}}CCIP2R & ~RCC_{{d2}}CCIP2R_USBSEL_Msk) | uint32_t(source);
832844 }
845+ %% elif hsi48 and target.family in ["f0"] and (target.name in ["42", "48", "72", "78"])
846+ enum class
847+ UsbClockSource : uint32_t
848+ {
849+ Hsi48 = 0,
850+ Pll = RCC_CFGR3_USBSW_PLLCLK,
851+ };
852+ static inline void
853+ enableUsbClockSource(UsbClockSource source)
854+ {
855+ RCC->CFGR3 = (RCC->CFGR3 & ~RCC_CFGR3_USBSW_Msk) | uint32_t(source);
856+ }
857+ %% elif hsi48 and target.family in ["g0"]
858+ enum class
859+ UsbClockSource : uint32_t
860+ {
861+ Hsi48 = 0,
862+ Hse = RCC_CCIPR2_USBSEL_0,
863+ Pll = RCC_CCIPR2_USBSEL_1,
864+ };
865+ static inline void
866+ enableUsbClockSource(UsbClockSource source)
867+ {
868+ RCC->CCIPR2 = (RCC->CCIPR2 & ~RCC_CCIPR2_USBSEL_Msk) | uint32_t(source);
869+ }
833870%% endif
834871
835872%% if target.family in ["f2", "f4", "f7"]
0 commit comments