diff options
Diffstat (limited to 'src/stm32/stm32g0.c')
-rw-r--r-- | src/stm32/stm32g0.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/stm32/stm32g0.c b/src/stm32/stm32g0.c index 63edcbaa..1964d89f 100644 --- a/src/stm32/stm32g0.c +++ b/src/stm32/stm32g0.c @@ -38,14 +38,29 @@ lookup_clock_line(uint32_t periph_base) return (struct cline){.en=&RCC->APBENR1,.rst=&RCC->APBRSTR1,.bit=1<<13}; if (periph_base == CRS_BASE) return (struct cline){.en=&RCC->APBENR1,.rst=&RCC->APBRSTR1,.bit=1<<16}; + if (periph_base == TIM1_BASE) + return (struct cline){.en=&RCC->APBENR2,.rst=&RCC->APBRSTR2,.bit=1<<11}; if (periph_base == SPI1_BASE) return (struct cline){.en=&RCC->APBENR2,.rst=&RCC->APBRSTR2,.bit=1<<12}; if (periph_base == USART1_BASE) return (struct cline){.en=&RCC->APBENR2,.rst=&RCC->APBRSTR2,.bit=1<<14}; + if (periph_base == TIM14_BASE) + return (struct cline){.en=&RCC->APBENR2,.rst=&RCC->APBRSTR2,.bit=1<<15}; + if (periph_base == TIM15_BASE) + return (struct cline){.en=&RCC->APBENR2,.rst=&RCC->APBRSTR2,.bit=1<<16}; + if (periph_base == TIM16_BASE) + return (struct cline){.en=&RCC->APBENR2,.rst=&RCC->APBRSTR2,.bit=1<<17}; + if (periph_base == TIM17_BASE) + return (struct cline){.en=&RCC->APBENR2,.rst=&RCC->APBRSTR2,.bit=1<<18}; if (periph_base == ADC1_BASE) return (struct cline){.en=&RCC->APBENR2,.rst=&RCC->APBRSTR2,.bit=1<<20}; - uint32_t bit = 1 << ((periph_base - APBPERIPH_BASE) / 0x400); - return (struct cline){.en=&RCC->APBENR1, .rst=&RCC->APBRSTR1, .bit=bit}; + if (periph_base >= APBPERIPH_BASE && periph_base <= LPTIM1_BASE) + { + uint32_t bit = 1 << ((periph_base - APBPERIPH_BASE) / 0x400); + return (struct cline){.en=&RCC->APBENR1, .rst=&RCC->APBRSTR1, .bit=bit}; + } + // unknown peripheral. returning .bit=0 makes this a no-op + return (struct cline){.en=&RCC->APBENR1, .rst=NULL, .bit=0}; } // Return the frequency of the given peripheral clock |