File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 35
35
*/
36
36
37
37
#include "rtc.h"
38
- #include <math.h>
39
38
40
39
#if defined(STM32_CORE_VERSION ) && (STM32_CORE_VERSION > 0x01090000 ) && \
41
40
defined(HAL_RTC_MODULE_ENABLED ) && !defined(HAL_RTC_MODULE_ONLY )
@@ -77,6 +76,11 @@ static void RTC_initClock(sourceClock_t source);
77
76
static void RTC_computePrediv (int8_t * asynch , int16_t * synch );
78
77
#endif /* !STM32F1xx */
79
78
79
+ static inline int _log2 (int x )
80
+ {
81
+ return (x > 0 ) ? (sizeof (int ) * 8 - __builtin_clz (x ) - 1 ) : 0 ;
82
+ }
83
+
80
84
/* Exported functions --------------------------------------------------------*/
81
85
82
86
/**
@@ -217,7 +221,7 @@ void RTC_setPrediv(int8_t asynch, int16_t synch)
217
221
} else {
218
222
RTC_computePrediv (& predivAsync , & predivSync );
219
223
}
220
- predivSync_bits = (uint8_t )log2 (predivSync ) + 1 ;
224
+ predivSync_bits = (uint8_t )_log2 (predivSync ) + 1 ;
221
225
#else
222
226
UNUSED (asynch );
223
227
UNUSED (synch );
@@ -241,7 +245,7 @@ void RTC_getPrediv(int8_t *asynch, int16_t *synch)
241
245
* asynch = predivAsync ;
242
246
* synch = predivSync ;
243
247
}
244
- predivSync_bits = (uint8_t )log2 (predivSync ) + 1 ;
248
+ predivSync_bits = (uint8_t )_log2 (predivSync ) + 1 ;
245
249
#else
246
250
UNUSED (asynch );
247
251
UNUSED (synch );
You can’t perform that action at this time.
0 commit comments