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

Function I2C_BusFreqGet

bsp/efm32/Libraries/emlib/src/em_i2c.c:158–168  ·  view source on GitHub ↗

/ * @brief * Get current configured I2C bus frequency. * * @details * This frequency is only of relevance when acting as master. * * @param[in] i2c * Pointer to I2C peripheral register block. * * @return * Current I2C frequency in Hz. ******************************************************************************/

Source from the content-addressed store, hash-verified

156 * Current I2C frequency in Hz.
157 ******************************************************************************/
158uint32_t I2C_BusFreqGet(I2C_TypeDef *i2c)
159{
160 uint32_t hfperclk;
161 uint32_t n;
162
163 /* Max frequency is given by fSCL = fHFPERCLK/((Nlow + Nhigh)(DIV + 1) + 4) */
164 hfperclk = CMU_ClockFreqGet(cmuClock_HFPER);
165 n = (uint32_t)(i2cNSum[(i2c->CTRL & _I2C_CTRL_CLHR_MASK) >> _I2C_CTRL_CLHR_SHIFT]);
166
167 return(hfperclk / ((n * (i2c->CLKDIV + 1)) + 4));
168}
169
170
171/***************************************************************************//**

Callers

nothing calls this directly

Calls 1

CMU_ClockFreqGetFunction · 0.85

Tested by

no test coverage detected