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

Function CMU_OscillatorEnable

bsp/efm32/Libraries/emlib/src/em_cmu.c:1909–1977  ·  view source on GitHub ↗

/ * @brief * Enable/disable oscillator. * * @param[in] osc * The oscillator to enable/disable. * * @param[in] enable * @li true - enable specified oscillator. * @li false - disable specified oscillator. * * @param[in] wait * Only used if @p enable is true. * @li true - wait for oscillator start-up time to timeout before returning. * @li false - do not wait for oscillator

Source from the content-addressed store, hash-verified

1907 * returning.
1908 ******************************************************************************/
1909void CMU_OscillatorEnable(CMU_Osc_TypeDef osc, bool enable, bool wait)
1910{
1911 uint32_t status;
1912 uint32_t enBit;
1913 uint32_t disBit;
1914
1915 switch (osc)
1916 {
1917 case cmuOsc_HFRCO:
1918 enBit = CMU_OSCENCMD_HFRCOEN;
1919 disBit = CMU_OSCENCMD_HFRCODIS;
1920 status = CMU_STATUS_HFRCORDY;
1921 break;
1922
1923 case cmuOsc_HFXO:
1924 enBit = CMU_OSCENCMD_HFXOEN;
1925 disBit = CMU_OSCENCMD_HFXODIS;
1926 status = CMU_STATUS_HFXORDY;
1927 break;
1928
1929 case cmuOsc_AUXHFRCO:
1930 enBit = CMU_OSCENCMD_AUXHFRCOEN;
1931 disBit = CMU_OSCENCMD_AUXHFRCODIS;
1932 status = CMU_STATUS_AUXHFRCORDY;
1933 break;
1934
1935 case cmuOsc_LFRCO:
1936 enBit = CMU_OSCENCMD_LFRCOEN;
1937 disBit = CMU_OSCENCMD_LFRCODIS;
1938 status = CMU_STATUS_LFRCORDY;
1939 break;
1940
1941 case cmuOsc_LFXO:
1942 enBit = CMU_OSCENCMD_LFXOEN;
1943 disBit = CMU_OSCENCMD_LFXODIS;
1944 status = CMU_STATUS_LFXORDY;
1945 break;
1946
1947#if defined _CMU_LFCLKSEL_LFAE_ULFRCO
1948 case cmuOsc_ULFRCO:
1949 /* ULFRCO is always enabled, and cannot be turned off */
1950 return;
1951#endif
1952
1953 default:
1954 /* Undefined clock source */
1955 EFM_ASSERT(0);
1956 return;
1957 }
1958
1959 if (enable)
1960 {
1961 CMU->OSCENCMD = enBit;
1962
1963 /* Wait for clock to stabilize if requested */
1964 if (wait)
1965 {
1966 while (!(CMU->STATUS & status))

Callers 3

rt_hw_board_initFunction · 0.85
DBG_SWOEnableFunction · 0.85
CMU_ClockSelectSetFunction · 0.85

Calls 1

EMU_UpdateOscConfigFunction · 0.85

Tested by

no test coverage detected