mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
cpu/stm32: fixed lfclk functions for L0 and L1
This commit is contained in:
parent
7ea8c7f768
commit
82485cf7c6
@ -37,6 +37,16 @@
|
|||||||
#define BIT_APB_PWREN RCC_APB1ENR_PWREN
|
#define BIT_APB_PWREN RCC_APB1ENR_PWREN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined (CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)
|
||||||
|
#define REG_LSE CSR
|
||||||
|
#define BIT_LSEON RCC_CSR_LSEON
|
||||||
|
#define BIT_LSERDY RCC_CSR_LSERDY
|
||||||
|
#else
|
||||||
|
#define REG_LSE BDCR
|
||||||
|
#define BIT_LSEON RCC_BDCR_LSEON
|
||||||
|
#define BIT_LSERDY RCC_BDCR_LSERDY
|
||||||
|
#endif
|
||||||
|
|
||||||
void stmclk_enable_hsi(void)
|
void stmclk_enable_hsi(void)
|
||||||
{
|
{
|
||||||
RCC->CR |= RCC_CR_HSION;
|
RCC->CR |= RCC_CR_HSION;
|
||||||
@ -58,8 +68,8 @@ void stmclk_enable_lfclk(void)
|
|||||||
{
|
{
|
||||||
#if CLOCK_LSE
|
#if CLOCK_LSE
|
||||||
stmclk_dbp_unlock();
|
stmclk_dbp_unlock();
|
||||||
RCC->BDCR |= RCC_BDCR_LSEON;
|
RCC->REG_LSE |= BIT_LSEON;
|
||||||
while (!(RCC->BDCR & RCC_BDCR_LSERDY)) {}
|
while (!(RCC->REG_LSE & BIT_LSERDY)) {}
|
||||||
stmclk_dbp_lock();
|
stmclk_dbp_lock();
|
||||||
#else
|
#else
|
||||||
RCC->CSR |= RCC_CSR_LSION;
|
RCC->CSR |= RCC_CSR_LSION;
|
||||||
@ -71,7 +81,8 @@ void stmclk_disable_lfclk(void)
|
|||||||
{
|
{
|
||||||
#if CLOCK_LSE
|
#if CLOCK_LSE
|
||||||
stmclk_dbp_unlock();
|
stmclk_dbp_unlock();
|
||||||
RCC->BDCR &= ~(RCC_BDCR_LSEON);
|
RCC->REG_LSE &= ~(BIT_LSEON);
|
||||||
|
while (!(RCC->REG_LSE & BIT_LSERDY)) {}
|
||||||
stmclk_dbp_lock();
|
stmclk_dbp_lock();
|
||||||
#else
|
#else
|
||||||
RCC->CSR &= ~(RCC_CSR_LSION);
|
RCC->CSR &= ~(RCC_CSR_LSION);
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
|
#include "stmclk.h"
|
||||||
#include "periph_conf.h"
|
#include "periph_conf.h"
|
||||||
#include "periph/init.h"
|
#include "periph/init.h"
|
||||||
|
|
||||||
@ -125,22 +126,11 @@ static void cpu_clock_init(void)
|
|||||||
|
|
||||||
/* configure the low speed clock domain (LSE vs LSI) */
|
/* configure the low speed clock domain (LSE vs LSI) */
|
||||||
#if CLOCK_LSE
|
#if CLOCK_LSE
|
||||||
/* allow write access to backup domain */
|
/* we enable the LSE clock if available for calibrating the MSI clock */
|
||||||
periph_clk_en(APB1, RCC_APB1ENR1_PWREN);
|
stmclk_enable_lfclk();
|
||||||
PWR->CR1 |= PWR_CR1_DBP;
|
|
||||||
/* enable LSE */
|
|
||||||
RCC->BDCR = RCC_BDCR_LSEON;
|
|
||||||
while (!(RCC->BDCR & RCC_BDCR_LSERDY)) {}
|
|
||||||
/* disable write access to back domain when done */
|
|
||||||
PWR->CR1 &= ~(PWR_CR1_DBP);
|
|
||||||
periph_clk_dis(APB1, RCC_APB1ENR1_PWREN);
|
|
||||||
|
|
||||||
/* now we can enable the MSI PLL mode */
|
/* now we can enable the MSI PLL mode */
|
||||||
RCC->CR |= RCC_CR_MSIPLLEN;
|
RCC->CR |= RCC_CR_MSIPLLEN;
|
||||||
while (!(RCC->CR & RCC_CR_MSIRDY)) {}
|
while (!(RCC->CR & RCC_CR_MSIRDY)) {}
|
||||||
#else
|
|
||||||
RCC->CSR = RCC_CSR_LSION;
|
|
||||||
while (!(RCC->CSR & RCC_CSR_LSIRDY)) {}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* select the MSI clock for the 48MHz clock tree (USB, RNG) */
|
/* select the MSI clock for the 48MHz clock tree (USB, RNG) */
|
||||||
|
Loading…
Reference in New Issue
Block a user