emlib/src/em_cmu.c
void CMU_LFXOInit(const CMU_LFXOInit_TypeDef *lfxoInit)
{
  /* Do not disable LFXO if it is currently selected as HF/Core clock */
  EFM_ASSERT(CMU_ClockSelectGet(cmuClock_HF) != cmuSelect_LFXO);

  /* LFXO must be disabled before reconfiguration */
  CMU_OscillatorEnable(cmuOsc_LFXO, false, false);

#if defined(_CMU_LFXOCTRL_MASK)
  BUS_RegMaskedWrite(&CMU->LFXOCTRL,
                     _CMU_LFXOCTRL_TUNING_MASK
                     | _CMU_LFXOCTRL_GAIN_MASK
                     | _CMU_LFXOCTRL_TIMEOUT_MASK
                     | _CMU_LFXOCTRL_MODE_MASK,
                     (lfxoInit->ctune << _CMU_LFXOCTRL_TUNING_SHIFT)
                     | (lfxoInit->gain << _CMU_LFXOCTRL_GAIN_SHIFT)
                     | (lfxoInit->timeout << _CMU_LFXOCTRL_TIMEOUT_SHIFT)
                     | (lfxoInit->mode << _CMU_LFXOCTRL_MODE_SHIFT));
#else
  bool cmuBoost  = (lfxoInit->boost & 0x2);
  BUS_RegMaskedWrite(&CMU->CTRL,
                     _CMU_CTRL_LFXOTIMEOUT_MASK
                     | _CMU_CTRL_LFXOBOOST_MASK
                     | _CMU_CTRL_LFXOMODE_MASK,
                     (lfxoInit->timeout << _CMU_CTRL_LFXOTIMEOUT_SHIFT)
                     | ((cmuBoost ? 1 : 0) << _CMU_CTRL_LFXOBOOST_SHIFT)
                     | (lfxoInit->mode << _CMU_CTRL_LFXOMODE_SHIFT));
#endif

#if defined(_EMU_AUXCTRL_REDLFXOBOOST_MASK)
  bool emuReduce = (lfxoInit->boost & 0x1);
  BUS_RegBitWrite(&EMU->AUXCTRL, _EMU_AUXCTRL_REDLFXOBOOST_SHIFT, emuReduce ? 1 : 0);
#endif
}
/**************************************************************************/
/**
 * @brief
 *   Set LFXO control registers
 *
 * @note
 *   LFXO configuration should be obtained from a configuration tool,
 *   app note or xtal datasheet. This function disables the LFXO to ensure
 *   a valid state before update.
 *
 * @param[in] lfxoInit
 *    LFXO setup parameters
 *****************************************************************************/
@brief
Set LFXO control registers

@note
LFXO configuration should be obtained from a configuration tool,
app note or xtal datasheet. This function disables the LFXO to ensure
a valid state before update.

@param[in] lfxoInit
LFXO setup parameters
@brief Set LFXO control registers @note LFXO configuration should be obtained from a configuration tool app note or xtal datasheet . This function disables the LFXO to ensure a valid state before update . @param [ in ] lfxoInit LFXO setup parameters
void CMU_LFXOInit(const CMU_LFXOInit_TypeDef *lfxoInit)
{
  EFM_ASSERT(CMU_ClockSelectGet(cmuClock_HF) != cmuSelect_LFXO);
  CMU_OscillatorEnable(cmuOsc_LFXO, false, false);
#if defined(_CMU_LFXOCTRL_MASK)
  BUS_RegMaskedWrite(&CMU->LFXOCTRL,
                     _CMU_LFXOCTRL_TUNING_MASK
                     | _CMU_LFXOCTRL_GAIN_MASK
                     | _CMU_LFXOCTRL_TIMEOUT_MASK
                     | _CMU_LFXOCTRL_MODE_MASK,
                     (lfxoInit->ctune << _CMU_LFXOCTRL_TUNING_SHIFT)
                     | (lfxoInit->gain << _CMU_LFXOCTRL_GAIN_SHIFT)
                     | (lfxoInit->timeout << _CMU_LFXOCTRL_TIMEOUT_SHIFT)
                     | (lfxoInit->mode << _CMU_LFXOCTRL_MODE_SHIFT));
#else
  bool cmuBoost  = (lfxoInit->boost & 0x2);
  BUS_RegMaskedWrite(&CMU->CTRL,
                     _CMU_CTRL_LFXOTIMEOUT_MASK
                     | _CMU_CTRL_LFXOBOOST_MASK
                     | _CMU_CTRL_LFXOMODE_MASK,
                     (lfxoInit->timeout << _CMU_CTRL_LFXOTIMEOUT_SHIFT)
                     | ((cmuBoost ? 1 : 0) << _CMU_CTRL_LFXOBOOST_SHIFT)
                     | (lfxoInit->mode << _CMU_CTRL_LFXOMODE_SHIFT));
#endif
#if defined(_EMU_AUXCTRL_REDLFXOBOOST_MASK)
  bool emuReduce = (lfxoInit->boost & 0x1);
  BUS_RegBitWrite(&EMU->AUXCTRL, _EMU_AUXCTRL_REDLFXOBOOST_SHIFT, emuReduce ? 1 : 0);
#endif
}
void CMU_LFXOInit ( const CMU_LFXOInit_TypeDef * lfxoInit ) { EFM_ASSERT ( CMU_ClockSelectGet ( cmuClock_HF ) != cmuSelect_LFXO ) ; CMU_OscillatorEnable ( cmuOsc_LFXO , false , false ) ; #if defined ( _CMU_LFXOCTRL_MASK ) BUS_RegMaskedWrite ( & CMU -> LFXOCTRL , _CMU_LFXOCTRL_TUNING_MASK | _CMU_LFXOCTRL_GAIN_MASK | _CMU_LFXOCTRL_TIMEOUT_MASK | _CMU_LFXOCTRL_MODE_MASK , ( lfxoInit -> ctune << _CMU_LFXOCTRL_TUNING_SHIFT ) | ( lfxoInit -> gain << _CMU_LFXOCTRL_GAIN_SHIFT ) | ( lfxoInit -> timeout << _CMU_LFXOCTRL_TIMEOUT_SHIFT ) | ( lfxoInit -> mode << _CMU_LFXOCTRL_MODE_SHIFT ) ) ; #else bool cmuBoost = ( lfxoInit -> boost & 0x2 ) ; BUS_RegMaskedWrite ( & CMU -> CTRL , _CMU_CTRL_LFXOTIMEOUT_MASK | _CMU_CTRL_LFXOBOOST_MASK | _CMU_CTRL_LFXOMODE_MASK , ( lfxoInit -> timeout << _CMU_CTRL_LFXOTIMEOUT_SHIFT ) | ( ( cmuBoost ? 1 : 0 ) << _CMU_CTRL_LFXOBOOST_SHIFT ) | ( lfxoInit -> mode << _CMU_CTRL_LFXOMODE_SHIFT ) ) ; #endif #if defined ( _EMU_AUXCTRL_REDLFXOBOOST_MASK ) bool emuReduce = ( lfxoInit -> boost & 0x1 ) ; BUS_RegBitWrite ( & EMU -> AUXCTRL , _EMU_AUXCTRL_REDLFXOBOOST_SHIFT , emuReduce ? 1 : 0 ) ; #endif }
@brief
   Set LFXO control registers
@brief Set LFXO control registers
/* Do not disable LFXO if it is currently selected as HF/Core clock */ /* LFXO must be disabled before reconfiguration */