emlib/src/em_emu.c
void EMU_VmonInit(const EMU_VmonInit_TypeDef *vmonInit)
{
  uint32_t thresholdCoarse, thresholdFine;
  uint32_t threshold;

  EFM_ASSERT((vmonInit->threshold >= 1620) && (vmonInit->threshold <= 3400));

  threshold = vmonCalibratedThreshold(vmonInit->channel, vmonInit->threshold);
  thresholdFine = threshold % 10;
  thresholdCoarse = threshold / 10;

  /* Saturate threshold to max values. */
  if (thresholdCoarse > 0xF) {
    thresholdCoarse = 0xF;
    thresholdFine = 9;
  }

  switch (vmonInit->channel) {
    case emuVmonChannel_AVDD:
      EMU->VMONAVDDCTRL = (thresholdCoarse << _EMU_VMONAVDDCTRL_RISETHRESCOARSE_SHIFT)
                          | (thresholdFine << _EMU_VMONAVDDCTRL_RISETHRESFINE_SHIFT)
                          | (thresholdCoarse << _EMU_VMONAVDDCTRL_FALLTHRESCOARSE_SHIFT)
                          | (thresholdFine << _EMU_VMONAVDDCTRL_FALLTHRESFINE_SHIFT)
                          | (vmonInit->riseWakeup ? EMU_VMONAVDDCTRL_RISEWU : 0)
                          | (vmonInit->fallWakeup ? EMU_VMONAVDDCTRL_FALLWU : 0)
                          | (vmonInit->enable     ? EMU_VMONAVDDCTRL_EN     : 0);
      break;
    case emuVmonChannel_ALTAVDD:
      EMU->VMONALTAVDDCTRL = (thresholdCoarse << _EMU_VMONALTAVDDCTRL_THRESCOARSE_SHIFT)
                             | (thresholdFine << _EMU_VMONALTAVDDCTRL_THRESFINE_SHIFT)
                             | (vmonInit->riseWakeup ? EMU_VMONALTAVDDCTRL_RISEWU : 0)
                             | (vmonInit->fallWakeup ? EMU_VMONALTAVDDCTRL_FALLWU : 0)
                             | (vmonInit->enable     ? EMU_VMONALTAVDDCTRL_EN     : 0);
      break;
    case emuVmonChannel_DVDD:
      EMU->VMONDVDDCTRL = (thresholdCoarse << _EMU_VMONDVDDCTRL_THRESCOARSE_SHIFT)
                          | (thresholdFine << _EMU_VMONDVDDCTRL_THRESFINE_SHIFT)
                          | (vmonInit->riseWakeup ? EMU_VMONDVDDCTRL_RISEWU : 0)
                          | (vmonInit->fallWakeup ? EMU_VMONDVDDCTRL_FALLWU : 0)
                          | (vmonInit->enable     ? EMU_VMONDVDDCTRL_EN     : 0);
      break;
    case emuVmonChannel_IOVDD0:
      EMU->VMONIO0CTRL = (thresholdCoarse << _EMU_VMONIO0CTRL_THRESCOARSE_SHIFT)
                         | (thresholdFine << _EMU_VMONIO0CTRL_THRESFINE_SHIFT)
                         | (vmonInit->retDisable ? EMU_VMONIO0CTRL_RETDIS : 0)
                         | (vmonInit->riseWakeup ? EMU_VMONIO0CTRL_RISEWU : 0)
                         | (vmonInit->fallWakeup ? EMU_VMONIO0CTRL_FALLWU : 0)
                         | (vmonInit->enable     ? EMU_VMONIO0CTRL_EN     : 0);
      break;
    default:
      EFM_ASSERT(false);
      return;
  }
}
/***************************************************************************/
/**
 * @brief
 *   Initialize VMON channel.
 *
 * @details
 *   Initialize a VMON channel without hysteresis. If the channel supports
 *   separate rise and fall triggers, both thresholds will be set to the same
 *   value. The threshold will be converted to a register field value based
 *   on calibration values from the DI page.
 *
 * @param[in] vmonInit
 *   VMON initialization struct
 ******************************************************************************/
@brief
Initialize VMON channel.

@details
Initialize a VMON channel without hysteresis. If the channel supports
separate rise and fall triggers, both thresholds will be set to the same
value. The threshold will be converted to a register field value based
on calibration values from the DI page.

@param[in] vmonInit
VMON initialization struct
@brief Initialize VMON channel . @details Initialize a VMON channel without hysteresis . If the channel supports separate rise and fall triggers both thresholds will be set to the same value . The threshold will be converted to a register field value based on calibration values from the DI page . @param [ in ] vmonInit VMON initialization struct
void EMU_VmonInit(const EMU_VmonInit_TypeDef *vmonInit)
{
  uint32_t thresholdCoarse, thresholdFine;
  uint32_t threshold;
  EFM_ASSERT((vmonInit->threshold >= 1620) && (vmonInit->threshold <= 3400));
  threshold = vmonCalibratedThreshold(vmonInit->channel, vmonInit->threshold);
  thresholdFine = threshold % 10;
  thresholdCoarse = threshold / 10;
  if (thresholdCoarse > 0xF) {
    thresholdCoarse = 0xF;
    thresholdFine = 9;
  }
  switch (vmonInit->channel) {
    case emuVmonChannel_AVDD:
      EMU->VMONAVDDCTRL = (thresholdCoarse << _EMU_VMONAVDDCTRL_RISETHRESCOARSE_SHIFT)
                          | (thresholdFine << _EMU_VMONAVDDCTRL_RISETHRESFINE_SHIFT)
                          | (thresholdCoarse << _EMU_VMONAVDDCTRL_FALLTHRESCOARSE_SHIFT)
                          | (thresholdFine << _EMU_VMONAVDDCTRL_FALLTHRESFINE_SHIFT)
                          | (vmonInit->riseWakeup ? EMU_VMONAVDDCTRL_RISEWU : 0)
                          | (vmonInit->fallWakeup ? EMU_VMONAVDDCTRL_FALLWU : 0)
                          | (vmonInit->enable     ? EMU_VMONAVDDCTRL_EN     : 0);
      break;
    case emuVmonChannel_ALTAVDD:
      EMU->VMONALTAVDDCTRL = (thresholdCoarse << _EMU_VMONALTAVDDCTRL_THRESCOARSE_SHIFT)
                             | (thresholdFine << _EMU_VMONALTAVDDCTRL_THRESFINE_SHIFT)
                             | (vmonInit->riseWakeup ? EMU_VMONALTAVDDCTRL_RISEWU : 0)
                             | (vmonInit->fallWakeup ? EMU_VMONALTAVDDCTRL_FALLWU : 0)
                             | (vmonInit->enable     ? EMU_VMONALTAVDDCTRL_EN     : 0);
      break;
    case emuVmonChannel_DVDD:
      EMU->VMONDVDDCTRL = (thresholdCoarse << _EMU_VMONDVDDCTRL_THRESCOARSE_SHIFT)
                          | (thresholdFine << _EMU_VMONDVDDCTRL_THRESFINE_SHIFT)
                          | (vmonInit->riseWakeup ? EMU_VMONDVDDCTRL_RISEWU : 0)
                          | (vmonInit->fallWakeup ? EMU_VMONDVDDCTRL_FALLWU : 0)
                          | (vmonInit->enable     ? EMU_VMONDVDDCTRL_EN     : 0);
      break;
    case emuVmonChannel_IOVDD0:
      EMU->VMONIO0CTRL = (thresholdCoarse << _EMU_VMONIO0CTRL_THRESCOARSE_SHIFT)
                         | (thresholdFine << _EMU_VMONIO0CTRL_THRESFINE_SHIFT)
                         | (vmonInit->retDisable ? EMU_VMONIO0CTRL_RETDIS : 0)
                         | (vmonInit->riseWakeup ? EMU_VMONIO0CTRL_RISEWU : 0)
                         | (vmonInit->fallWakeup ? EMU_VMONIO0CTRL_FALLWU : 0)
                         | (vmonInit->enable     ? EMU_VMONIO0CTRL_EN     : 0);
      break;
    default:
      EFM_ASSERT(false);
      return;
  }
}
void EMU_VmonInit ( const EMU_VmonInit_TypeDef * vmonInit ) { uint32_t thresholdCoarse , thresholdFine ; uint32_t threshold ; EFM_ASSERT ( ( vmonInit -> threshold >= 1620 ) && ( vmonInit -> threshold <= 3400 ) ) ; threshold = vmonCalibratedThreshold ( vmonInit -> channel , vmonInit -> threshold ) ; thresholdFine = threshold % 10 ; thresholdCoarse = threshold / 10 ; if ( thresholdCoarse > 0xF ) { thresholdCoarse = 0xF ; thresholdFine = 9 ; } switch ( vmonInit -> channel ) { case emuVmonChannel_AVDD : EMU -> VMONAVDDCTRL = ( thresholdCoarse << _EMU_VMONAVDDCTRL_RISETHRESCOARSE_SHIFT ) | ( thresholdFine << _EMU_VMONAVDDCTRL_RISETHRESFINE_SHIFT ) | ( thresholdCoarse << _EMU_VMONAVDDCTRL_FALLTHRESCOARSE_SHIFT ) | ( thresholdFine << _EMU_VMONAVDDCTRL_FALLTHRESFINE_SHIFT ) | ( vmonInit -> riseWakeup ? EMU_VMONAVDDCTRL_RISEWU : 0 ) | ( vmonInit -> fallWakeup ? EMU_VMONAVDDCTRL_FALLWU : 0 ) | ( vmonInit -> enable ? EMU_VMONAVDDCTRL_EN : 0 ) ; break ; case emuVmonChannel_ALTAVDD : EMU -> VMONALTAVDDCTRL = ( thresholdCoarse << _EMU_VMONALTAVDDCTRL_THRESCOARSE_SHIFT ) | ( thresholdFine << _EMU_VMONALTAVDDCTRL_THRESFINE_SHIFT ) | ( vmonInit -> riseWakeup ? EMU_VMONALTAVDDCTRL_RISEWU : 0 ) | ( vmonInit -> fallWakeup ? EMU_VMONALTAVDDCTRL_FALLWU : 0 ) | ( vmonInit -> enable ? EMU_VMONALTAVDDCTRL_EN : 0 ) ; break ; case emuVmonChannel_DVDD : EMU -> VMONDVDDCTRL = ( thresholdCoarse << _EMU_VMONDVDDCTRL_THRESCOARSE_SHIFT ) | ( thresholdFine << _EMU_VMONDVDDCTRL_THRESFINE_SHIFT ) | ( vmonInit -> riseWakeup ? EMU_VMONDVDDCTRL_RISEWU : 0 ) | ( vmonInit -> fallWakeup ? EMU_VMONDVDDCTRL_FALLWU : 0 ) | ( vmonInit -> enable ? EMU_VMONDVDDCTRL_EN : 0 ) ; break ; case emuVmonChannel_IOVDD0 : EMU -> VMONIO0CTRL = ( thresholdCoarse << _EMU_VMONIO0CTRL_THRESCOARSE_SHIFT ) | ( thresholdFine << _EMU_VMONIO0CTRL_THRESFINE_SHIFT ) | ( vmonInit -> retDisable ? EMU_VMONIO0CTRL_RETDIS : 0 ) | ( vmonInit -> riseWakeup ? EMU_VMONIO0CTRL_RISEWU : 0 ) | ( vmonInit -> fallWakeup ? EMU_VMONIO0CTRL_FALLWU : 0 ) | ( vmonInit -> enable ? EMU_VMONIO0CTRL_EN : 0 ) ; break ; default : EFM_ASSERT ( false ) ; return ; } }
@brief
   Initialize VMON channel.
@brief Initialize VMON channel .
/* Saturate threshold to max values. */