mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 19:23:25 +00:00
5f02d6b659
Define the board's external crystal (HSE) frequency `xtalHz` in the respective `board_*.go` files. Per-topology PLL tables (F1, F4, F7) will compute the register dividers from it. Moving this parameter to the board definition level cleanly isolates board hardware characteristics from general MCU chip configurations, eliminating the need for custom target build tags. Targets using HSE-clocked STM32 chips must define `xtalHz` or fail to build.
21 lines
660 B
Go
21 lines
660 B
Go
//go:build stm32f4 && (stm32f405 || stm32f407)
|
|
|
|
package machine
|
|
|
|
// PLLParams168MHz returns the HSE PLL dividers needed to reach a 336MHz VCO
|
|
// (168MHz SYSCLK, P=2, Q=7) for the configured crystal frequency. M is chosen
|
|
// to bring the PLL input (HSE/M) to 2MHz, the value RM0090 pg. 95 recommends
|
|
// to minimize jitter; the previous hardcoded F407 table used 1MHz.
|
|
func PLLParams168MHz() PLLParams {
|
|
switch xtalHz {
|
|
case 8_000_000:
|
|
return PLLParams{M: 4, N: 168, P: 2, Q: 7}
|
|
case 12_000_000:
|
|
return PLLParams{M: 6, N: 168, P: 2, Q: 7}
|
|
case 16_000_000:
|
|
return PLLParams{M: 8, N: 168, P: 2, Q: 7}
|
|
default:
|
|
panic("unsupported xtal frequency")
|
|
}
|
|
}
|