mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 11:37:46 +00:00
machine/stm32u585: implement ADC
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -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) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user