//go:build stm32wlx package runtime import ( "device/stm32" "machine" ) const ( /* PLL Options RMN0461.p247 */ PLL_M = 2 PLL_N = 6 PLL_R = 2 PLL_P = 2 PLL_Q = 2 ) func init() { // Configure 48Mhz clock initCLK() // Timers init initTickTimer(&machine.TIM1) // UART init machine.InitSerial() } func initCLK() { // Enable HSE32 VDDTCXO output on package pin PB0-VDDTCXO stm32.RCC.CR.ReplaceBits(stm32.RCC_CR_HSEBYPPWR_VDDTCXO, stm32.RCC_CR_HSEBYPPWR_Msk, 0) // SYSCLOCK from HSE32 clock division factor (SYSCLOCK=HSE32) stm32.RCC.CR.ReplaceBits(stm32.RCC_CR_HSEPRE_Div1, stm32.RCC_CR_HSEPRE_Msk, 0) // enable external Clock HSE32 TXCO (RM0461p226) stm32.RCC.CR.SetBits(stm32.RCC_CR_HSEBYPPWR) stm32.RCC.CR.SetBits(stm32.RCC_CR_HSEON) for !stm32.RCC.CR.HasBits(stm32.RCC_CR_HSERDY) { } // Disable PLL stm32.RCC.CR.ClearBits(stm32.RCC_CR_PLLON) for stm32.RCC.CR.HasBits(stm32.RCC_CR_PLLRDY) { } // Configure the PLL stm32.RCC.PLLCFGR.Set((PLL_M-1)<