machine/stm32u585: implement ADC

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2026-03-18 12:29:53 +01:00
parent a9c0501826
commit 7ca53138bc
4 changed files with 151 additions and 0 deletions
+8
View File
@@ -30,4 +30,12 @@ func initCLK() {
// Enable PWR peripheral clock (required on STM32U5 before accessing PWR registers).
stm32.RCC.AHB3ENR.SetBits(stm32.RCC_AHB3ENR_PWREN)
_ = stm32.RCC.AHB3ENR.Get() // read-back for clock stabilization
// Switch from VOS Range 4 to Range 3. Range 4 doesn't support ADC (RM0456 §6.3.6).
// Range 3 supports up to 50 MHz HCLK and enables ADC. No flash wait-state change needed at 4 MHz.
// The EPOD booster must be enabled before changing VOS (RM0456 §10.5.4).
stm32.PWR.VOSR.SetBits(stm32.PWR_VOSR_BOOSTEN)
stm32.PWR.VOSR.ReplaceBits(stm32.PWR_VOSR_VOS_Range3<<stm32.PWR_VOSR_VOS_Pos, stm32.PWR_VOSR_VOS_Msk, 0)
for !stm32.PWR.VOSR.HasBits(stm32.PWR_VOSR_VOSRDY) {
}
}