[DONE] Error in hal_lld.h on STM32L1XX

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
daemon
Posts: 35
Joined: Tue Oct 09, 2012 1:53 pm

[DONE] Error in hal_lld.h on STM32L1XX

Post by daemon »

Hello!
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 */
Attachments
rtc.patch.gz
(364 Bytes) Downloaded 322 times
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [TODO] Error in hal_lld.h on STM32L1XX

Post by Giovanni »

Hi,

Thanks, added to the TODO list.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: [TODO] Error in hal_lld.h on STM32L1XX

Post by Giovanni »

Fixed as bug #476.

Giovanni
Post Reply