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

Function CMU_DivToLog2

bsp/efm32/Libraries/emlib/src/em_cmu.c:119–130  ·  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

117 * @return Base 2 logarithm of input, as used by fixed prescalers
118 ******************************************************************************/
119__STATIC_INLINE uint32_t CMU_DivToLog2(CMU_ClkDiv_TypeDef div)
120{
121 uint32_t log2;
122
123 /* Prescalers take argument of 32768 or less */
124 EFM_ASSERT((div>0) && (div <= 32768));
125
126 /* Count leading zeroes and "reverse" result, Cortex-M3 intrinsic */
127 log2 = (31 - __CLZ(div));
128
129 return log2;
130}
131
132
133/***************************************************************************//**

Callers 1

CMU_ClockDivSetFunction · 0.85

Calls 1

__CLZFunction · 0.50

Tested by

no test coverage detected