stm32: Use TIM for runtime clock

This commit is contained in:
Kenneth Bell
2021-05-15 10:38:40 -07:00
committed by Ron Evans
parent 003c96edc0
commit fa3dd41a4f
9 changed files with 122 additions and 307 deletions
+1 -25
View File
@@ -64,39 +64,15 @@ const (
FLASH_OPTIONS = stm32.FLASH_ACR_ICEN | stm32.FLASH_ACR_DCEN | stm32.FLASH_ACR_PRFTEN
)
/*
timer settings used for tick and sleep.
note: TICK_TIMER_FREQ and SLEEP_TIMER_FREQ are controlled by PLL / clock
settings above, so must be kept in sync if the clock settings are changed.
*/
const (
TICK_RATE = 1000 // 1 KHz
SLEEP_TIMER_IRQ = stm32.IRQ_TIM3
SLEEP_TIMER_FREQ = PCLK1_FREQ_HZ * 2
TICK_TIMER_IRQ = stm32.IRQ_TIM7
TICK_TIMER_FREQ = PCLK1_FREQ_HZ * 2
)
type arrtype = uint32
func init() {
initOSC() // configure oscillators
initCLK()
initSleepTimer(&timerInfo{
EnableRegister: &stm32.RCC.APB1ENR,
EnableFlag: stm32.RCC_APB1ENR_TIM3EN,
Device: stm32.TIM3,
})
initCOM()
initTickTimer(&timerInfo{
EnableRegister: &stm32.RCC.APB1ENR,
EnableFlag: stm32.RCC_APB1ENR_TIM7EN,
Device: stm32.TIM7,
})
initTickTimer(&machine.TIM3)
}
func initOSC() {