emlib/src/em_emu.c
void EMU_VmonHystInit(const EMU_VmonHystInit_TypeDef *vmonInit)
{
  uint32_t riseThreshold;
  uint32_t fallThreshold;

  /* VMON supports voltages between 1620 mV and 3400 mV (inclusive) */
  EFM_ASSERT((vmonInit->riseThreshold >= 1620) && (vmonInit->riseThreshold <= 3400));
  EFM_ASSERT((vmonInit->fallThreshold >= 1620) && (vmonInit->fallThreshold <= 3400));
  /* Fall threshold has to be lower than rise threshold */
  EFM_ASSERT(vmonInit->fallThreshold <= vmonInit->riseThreshold);

  riseThreshold = vmonCalibratedThreshold(vmonInit->channel, vmonInit->riseThreshold);
  fallThreshold = vmonCalibratedThreshold(vmonInit->channel, vmonInit->fallThreshold);

  switch (vmonInit->channel) {
    case emuVmonChannel_AVDD:
      EMU->VMONAVDDCTRL = ((riseThreshold / 10) << _EMU_VMONAVDDCTRL_RISETHRESCOARSE_SHIFT)
                          | ((riseThreshold % 10) << _EMU_VMONAVDDCTRL_RISETHRESFINE_SHIFT)
                          | ((fallThreshold / 10) << _EMU_VMONAVDDCTRL_FALLTHRESCOARSE_SHIFT)
                          | ((fallThreshold % 10) << _EMU_VMONAVDDCTRL_FALLTHRESFINE_SHIFT)
                          | (vmonInit->riseWakeup ? EMU_VMONAVDDCTRL_RISEWU : 0)
                          | (vmonInit->fallWakeup ? EMU_VMONAVDDCTRL_FALLWU : 0)
                          | (vmonInit->enable     ? EMU_VMONAVDDCTRL_EN     : 0);
      break;
    default:
      EFM_ASSERT(false);
      return;
  }
}
/***************************************************************************/
/**
 * @brief
 *   Initialize VMON channel with hysteresis (separate rise and fall triggers).
 *
 * @details
 *   Initialize a VMON channel which supports hysteresis. The AVDD channel is
 *   the only channel to support separate rise and fall triggers. The rise and
 *   fall thresholds will be converted to a register field value based on
 *   calibration values from the DI page.
 *
 * @param[in] vmonInit
 *   VMON Hysteresis initialization struct
 ******************************************************************************/
@brief
Initialize VMON channel with hysteresis (separate rise and fall triggers).

@details
Initialize a VMON channel which supports hysteresis. The AVDD channel is
the only channel to support separate rise and fall triggers. The rise and
fall thresholds will be converted to a register field value based on
calibration values from the DI page.

@param[in] vmonInit
VMON Hysteresis initialization struct
@brief Initialize VMON channel with hysteresis ( separate rise and fall triggers ) . @details Initialize a VMON channel which supports hysteresis . The AVDD channel is the only channel to support separate rise and fall triggers . The rise and fall thresholds will be converted to a register field value based on calibration values from the DI page . @param [ in ] vmonInit VMON Hysteresis initialization struct
void EMU_VmonHystInit(const EMU_VmonHystInit_TypeDef *vmonInit)
{
  uint32_t riseThreshold;
  uint32_t fallThreshold;
  EFM_ASSERT((vmonInit->riseThreshold >= 1620) && (vmonInit->riseThreshold <= 3400));
  EFM_ASSERT((vmonInit->fallThreshold >= 1620) && (vmonInit->fallThreshold <= 3400));
  EFM_ASSERT(vmonInit->fallThreshold <= vmonInit->riseThreshold);
  riseThreshold = vmonCalibratedThreshold(vmonInit->channel, vmonInit->riseThreshold);
  fallThreshold = vmonCalibratedThreshold(vmonInit->channel, vmonInit->fallThreshold);
  switch (vmonInit->channel) {
    case emuVmonChannel_AVDD:
      EMU->VMONAVDDCTRL = ((riseThreshold / 10) << _EMU_VMONAVDDCTRL_RISETHRESCOARSE_SHIFT)
                          | ((riseThreshold % 10) << _EMU_VMONAVDDCTRL_RISETHRESFINE_SHIFT)
                          | ((fallThreshold / 10) << _EMU_VMONAVDDCTRL_FALLTHRESCOARSE_SHIFT)
                          | ((fallThreshold % 10) << _EMU_VMONAVDDCTRL_FALLTHRESFINE_SHIFT)
                          | (vmonInit->riseWakeup ? EMU_VMONAVDDCTRL_RISEWU : 0)
                          | (vmonInit->fallWakeup ? EMU_VMONAVDDCTRL_FALLWU : 0)
                          | (vmonInit->enable     ? EMU_VMONAVDDCTRL_EN     : 0);
      break;
    default:
      EFM_ASSERT(false);
      return;
  }
}
void EMU_VmonHystInit ( const EMU_VmonHystInit_TypeDef * vmonInit ) { uint32_t riseThreshold ; uint32_t fallThreshold ; EFM_ASSERT ( ( vmonInit -> riseThreshold >= 1620 ) && ( vmonInit -> riseThreshold <= 3400 ) ) ; EFM_ASSERT ( ( vmonInit -> fallThreshold >= 1620 ) && ( vmonInit -> fallThreshold <= 3400 ) ) ; EFM_ASSERT ( vmonInit -> fallThreshold <= vmonInit -> riseThreshold ) ; riseThreshold = vmonCalibratedThreshold ( vmonInit -> channel , vmonInit -> riseThreshold ) ; fallThreshold = vmonCalibratedThreshold ( vmonInit -> channel , vmonInit -> fallThreshold ) ; switch ( vmonInit -> channel ) { case emuVmonChannel_AVDD : EMU -> VMONAVDDCTRL = ( ( riseThreshold / 10 ) << _EMU_VMONAVDDCTRL_RISETHRESCOARSE_SHIFT ) | ( ( riseThreshold % 10 ) << _EMU_VMONAVDDCTRL_RISETHRESFINE_SHIFT ) | ( ( fallThreshold / 10 ) << _EMU_VMONAVDDCTRL_FALLTHRESCOARSE_SHIFT ) | ( ( fallThreshold % 10 ) << _EMU_VMONAVDDCTRL_FALLTHRESFINE_SHIFT ) | ( vmonInit -> riseWakeup ? EMU_VMONAVDDCTRL_RISEWU : 0 ) | ( vmonInit -> fallWakeup ? EMU_VMONAVDDCTRL_FALLWU : 0 ) | ( vmonInit -> enable ? EMU_VMONAVDDCTRL_EN : 0 ) ; break ; default : EFM_ASSERT ( false ) ; return ; } }
@brief
   Initialize VMON channel with hysteresis (separate rise and fall triggers).
@brief Initialize VMON channel with hysteresis ( separate rise and fall triggers ) .
/* VMON supports voltages between 1620 mV and 3400 mV (inclusive) */ /* Fall threshold has to be lower than rise threshold */