File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 3535 */
3636
3737#include "rtc.h"
38- #include <math.h>
3938
4039#if defined(STM32_CORE_VERSION ) && (STM32_CORE_VERSION > 0x01090000 ) && \
4140 defined(HAL_RTC_MODULE_ENABLED ) && !defined(HAL_RTC_MODULE_ONLY )
@@ -77,6 +76,11 @@ static void RTC_initClock(sourceClock_t source);
7776static void RTC_computePrediv (int8_t * asynch , int16_t * synch );
7877#endif /* !STM32F1xx */
7978
79+ static inline int _log2 (int x )
80+ {
81+ return (x > 0 ) ? (sizeof (int ) * 8 - __builtin_clz (x ) - 1 ) : 0 ;
82+ }
83+
8084/* Exported functions --------------------------------------------------------*/
8185
8286/**
@@ -217,7 +221,7 @@ void RTC_setPrediv(int8_t asynch, int16_t synch)
217221 } else {
218222 RTC_computePrediv (& predivAsync , & predivSync );
219223 }
220- predivSync_bits = (uint8_t )log2 (predivSync ) + 1 ;
224+ predivSync_bits = (uint8_t )_log2 (predivSync ) + 1 ;
221225#else
222226 UNUSED (asynch );
223227 UNUSED (synch );
@@ -241,7 +245,7 @@ void RTC_getPrediv(int8_t *asynch, int16_t *synch)
241245 * asynch = predivAsync ;
242246 * synch = predivSync ;
243247 }
244- predivSync_bits = (uint8_t )log2 (predivSync ) + 1 ;
248+ predivSync_bits = (uint8_t )_log2 (predivSync ) + 1 ;
245249#else
246250 UNUSED (asynch );
247251 UNUSED (synch );
You can’t perform that action at this time.
0 commit comments