[DONE] Error in hal_lld.h on STM32L1XX
Posted: Wed Mar 12, 2014 8:13 pm
Hello!
I found a minor error (misprint in macro) in hal_lld.h while playing with LSE settings.
First: STM_RTCCLK is not referenced anywhere in the code, but STM32_RTCCLK does.
Second: This macro will trigger error when STM32_LSECLK = 0 and LSE is not used. NOTE that STM32_LSECLK is a user-defined macro, so it can get any value supplied by user (and in case of disabled LSE, STM32_LSECLK = 0 is a rationale value).
Third: The same issue with STM_RTCCLK misprint for LSI also.
Patch attached.
I found a minor error (misprint in macro) in hal_lld.h while playing with LSE settings.
Code: Select all
#else /* !STM32_LSE_ENABLED */
#if STM_RTCCLK == STM32_LSECLK
#error "required LSE clock is not enabled"
#endif
#endif /* !STM32_LSE_ENABLED */
First: STM_RTCCLK is not referenced anywhere in the code, but STM32_RTCCLK does.
Second: This macro will trigger error when STM32_LSECLK = 0 and LSE is not used. NOTE that STM32_LSECLK is a user-defined macro, so it can get any value supplied by user (and in case of disabled LSE, STM32_LSECLK = 0 is a rationale value).
Third: The same issue with STM_RTCCLK misprint for LSI also.
Patch attached.
Code: Select all
diff -Naur os.orig/hal/platforms/STM32L1xx/hal_lld.h os/hal/platforms/STM32L1xx/hal_lld.h
--- os.orig/hal/platforms/STM32L1xx/hal_lld.h 2014-01-06 09:45:32.000000000 +0200
+++ os/hal/platforms/STM32L1xx/hal_lld.h 2014-03-12 20:46:40.400860682 +0200
@@ -674,7 +674,7 @@
/* LSI related checks.*/
#if STM32_LSI_ENABLED
#else /* !STM32_LSI_ENABLED */
-#if STM_RTCCLK == STM32_LSICLK
+#if STM32_RTCCLK == STM32_LSICLK
#error "required LSI clock is not enabled"
#endif
#endif /* !STM32_LSI_ENABLED */
@@ -688,7 +688,7 @@
#error "STM32_LSECLK outside acceptable range (1...1000kHz)"
#endif
#else /* !STM32_LSE_ENABLED */
-#if STM_RTCCLK == STM32_LSECLK
+#if (STM32_RTCCLK == STM32_LSECLK) && (STM32_LSECLK != 0)
#error "required LSE clock is not enabled"
#endif
#endif /* !STM32_LSE_ENABLED */