MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / BURTC_DivToLog2

Function BURTC_DivToLog2

bsp/efm32/Libraries/emlib/src/em_burtc.c:65–76  ·  view source on GitHub ↗

/ * @brief Convert dividend to prescaler logarithmic value. Only works for even * numbers equal to 2^n * @param[in] div Unscaled dividend, * @return Base 2 logarithm of input, as used by fixed prescalers ******************************************************************************/

Source from the content-addressed store, hash-verified

63 * @return Base 2 logarithm of input, as used by fixed prescalers
64 ******************************************************************************/
65__STATIC_INLINE uint32_t BURTC_DivToLog2(uint32_t div)
66{
67 uint32_t log2;
68
69 /* Prescaler accepts an argument of 128 or less, valid values being 2^n */
70 EFM_ASSERT((div > 0) && (div <= 32768));
71
72 /* Count leading zeroes and "reverse" result, Cortex-M3 intrinsic */
73 log2 = (31 - __CLZ(div));
74
75 return log2;
76}
77
78
79/*******************************************************************************

Callers 1

BURTC_InitFunction · 0.85

Calls 1

__CLZFunction · 0.50

Tested by

no test coverage detected