emlib/src/em_emu.c
static void vScaleDownEM23Setup(void)
{
  uint32_t hfSrcClockFrequency;

  EMU_VScaleEM23_TypeDef scaleEM23Voltage =
    (EMU_VScaleEM23_TypeDef)((EMU->CTRL & _EMU_CTRL_EM23VSCALE_MASK)
                             >> _EMU_CTRL_EM23VSCALE_SHIFT);

  EMU_VScaleEM01_TypeDef currentEM01Voltage =
    (EMU_VScaleEM01_TypeDef)((EMU->STATUS & _EMU_STATUS_VSCALE_MASK)
                             >> _EMU_STATUS_VSCALE_SHIFT);

  /* Wait until previous scaling is done. */
  EMU_VScaleWait();

  /* Inverse coding. */
  if ((uint32_t)scaleEM23Voltage > (uint32_t)currentEM01Voltage) {
    /* Set safe clock and wait-states. */
    if (scaleEM23Voltage == emuVScaleEM23_LowPower) {
      hfSrcClockFrequency = CMU_ClockDivGet(cmuClock_HF) * CMU_ClockFreqGet(cmuClock_HF);
      /* Set default low power voltage HFRCO band as HF clock. */
      if (hfSrcClockFrequency > CMU_VSCALEEM01_LOWPOWER_VOLTAGE_CLOCK_MAX) {
        CMU_HFRCOBandSet(cmuHFRCOFreq_19M0Hz);
      }
      CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);
    } else {
      /* Other voltage scaling levels are not currently supported. */
      EFM_ASSERT(false);
    }
  } else {
    /* Same voltage or hardware will scale to min(EMU_CTRL_EM23VSCALE, EMU_STATUS_VSCALE)  */
  }
}
/* Configure EMU and CMU for EM2 and 3 voltage downscale */
Configure EMU and CMU for EM2 and 3 voltage downscale
Configure EMU and CMU for EM2 and 3 voltage downscale
static void vScaleDownEM23Setup(void)
{
  uint32_t hfSrcClockFrequency;
  EMU_VScaleEM23_TypeDef scaleEM23Voltage =
    (EMU_VScaleEM23_TypeDef)((EMU->CTRL & _EMU_CTRL_EM23VSCALE_MASK)
                             >> _EMU_CTRL_EM23VSCALE_SHIFT);
  EMU_VScaleEM01_TypeDef currentEM01Voltage =
    (EMU_VScaleEM01_TypeDef)((EMU->STATUS & _EMU_STATUS_VSCALE_MASK)
                             >> _EMU_STATUS_VSCALE_SHIFT);
  EMU_VScaleWait();
  if ((uint32_t)scaleEM23Voltage > (uint32_t)currentEM01Voltage) {
    if (scaleEM23Voltage == emuVScaleEM23_LowPower) {
      hfSrcClockFrequency = CMU_ClockDivGet(cmuClock_HF) * CMU_ClockFreqGet(cmuClock_HF);
      if (hfSrcClockFrequency > CMU_VSCALEEM01_LOWPOWER_VOLTAGE_CLOCK_MAX) {
        CMU_HFRCOBandSet(cmuHFRCOFreq_19M0Hz);
      }
      CMU_ClockSelectSet(cmuClock_HF, cmuSelect_HFRCO);
    } else {
      EFM_ASSERT(false);
    }
  } else {
  }
}
static void vScaleDownEM23Setup ( void ) { uint32_t hfSrcClockFrequency ; EMU_VScaleEM23_TypeDef scaleEM23Voltage = ( EMU_VScaleEM23_TypeDef ) ( ( EMU -> CTRL & _EMU_CTRL_EM23VSCALE_MASK ) >> _EMU_CTRL_EM23VSCALE_SHIFT ) ; EMU_VScaleEM01_TypeDef currentEM01Voltage = ( EMU_VScaleEM01_TypeDef ) ( ( EMU -> STATUS & _EMU_STATUS_VSCALE_MASK ) >> _EMU_STATUS_VSCALE_SHIFT ) ; EMU_VScaleWait ( ) ; if ( ( uint32_t ) scaleEM23Voltage > ( uint32_t ) currentEM01Voltage ) { if ( scaleEM23Voltage == emuVScaleEM23_LowPower ) { hfSrcClockFrequency = CMU_ClockDivGet ( cmuClock_HF ) * CMU_ClockFreqGet ( cmuClock_HF ) ; if ( hfSrcClockFrequency > CMU_VSCALEEM01_LOWPOWER_VOLTAGE_CLOCK_MAX ) { CMU_HFRCOBandSet ( cmuHFRCOFreq_19M0Hz ) ; } CMU_ClockSelectSet ( cmuClock_HF , cmuSelect_HFRCO ) ; } else { EFM_ASSERT ( false ) ; } } else { } }
Configure EMU and CMU for EM2 and 3 voltage downscale
Configure EMU and CMU for EM2 and 3 voltage downscale
/* Wait until previous scaling is done. */ /* Inverse coding. */ /* Set safe clock and wait-states. */ /* Set default low power voltage HFRCO band as HF clock. */ /* Other voltage scaling levels are not currently supported. */ /* Same voltage or hardware will scale to min(EMU_CTRL_EM23VSCALE, EMU_STATUS_VSCALE)  */