aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/STM32/RT-STM32F031K6-NUCLEO32/mcuconf.h1
-rw-r--r--demos/STM32/RT-STM32F051-DISCOVERY/mcuconf.h1
-rw-r--r--demos/STM32/RT-STM32F070RB-NUCLEO64/mcuconf.h1
-rw-r--r--os/hal/ports/STM32/STM32F0xx/hal_lld.c3
-rw-r--r--os/hal/ports/STM32/STM32F0xx/hal_lld.h19
-rw-r--r--os/hal/ports/STM32/STM32F0xx/stm32_registry.h45
-rw-r--r--readme.txt2
7 files changed, 63 insertions, 9 deletions
diff --git a/demos/STM32/RT-STM32F031K6-NUCLEO32/mcuconf.h b/demos/STM32/RT-STM32F031K6-NUCLEO32/mcuconf.h
index 44eb7bb2c..3fc828e95 100644
--- a/demos/STM32/RT-STM32F031K6-NUCLEO32/mcuconf.h
+++ b/demos/STM32/RT-STM32F031K6-NUCLEO32/mcuconf.h
@@ -41,7 +41,6 @@
#define STM32_PLS STM32_PLS_LEV0
#define STM32_HSI_ENABLED TRUE
#define STM32_HSI14_ENABLED TRUE
-#define STM32_HSI48_ENABLED FALSE
#define STM32_LSI_ENABLED TRUE
#define STM32_HSE_ENABLED FALSE
#define STM32_LSE_ENABLED FALSE
diff --git a/demos/STM32/RT-STM32F051-DISCOVERY/mcuconf.h b/demos/STM32/RT-STM32F051-DISCOVERY/mcuconf.h
index 13c009529..aacd56eb4 100644
--- a/demos/STM32/RT-STM32F051-DISCOVERY/mcuconf.h
+++ b/demos/STM32/RT-STM32F051-DISCOVERY/mcuconf.h
@@ -41,7 +41,6 @@
#define STM32_PLS STM32_PLS_LEV0
#define STM32_HSI_ENABLED TRUE
#define STM32_HSI14_ENABLED TRUE
-#define STM32_HSI48_ENABLED FALSE
#define STM32_LSI_ENABLED TRUE
#define STM32_HSE_ENABLED FALSE
#define STM32_LSE_ENABLED FALSE
diff --git a/demos/STM32/RT-STM32F070RB-NUCLEO64/mcuconf.h b/demos/STM32/RT-STM32F070RB-NUCLEO64/mcuconf.h
index 5faa050cd..134a6c969 100644
--- a/demos/STM32/RT-STM32F070RB-NUCLEO64/mcuconf.h
+++ b/demos/STM32/RT-STM32F070RB-NUCLEO64/mcuconf.h
@@ -41,7 +41,6 @@
#define STM32_PLS STM32_PLS_LEV0
#define STM32_HSI_ENABLED TRUE
#define STM32_HSI14_ENABLED TRUE
-#define STM32_HSI48_ENABLED FALSE
#define STM32_LSI_ENABLED TRUE
#define STM32_HSE_ENABLED FALSE
#define STM32_LSE_ENABLED FALSE
diff --git a/os/hal/ports/STM32/STM32F0xx/hal_lld.c b/os/hal/ports/STM32/STM32F0xx/hal_lld.c
index 3422061e3..a85e92ac8 100644
--- a/os/hal/ports/STM32/STM32F0xx/hal_lld.c
+++ b/os/hal/ports/STM32/STM32F0xx/hal_lld.c
@@ -307,9 +307,10 @@ void stm32_clock_init(void) {
#endif
/* Clock settings.*/
+ /* CFGR2 must be configured first since CFGR value could change CFGR2 */
+ RCC->CFGR2 = STM32_PREDIV;
RCC->CFGR = STM32_PLLNODIV | STM32_MCOPRE | STM32_MCOSEL | STM32_PLLMUL |
STM32_PLLSRC | STM32_PPRE | STM32_HPRE;
- RCC->CFGR2 = STM32_PREDIV;
#if STM32_CECSW == STM32_CECSW_OFF
RCC->CFGR3 = STM32_USBSW | STM32_I2C1SW | STM32_USART1SW;
#else
diff --git a/os/hal/ports/STM32/STM32F0xx/hal_lld.h b/os/hal/ports/STM32/STM32F0xx/hal_lld.h
index 316d063b7..aebd833c9 100644
--- a/os/hal/ports/STM32/STM32F0xx/hal_lld.h
+++ b/os/hal/ports/STM32/STM32F0xx/hal_lld.h
@@ -499,6 +499,10 @@
* HSI related checks.
*/
#if STM32_HSI_ENABLED
+#if (STM32_SW == STM32_SW_PLL) && \
+ (STM32_PLLSRC == STM32_PLLSRC_HSI) && !STM32_HAS_HSI_PREDIV
+#error "STM32_PLLSRC_HSI not available on this platform. Select STM32_PLLSRC_HSI_DIV2 instead."
+#endif
#else /* !STM32_HSI_ENABLED */
#if STM32_SW == STM32_SW_HSI
@@ -548,6 +552,9 @@
* HSI48 related checks.
*/
#if STM32_HSI48_ENABLED
+#if !STM32_HAS_HSI48
+#error "HSI48 not available on this platform"
+#endif
#else /* !STM32_HSI48_ENABLED */
#if STM32_SW == STM32_SW_HSI48
@@ -662,7 +669,7 @@
#define STM32_ACTIVATE_PLL FALSE
#endif
-/* HSE prescaler setting check.*/
+/* HSE, HSI prescaler setting check.*/
#if ((STM32_PREDIV_VALUE >= 1) || (STM32_PREDIV_VALUE <= 16))
#define STM32_PREDIV ((STM32_PREDIV_VALUE - 1) << 0)
#else
@@ -821,14 +828,16 @@
*/
#if (STM32_MCOPRE == STM32_MCOPRE_DIV1) || defined(__DOXYGEN__)
#define STM32_MCOCLK STM32_MCODIVCLK
-#elif STM32_MCOPRE == STM32_MCOPRE_DIV2
+#elif (STM32_MCOPRE == STM32_MCOPRE_DIV2) && STM32_HAS_MCO_PREDIV
#define STM32_MCOCLK (STM32_MCODIVCLK / 2)
-#elif STM32_MCOPRE == STM32_MCOPRE_DIV4
+#elif (STM32_MCOPRE == STM32_MCOPRE_DIV4) && STM32_HAS_MCO_PREDIV
#define STM32_MCOCLK (STM32_MCODIVCLK / 4)
-#elif STM32_MCOPRE == STM32_MCOPRE_DIV8
+#elif (STM32_MCOPRE == STM32_MCOPRE_DIV8) && STM32_HAS_MCO_PREDIV
#define STM32_MCOCLK (STM32_MCODIVCLK / 8)
-#elif STM32_MCOPRE == STM32_MCOPRE_DIV16
+#elif (STM32_MCOPRE == STM32_MCOPRE_DIV16) && STM32_HAS_MCO_PREDIV
#define STM32_MCOCLK (STM32_MCODIVCLK / 16)
+#elif !STM32_HAS_MCO_PREDIV
+#error "MCO_PREDIV not available on this platform. Select STM32_MCODIVCLK."
#else
#error "invalid STM32_MCOPRE value specified"
#endif
diff --git a/os/hal/ports/STM32/STM32F0xx/stm32_registry.h b/os/hal/ports/STM32/STM32F0xx/stm32_registry.h
index e97c875c1..5e8b6532a 100644
--- a/os/hal/ports/STM32/STM32F0xx/stm32_registry.h
+++ b/os/hal/ports/STM32/STM32F0xx/stm32_registry.h
@@ -46,6 +46,15 @@
/* Common identifier of all STM32F030 devices.*/
#define STM32F030
+/* RCC attributes. */
+#define STM32_HAS_HSI48 FALSE
+#if defined(STM32F030xC)
+#define STM32_HAS_HSI_PREDIV TRUE
+#else
+#define STM32_HAS_HSI_PREDIV FALSE
+#endif
+#define STM32_HAS_MCO_PREDIV TRUE
+
/* ADC attributes.*/
#define STM32_HAS_ADC1 TRUE
#define STM32_ADC_SUPPORTS_PRESCALER FALSE
@@ -241,6 +250,7 @@
#define STM32_HAS_TIM2 FALSE
#define STM32_HAS_TIM4 FALSE
#define STM32_HAS_TIM5 FALSE
+#define STM32_HAS_TIM7 FALSE
#define STM32_HAS_TIM8 FALSE
#define STM32_HAS_TIM9 FALSE
#define STM32_HAS_TIM10 FALSE
@@ -349,6 +359,11 @@
/*===========================================================================*/
#elif defined(STM32F031x6) || defined(STM32F038xx)
+/* RCC attributes. */
+#define STM32_HAS_HSI48 FALSE
+#define STM32_HAS_HSI_PREDIV FALSE
+#define STM32_HAS_MCO_PREDIV TRUE
+
/* ADC attributes.*/
#define STM32_HAS_ADC1 TRUE
#define STM32_ADC_SUPPORTS_PRESCALER FALSE
@@ -553,6 +568,11 @@
/*===========================================================================*/
#elif defined(STM32F042x6)
+/* RCC attributes. */
+#define STM32_HAS_HSI48 TRUE
+#define STM32_HAS_HSI_PREDIV TRUE
+#define STM32_HAS_MCO_PREDIV TRUE
+
/* ADC attributes.*/
#define STM32_HAS_ADC1 TRUE
#define STM32_ADC_SUPPORTS_PRESCALER FALSE
@@ -767,6 +787,11 @@
/*===========================================================================*/
#elif defined(STM32F048xx)
+/* RCC attributes. */
+#define STM32_HAS_HSI48 TRUE
+#define STM32_HAS_HSI_PREDIV TRUE
+#define STM32_HAS_MCO_PREDIV TRUE
+
/* ADC attributes.*/
#define STM32_HAS_ADC1 TRUE
#define STM32_ADC_SUPPORTS_PRESCALER FALSE
@@ -985,6 +1010,11 @@
/*===========================================================================*/
#elif defined(STM32F051x8) || defined(STM32F058xx)
+/* RCC attributes. */
+#define STM32_HAS_HSI48 FALSE
+#define STM32_HAS_HSI_PREDIV FALSE
+#define STM32_HAS_MCO_PREDIV FALSE
+
/* ADC attributes.*/
#define STM32_HAS_ADC1 TRUE
#define STM32_ADC_SUPPORTS_PRESCALER FALSE
@@ -1219,6 +1249,11 @@
/* Common identifier of all STM32F070 devices.*/
#define STM32F070
+/* RCC attributes. */
+#define STM32_HAS_HSI48 FALSE
+#define STM32_HAS_HSI_PREDIV TRUE
+#define STM32_HAS_MCO_PREDIV TRUE
+
/* ADC attributes.*/
#define STM32_HAS_ADC1 TRUE
#define STM32_ADC_SUPPORTS_PRESCALER FALSE
@@ -1469,6 +1504,11 @@
/*===========================================================================*/
#elif defined(STM32F071xB) || defined(STM32F072xB) || \
defined(STM32F078xx)
+
+/* RCC attributes. */
+#define STM32_HAS_HSI48 TRUE
+#define STM32_HAS_HSI_PREDIV TRUE
+#define STM32_HAS_MCO_PREDIV TRUE
/* ADC attributes.*/
#define STM32_HAS_ADC1 TRUE
@@ -1733,6 +1773,11 @@
/*===========================================================================*/
#elif defined(STM32F091xC) || defined(STM32F098xx)
+/* RCC attributes. */
+#define STM32_HAS_HSI48 TRUE
+#define STM32_HAS_HSI_PREDIV TRUE
+#define STM32_HAS_MCO_PREDIV TRUE
+
/* ADC attributes.*/
#define STM32_HAS_ADC1 TRUE
#define STM32_ADC_SUPPORTS_PRESCALER FALSE
diff --git a/readme.txt b/readme.txt
index 9ef6bfa19..6a6b44956 100644
--- a/readme.txt
+++ b/readme.txt
@@ -153,6 +153,8 @@
- RT: Merged RT4.
- NIL: Merged NIL2.
- NIL: Added STM32F7 demo.
+- HAL: Fixed wrong clock init in STM32F0 port ad added more error checks
+ (bug #806)(backported to 16.1.6).
- HAL: Fixed misplaced else in STM32F0 port (bug #805)
(backported to 16.1.6).
- HAL: Fixed flash waiting state misconfiguration in STM32L4 port (bug #804)