diff --git a/include/libopencm3/stm32/common/rcc_common_all.h b/include/libopencm3/stm32/common/rcc_common_all.h index c610be8e..49837137 100644 --- a/include/libopencm3/stm32/common/rcc_common_all.h +++ b/include/libopencm3/stm32/common/rcc_common_all.h @@ -50,6 +50,8 @@ void rcc_periph_reset_hold(enum rcc_periph_rst rst); void rcc_periph_reset_release(enum rcc_periph_rst rst); void rcc_set_mco(uint32_t mcosrc); +void rcc_osc_bypass_enable(enum rcc_osc osc); +void rcc_osc_bypass_disable(enum rcc_osc osc); /** * Is the given oscillator ready? diff --git a/include/libopencm3/stm32/f0/rcc.h b/include/libopencm3/stm32/f0/rcc.h index b6e519ae..a1f87f8c 100644 --- a/include/libopencm3/stm32/f0/rcc.h +++ b/include/libopencm3/stm32/f0/rcc.h @@ -509,8 +509,6 @@ void rcc_osc_ready_int_disable(enum rcc_osc osc); int rcc_osc_ready_int_flag(enum rcc_osc osc); void rcc_osc_on(enum rcc_osc osc); void rcc_osc_off(enum rcc_osc osc); -void rcc_osc_bypass_enable(enum rcc_osc osc); -void rcc_osc_bypass_disable(enum rcc_osc osc); void rcc_css_enable(void); void rcc_css_disable(void); void rcc_css_int_clear(void); diff --git a/include/libopencm3/stm32/f1/rcc.h b/include/libopencm3/stm32/f1/rcc.h index 828475fd..115c8f5b 100644 --- a/include/libopencm3/stm32/f1/rcc.h +++ b/include/libopencm3/stm32/f1/rcc.h @@ -691,8 +691,6 @@ void rcc_osc_on(enum rcc_osc osc); void rcc_osc_off(enum rcc_osc osc); void rcc_css_enable(void); void rcc_css_disable(void); -void rcc_osc_bypass_enable(enum rcc_osc osc); -void rcc_osc_bypass_disable(enum rcc_osc osc); void rcc_set_sysclk_source(uint32_t clk); void rcc_set_pll_multiplication_factor(uint32_t mul); void rcc_set_pll2_multiplication_factor(uint32_t mul); diff --git a/include/libopencm3/stm32/f2/rcc.h b/include/libopencm3/stm32/f2/rcc.h index afda3692..37345910 100644 --- a/include/libopencm3/stm32/f2/rcc.h +++ b/include/libopencm3/stm32/f2/rcc.h @@ -745,8 +745,6 @@ void rcc_osc_on(enum rcc_osc osc); void rcc_osc_off(enum rcc_osc osc); void rcc_css_enable(void); void rcc_css_disable(void); -void rcc_osc_bypass_enable(enum rcc_osc osc); -void rcc_osc_bypass_disable(enum rcc_osc osc); void rcc_set_sysclk_source(uint32_t clk); void rcc_set_pll_source(uint32_t pllsrc); void rcc_set_ppre2(uint32_t ppre2); diff --git a/include/libopencm3/stm32/f3/rcc.h b/include/libopencm3/stm32/f3/rcc.h index a267d6ce..9b5f5c1b 100644 --- a/include/libopencm3/stm32/f3/rcc.h +++ b/include/libopencm3/stm32/f3/rcc.h @@ -596,8 +596,6 @@ void rcc_osc_on(enum rcc_osc osc); void rcc_osc_off(enum rcc_osc osc); void rcc_css_enable(void); void rcc_css_disable(void); -void rcc_osc_bypass_enable(enum rcc_osc osc); -void rcc_osc_bypass_disable(enum rcc_osc osc); void rcc_set_sysclk_source(uint32_t clk); void rcc_set_pll_source(uint32_t pllsrc); void rcc_set_ppre2(uint32_t ppre2); diff --git a/include/libopencm3/stm32/f4/rcc.h b/include/libopencm3/stm32/f4/rcc.h index 7322ec75..3b6f3806 100644 --- a/include/libopencm3/stm32/f4/rcc.h +++ b/include/libopencm3/stm32/f4/rcc.h @@ -946,8 +946,6 @@ void rcc_osc_on(enum rcc_osc osc); void rcc_osc_off(enum rcc_osc osc); void rcc_css_enable(void); void rcc_css_disable(void); -void rcc_osc_bypass_enable(enum rcc_osc osc); -void rcc_osc_bypass_disable(enum rcc_osc osc); void rcc_pllsai_config(uint16_t n, uint16_t p, uint16_t q, uint16_t r); void rcc_pllsai_postscalers(uint8_t q, uint8_t r); void rcc_set_sysclk_source(uint32_t clk); diff --git a/include/libopencm3/stm32/f7/rcc.h b/include/libopencm3/stm32/f7/rcc.h index ff49b2a4..9b2fad67 100644 --- a/include/libopencm3/stm32/f7/rcc.h +++ b/include/libopencm3/stm32/f7/rcc.h @@ -921,8 +921,6 @@ void rcc_osc_on(enum rcc_osc osc); void rcc_osc_off(enum rcc_osc osc); void rcc_css_enable(void); void rcc_css_disable(void); -void rcc_osc_bypass_enable(enum rcc_osc osc); -void rcc_osc_bypass_disable(enum rcc_osc osc); void rcc_set_sysclk_source(uint32_t clk); void rcc_set_pll_source(uint32_t pllsrc); void rcc_set_ppre2(uint32_t ppre2); diff --git a/include/libopencm3/stm32/l0/rcc.h b/include/libopencm3/stm32/l0/rcc.h index 230e82bf..fe31b3a3 100644 --- a/include/libopencm3/stm32/l0/rcc.h +++ b/include/libopencm3/stm32/l0/rcc.h @@ -660,8 +660,6 @@ BEGIN_DECLS void rcc_osc_on(enum rcc_osc osc); void rcc_osc_off(enum rcc_osc osc); -void rcc_osc_bypass_enable(enum rcc_osc osc); -void rcc_osc_bypass_disable(enum rcc_osc osc); void rcc_osc_ready_int_clear(enum rcc_osc osc); void rcc_osc_ready_int_enable(enum rcc_osc osc); void rcc_osc_ready_int_disable(enum rcc_osc osc); diff --git a/include/libopencm3/stm32/l1/rcc.h b/include/libopencm3/stm32/l1/rcc.h index 6432a493..9d55ee59 100644 --- a/include/libopencm3/stm32/l1/rcc.h +++ b/include/libopencm3/stm32/l1/rcc.h @@ -611,8 +611,6 @@ void rcc_osc_on(enum rcc_osc osc); void rcc_osc_off(enum rcc_osc osc); void rcc_css_enable(void); void rcc_css_disable(void); -void rcc_osc_bypass_enable(enum rcc_osc osc); -void rcc_osc_bypass_disable(enum rcc_osc osc); void rcc_set_msi_range(uint32_t range); void rcc_set_sysclk_source(uint32_t clk); void rcc_set_pll_configuration(uint32_t source, uint32_t multiplier, diff --git a/include/libopencm3/stm32/l4/rcc.h b/include/libopencm3/stm32/l4/rcc.h index fbdc7b8e..84544187 100644 --- a/include/libopencm3/stm32/l4/rcc.h +++ b/include/libopencm3/stm32/l4/rcc.h @@ -938,8 +938,6 @@ void rcc_osc_on(enum rcc_osc osc); void rcc_osc_off(enum rcc_osc osc); void rcc_css_enable(void); void rcc_css_disable(void); -void rcc_osc_bypass_enable(enum rcc_osc osc); -void rcc_osc_bypass_disable(enum rcc_osc osc); void rcc_set_sysclk_source(uint32_t clk); void rcc_set_pll_source(uint32_t pllsrc); void rcc_set_ppre2(uint32_t ppre2); diff --git a/lib/stm32/common/rcc_common_all.c b/lib/stm32/common/rcc_common_all.c index afa6263f..0c14313f 100644 --- a/lib/stm32/common/rcc_common_all.c +++ b/lib/stm32/common/rcc_common_all.c @@ -197,6 +197,66 @@ void rcc_set_mco(uint32_t mcosrc) (mcosrc << RCC_CFGR_MCO_SHIFT); } +/** + * RCC Enable Bypass. + * Enable an external clock to bypass the internal clock (high speed and low + * speed clocks only). The external clock must be enabled (see @ref rcc_osc_on) + * and the internal clock must be disabled (see @ref rcc_osc_off) for this to + * have effect. + * @note The LSE clock is in the backup domain and cannot be bypassed until the + * backup domain write protection has been removed (see @ref + * pwr_disable_backup_domain_write_protect). + * @param[in] osc Oscillator ID. Only HSE and LSE have effect. + */ +void rcc_osc_bypass_enable(enum rcc_osc osc) +{ + switch (osc) { + case RCC_HSE: + RCC_CR |= RCC_CR_HSEBYP; + break; + case RCC_LSE: +#ifdef RCC_CSR_LSEBYP + RCC_CSR |= RCC_CSR_LSEBYP; +#else + RCC_BDCR |= RCC_BDCR_LSEBYP; +#endif + break; + default: + /* Do nothing, only HSE/LSE allowed here. */ + break; + } +} + +/** + * RCC Disable Bypass. + * Re-enable the internal clock (high speed and low speed clocks only). The + * internal clock must be disabled (see @ref rcc_osc_off) for this to have + * effect. + * @note The LSE clock is in the backup domain and cannot have bypass removed + * until the backup domain write protection has been removed (see @ref + * pwr_disable_backup_domain_write_protect) or the backup domain has been reset + * (see @ref rcc_backupdomain_reset). + * @param[in] osc Oscillator ID. Only HSE and LSE have effect. + */ +void rcc_osc_bypass_disable(enum rcc_osc osc) +{ + switch (osc) { + case RCC_HSE: + RCC_CR &= ~RCC_CR_HSEBYP; + break; + case RCC_LSE: +#ifdef RCC_CSR_LSEBYP + RCC_CSR &= ~RCC_CSR_LSEBYP; +#else + RCC_BDCR &= ~RCC_BDCR_LSEBYP; +#endif + break; + default: + /* Do nothing, only HSE/LSE allowed here. */ + break; + } +} + /**@}*/ #undef _RCC_REG diff --git a/lib/stm32/f0/rcc.c b/lib/stm32/f0/rcc.c index a584509a..d3798596 100644 --- a/lib/stm32/f0/rcc.c +++ b/lib/stm32/f0/rcc.c @@ -323,66 +323,6 @@ void rcc_css_disable(void) RCC_CR &= ~RCC_CR_CSSON; } -/*---------------------------------------------------------------------------*/ -/** @brief RCC Enable Bypass. - * - * Enable an external clock to bypass the internal clock (high speed and low - * speed clocks only). The external clock must be enabled (see @ref rcc_osc_on) - * and the internal clock must be disabled (see @ref rcc_osc_off) for this to - * have effect. - * - * @param[in] osc enum ::osc_t. Oscillator ID. Only HSE and LSE have effect. - */ - -void rcc_osc_bypass_enable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR |= RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR |= RCC_BDCR_LSEBYP; - break; - case RCC_HSI48: - case RCC_HSI14: - case RCC_HSI: - case RCC_LSI: - case RCC_PLL: - /* Do nothing */ - break; - } -} - -/*---------------------------------------------------------------------------*/ -/** @brief RCC Disable Bypass. - * - * Re-enable the internal clock (high speed and low speed clocks only). The - * internal clock must be disabled (see @ref rcc_osc_off) for this to have - * effect. - * - * - * @param[in] osc enum ::osc_t. Oscillator ID. Only HSE and LSE have effect. - */ - -void rcc_osc_bypass_disable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR &= ~RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR &= ~RCC_BDCR_LSEBYP; - break; - case RCC_HSI48: - case RCC_HSI14: - case RCC_PLL: - case RCC_HSI: - case RCC_LSI: - /* Do nothing */ - break; - } -} - /*---------------------------------------------------------------------------*/ /** @brief RCC Set the Source for the System Clock. * diff --git a/lib/stm32/f1/rcc.c b/lib/stm32/f1/rcc.c index 53a015b5..af02d752 100644 --- a/lib/stm32/f1/rcc.c +++ b/lib/stm32/f1/rcc.c @@ -346,72 +346,6 @@ void rcc_css_disable(void) RCC_CR &= ~RCC_CR_CSSON; } -/*---------------------------------------------------------------------------*/ -/** @brief RCC Enable Bypass. - -Enable an external clock to bypass the internal clock (high speed and low speed -clocks only). The external clock must be enabled (see @ref rcc_osc_on) and the -internal clock must be disabled (see @ref rcc_osc_off) for this to have effect. - -@note The LSE clock is in the backup domain and cannot be bypassed until the -backup domain write protection has been removed (see @ref -pwr_disable_backup_domain_write_protect). - -@param[in] osc enum ::osc_t. Oscillator ID. Only HSE and LSE have effect. -*/ - -void rcc_osc_bypass_enable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR |= RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR |= RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_PLL2: - case RCC_PLL3: - case RCC_HSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - -/*---------------------------------------------------------------------------*/ -/** @brief RCC Disable Bypass. - -Re-enable the internal clock (high speed and low speed clocks only). The -internal clock must be disabled (see @ref rcc_osc_off) for this to have effect. - -@note The LSE clock is in the backup domain and cannot have bypass removed -until the backup domain write protection has been removed (see @ref -pwr_disable_backup_domain_write_protect) or the backup domain has been reset -(see @ref rcc_backupdomain_reset). - -@param[in] osc enum ::osc_t. Oscillator ID. Only HSE and LSE have effect. -*/ - -void rcc_osc_bypass_disable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR &= ~RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR &= ~RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_PLL2: - case RCC_PLL3: - case RCC_HSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - /*---------------------------------------------------------------------------*/ /** @brief RCC Set the Source for the System Clock. diff --git a/lib/stm32/f2/rcc.c b/lib/stm32/f2/rcc.c index ff3a4a8a..b662cebb 100644 --- a/lib/stm32/f2/rcc.c +++ b/lib/stm32/f2/rcc.c @@ -255,40 +255,6 @@ void rcc_css_disable(void) RCC_CR &= ~RCC_CR_CSSON; } -void rcc_osc_bypass_enable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR |= RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR |= RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - -void rcc_osc_bypass_disable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR &= ~RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR &= ~RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - void rcc_set_sysclk_source(uint32_t clk) { uint32_t reg32; diff --git a/lib/stm32/f3/rcc.c b/lib/stm32/f3/rcc.c index d9d12841..0a69efee 100644 --- a/lib/stm32/f3/rcc.c +++ b/lib/stm32/f3/rcc.c @@ -277,40 +277,6 @@ void rcc_css_disable(void) RCC_CR &= ~RCC_CR_CSSON; } -void rcc_osc_bypass_enable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR |= RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR |= RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - -void rcc_osc_bypass_disable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR &= ~RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR &= ~RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - void rcc_set_sysclk_source(uint32_t clk) { uint32_t reg32; diff --git a/lib/stm32/f4/rcc.c b/lib/stm32/f4/rcc.c index eb30dd25..be15a80c 100644 --- a/lib/stm32/f4/rcc.c +++ b/lib/stm32/f4/rcc.c @@ -532,37 +532,6 @@ void rcc_css_disable(void) RCC_CR &= ~RCC_CR_CSSON; } -void rcc_osc_bypass_enable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR |= RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR |= RCC_BDCR_LSEBYP; - break; - default: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - -void rcc_osc_bypass_disable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR &= ~RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR &= ~RCC_BDCR_LSEBYP; - break; - default: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - - /** * Set the dividers for the PLLSAI clock outputs * divider p is only available on F4x9 parts, pass 0 for other parts. diff --git a/lib/stm32/f7/rcc.c b/lib/stm32/f7/rcc.c index 10e1d2ef..4ef198e8 100644 --- a/lib/stm32/f7/rcc.c +++ b/lib/stm32/f7/rcc.c @@ -212,42 +212,6 @@ void rcc_css_disable(void) RCC_CR &= ~RCC_CR_CSSON; } -void rcc_osc_bypass_enable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR |= RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR |= RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - -void rcc_osc_bypass_disable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR &= ~RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR &= ~RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - - - void rcc_set_sysclk_source(uint32_t clk) { uint32_t reg32; diff --git a/lib/stm32/l0/rcc.c b/lib/stm32/l0/rcc.c index b7f9e584..f7d5c207 100644 --- a/lib/stm32/l0/rcc.c +++ b/lib/stm32/l0/rcc.c @@ -91,37 +91,6 @@ void rcc_osc_off(enum rcc_osc osc) } } -/* TODO easy target for shared code */ -void rcc_osc_bypass_enable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR |= RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_CSR |= RCC_CSR_LSEBYP; - break; - default: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - -/* TODO easy target for shared code */ -void rcc_osc_bypass_disable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR &= ~RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_CSR &= ~RCC_CSR_LSEBYP; - break; - default: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} /*---------------------------------------------------------------------------*/ /** @brief RCC Clear the Oscillator Ready Interrupt Flag diff --git a/lib/stm32/l1/rcc.c b/lib/stm32/l1/rcc.c index c76d6a25..81ef52a2 100644 --- a/lib/stm32/l1/rcc.c +++ b/lib/stm32/l1/rcc.c @@ -335,42 +335,6 @@ void rcc_css_disable(void) RCC_CR &= ~RCC_CR_CSSON; } -void rcc_osc_bypass_enable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR |= RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_CSR |= RCC_CSR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI: - case RCC_LSI: - case RCC_MSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - -void rcc_osc_bypass_disable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR &= ~RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_CSR &= ~RCC_CSR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI: - case RCC_LSI: - case RCC_MSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - /** * Set the range of the MSI oscillator * @param range desired range @ref rcc_icscr_msirange diff --git a/lib/stm32/l4/rcc.c b/lib/stm32/l4/rcc.c index 3d895c21..3259a001 100644 --- a/lib/stm32/l4/rcc.c +++ b/lib/stm32/l4/rcc.c @@ -258,42 +258,6 @@ void rcc_css_disable(void) RCC_CR &= ~RCC_CR_CSSON; } -void rcc_osc_bypass_enable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR |= RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR |= RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI16: - case RCC_MSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - -void rcc_osc_bypass_disable(enum rcc_osc osc) -{ - switch (osc) { - case RCC_HSE: - RCC_CR &= ~RCC_CR_HSEBYP; - break; - case RCC_LSE: - RCC_BDCR &= ~RCC_BDCR_LSEBYP; - break; - case RCC_PLL: - case RCC_HSI16: - case RCC_MSI: - case RCC_LSI: - /* Do nothing, only HSE/LSE allowed here. */ - break; - } -} - void rcc_set_sysclk_source(uint32_t clk) { uint32_t reg32;