aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-11-13 14:02:21 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-11-13 14:02:21 +0000
commit8beb4eb16652a07f602e07d17153d63ddba3d73f (patch)
treec191f4845ebb3969a44b5ba14da38fafe202f700 /os
parentf098e079d0fd66419adbb226d7045ca810fe9890 (diff)
downloadChibiOS-8beb4eb16652a07f602e07d17153d63ddba3d73f.tar.gz
ChibiOS-8beb4eb16652a07f602e07d17153d63ddba3d73f.tar.bz2
ChibiOS-8beb4eb16652a07f602e07d17153d63ddba3d73f.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8480 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/ports/STM32/STM32L4xx/hal_lld.c24
-rw-r--r--os/hal/ports/STM32/STM32L4xx/hal_lld.h22
2 files changed, 24 insertions, 22 deletions
diff --git a/os/hal/ports/STM32/STM32L4xx/hal_lld.c b/os/hal/ports/STM32/STM32L4xx/hal_lld.c
index fcc9cd6b3..f48cd8454 100644
--- a/os/hal/ports/STM32/STM32L4xx/hal_lld.c
+++ b/os/hal/ports/STM32/STM32L4xx/hal_lld.c
@@ -184,13 +184,17 @@ void stm32_clock_init(void) {
; /* Wait until LSI is stable. */
#endif
-#if STM32_ACTIVATE_PLL
- /* PLL activation.*/
+#if STM32_ACTIVATE_PLL || STM32_ACTIVATE_PLLSAI1 || STM32_ACTIVATE_PLLSAI2
+ /* PLLM and PLLSRC are common to all PLLs.*/
RCC->PLLCFGR = STM32_PLLR | STM32_PLLREN |
STM32_PLLQ | STM32_PLLQEN |
STM32_PLLP | STM32_PLLPEN |
STM32_PLLN | STM32_PLLM |
STM32_PLLSRC;
+#endif
+
+#if STM32_ACTIVATE_PLL
+ /* PLL activation.*/
RCC->CR |= RCC_CR_PLLON;
/* Waiting for PLL lock.*/
@@ -227,22 +231,20 @@ void stm32_clock_init(void) {
RCC->CFGR = STM32_MCOPRE | STM32_MCOSEL | STM32_STOPWUCK |
STM32_PPRE2 | STM32_PPRE1 | STM32_HPRE;
- /* DCKCFGR1 register initialization, note, must take care of the _OFF
+ /* CCIPR register initialization, note, must take care of the _OFF
pseudo settings.*/
{
- uint32_t ccipr = 0;
+ uint32_t ccipr = STM32_DFSDMSEL | STM32_SWPMI1SEL | STM32_ADCSEL |
+ STM32_CLK48SEL | STM32_LPTIM2SEL | STM32_LPTIM1SEL |
+ STM32_I2C3SEL | STM32_I2C2SEL | STM32_I2C1SEL |
+ STM32_UART5SEL | STM32_UART4SEL | STM32_USART3SEL |
+ STM32_USART2SEL | STM32_USART1SEL;
#if STM32_SAI2SEL != STM32_SAI2SEL_OFF
ccipr |= STM32_SAI2SEL;
#endif
#if STM32_SAI1SEL != STM32_SAI1SEL_OFF
ccipr |= STM32_SAI1SEL;
#endif
- ccipr |= STM32_DFSDMSEL | STM32_SWPMI1SEL | STM32_ADCSEL |
- STM32_CLK48SEL | STM32_SAI2SEL | STM32_SAI1SEL |
- STM32_LPTIM2SEL | STM32_LPTIM1SEL | STM32_I2C3SEL |
- STM32_I2C2SEL | STM32_I2C1SEL | STM32_UART5SEL |
- STM32_UART4SEL | STM32_USART3SEL | STM32_USART2SEL |
- STM32_USART1SEL;
RCC->CCIPR = ccipr;
}
@@ -250,7 +252,7 @@ void stm32_clock_init(void) {
FLASH->ACR = FLASH_ACR_DCEN | FLASH_ACR_ICEN | FLASH_ACR_PRFTEN |
STM32_FLASHBITS;
- /* Switching to the configured clock source if it is different from HSI.*/
+ /* Switching to the configured clock source if it is different from MSI.*/
#if (STM32_SW != STM32_SW_MSI)
RCC->CFGR |= STM32_SW; /* Switches on the selected clock source. */
while ((RCC->CFGR & RCC_CFGR_SWS) != (STM32_SW << 2))
diff --git a/os/hal/ports/STM32/STM32L4xx/hal_lld.h b/os/hal/ports/STM32/STM32L4xx/hal_lld.h
index 97ab91555..dec8e50da 100644
--- a/os/hal/ports/STM32/STM32L4xx/hal_lld.h
+++ b/os/hal/ports/STM32/STM32L4xx/hal_lld.h
@@ -178,11 +178,11 @@
* @name RCC_PLLCFGR register bits definitions
* @{
*/
-#define STM32_PLLSRC_MASK (3 << 16) /**< PLL clock source mask. */
-#define STM32_PLLSRC_NOCLOCK (0 << 16) /**< PLL clock source disabled. */
-#define STM32_PLLSRC_MSI (1 << 16) /**< PLL clock source is MSI. */
-#define STM32_PLLSRC_HSI16 (2 << 16) /**< PLL clock source is HSI16. */
-#define STM32_PLLSRC_HSE (3 << 16) /**< PLL clock source is HSE. */
+#define STM32_PLLSRC_MASK (3 << 0) /**< PLL clock source mask. */
+#define STM32_PLLSRC_NOCLOCK (0 << 0) /**< PLL clock source disabled. */
+#define STM32_PLLSRC_MSI (1 << 0) /**< PLL clock source is MSI. */
+#define STM32_PLLSRC_HSI16 (2 << 0) /**< PLL clock source is HSI16. */
+#define STM32_PLLSRC_HSE (3 << 0) /**< PLL clock source is HSE. */
/** @} */
/**
@@ -533,17 +533,17 @@
#endif
/**
- * @brief LSCO clock source.
+ * @brief MCO divider setting.
*/
-#if !defined(STM32_LSCOSEL) || defined(__DOXYGEN__)
-#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
+#if !defined(STM32_MCOPRE) || defined(__DOXYGEN__)
+#define STM32_MCOPRE STM32_MCOPRE_DIV1
#endif
/**
- * @brief MCO divider setting.
+ * @brief LSCO clock source.
*/
-#if !defined(STM32_MCOPRE) || defined(__DOXYGEN__)
-#define STM32_MCOPRE STM32_MCOPRE_DIV1
+#if !defined(STM32_LSCOSEL) || defined(__DOXYGEN__)
+#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK
#endif
/**