emlib/src/em_emu.c
void EMU_EM4Init(const EMU_EM4Init_TypeDef *em4Init)
{
#if defined(_EMU_EM4CONF_MASK)
  /* Init for platforms with EMU->EM4CONF register */
  uint32_t em4conf = EMU->EM4CONF;

  /* Clear fields that will be reconfigured */
  em4conf &= ~(_EMU_EM4CONF_LOCKCONF_MASK
               | _EMU_EM4CONF_OSC_MASK
               | _EMU_EM4CONF_BURTCWU_MASK
               | _EMU_EM4CONF_VREGEN_MASK);

  /* Configure new settings */
  em4conf |= (em4Init->lockConfig << _EMU_EM4CONF_LOCKCONF_SHIFT)
             | (em4Init->osc)
             | (em4Init->buRtcWakeup << _EMU_EM4CONF_BURTCWU_SHIFT)
             | (em4Init->vreg << _EMU_EM4CONF_VREGEN_SHIFT);

  /* Apply configuration. Note that lock can be set after this stage. */
  EMU->EM4CONF = em4conf;

#elif defined(_EMU_EM4CTRL_MASK)
  /* Init for platforms with EMU->EM4CTRL register */

  uint32_t em4ctrl = EMU->EM4CTRL;

  em4ctrl &= ~(_EMU_EM4CTRL_RETAINLFXO_MASK
               | _EMU_EM4CTRL_RETAINLFRCO_MASK
               | _EMU_EM4CTRL_RETAINULFRCO_MASK
               | _EMU_EM4CTRL_EM4STATE_MASK
               | _EMU_EM4CTRL_EM4IORETMODE_MASK);

  em4ctrl |= (em4Init->retainLfxo     ? EMU_EM4CTRL_RETAINLFXO : 0)
             | (em4Init->retainLfrco  ? EMU_EM4CTRL_RETAINLFRCO : 0)
             | (em4Init->retainUlfrco ? EMU_EM4CTRL_RETAINULFRCO : 0)
             | (em4Init->em4State     ? EMU_EM4CTRL_EM4STATE_EM4H : 0)
             | (em4Init->pinRetentionMode);

  EMU->EM4CTRL = em4ctrl;
#endif

#if defined(_EMU_CTRL_EM4HVSCALE_MASK)
  EMU->CTRL = (EMU->CTRL & ~_EMU_CTRL_EM4HVSCALE_MASK)
              | (em4Init->vScaleEM4HVoltage << _EMU_CTRL_EM4HVSCALE_SHIFT);
#endif
}
/***************************************************************************/
/**
 * @brief
 *   Update EMU module with Energy Mode 4 configuration
 *
 * @param[in] em4Init
 *    Energy Mode 4 configuration structure
 ******************************************************************************/
@brief
Update EMU module with Energy Mode 4 configuration

@param[in] em4Init
Energy Mode 4 configuration structure
@brief Update EMU module with Energy Mode 4 configuration @param [ in ] em4Init Energy Mode 4 configuration structure
void EMU_EM4Init(const EMU_EM4Init_TypeDef *em4Init)
{
#if defined(_EMU_EM4CONF_MASK)
  uint32_t em4conf = EMU->EM4CONF;
  em4conf &= ~(_EMU_EM4CONF_LOCKCONF_MASK
               | _EMU_EM4CONF_OSC_MASK
               | _EMU_EM4CONF_BURTCWU_MASK
               | _EMU_EM4CONF_VREGEN_MASK);
  em4conf |= (em4Init->lockConfig << _EMU_EM4CONF_LOCKCONF_SHIFT)
             | (em4Init->osc)
             | (em4Init->buRtcWakeup << _EMU_EM4CONF_BURTCWU_SHIFT)
             | (em4Init->vreg << _EMU_EM4CONF_VREGEN_SHIFT);
  EMU->EM4CONF = em4conf;
#elif defined(_EMU_EM4CTRL_MASK)
  uint32_t em4ctrl = EMU->EM4CTRL;
  em4ctrl &= ~(_EMU_EM4CTRL_RETAINLFXO_MASK
               | _EMU_EM4CTRL_RETAINLFRCO_MASK
               | _EMU_EM4CTRL_RETAINULFRCO_MASK
               | _EMU_EM4CTRL_EM4STATE_MASK
               | _EMU_EM4CTRL_EM4IORETMODE_MASK);
  em4ctrl |= (em4Init->retainLfxo     ? EMU_EM4CTRL_RETAINLFXO : 0)
             | (em4Init->retainLfrco  ? EMU_EM4CTRL_RETAINLFRCO : 0)
             | (em4Init->retainUlfrco ? EMU_EM4CTRL_RETAINULFRCO : 0)
             | (em4Init->em4State     ? EMU_EM4CTRL_EM4STATE_EM4H : 0)
             | (em4Init->pinRetentionMode);
  EMU->EM4CTRL = em4ctrl;
#endif
#if defined(_EMU_CTRL_EM4HVSCALE_MASK)
  EMU->CTRL = (EMU->CTRL & ~_EMU_CTRL_EM4HVSCALE_MASK)
              | (em4Init->vScaleEM4HVoltage << _EMU_CTRL_EM4HVSCALE_SHIFT);
#endif
}
void EMU_EM4Init ( const EMU_EM4Init_TypeDef * em4Init ) { #if defined ( _EMU_EM4CONF_MASK ) uint32_t em4conf = EMU -> EM4CONF ; em4conf &= ~ ( _EMU_EM4CONF_LOCKCONF_MASK | _EMU_EM4CONF_OSC_MASK | _EMU_EM4CONF_BURTCWU_MASK | _EMU_EM4CONF_VREGEN_MASK ) ; em4conf |= ( em4Init -> lockConfig << _EMU_EM4CONF_LOCKCONF_SHIFT ) | ( em4Init -> osc ) | ( em4Init -> buRtcWakeup << _EMU_EM4CONF_BURTCWU_SHIFT ) | ( em4Init -> vreg << _EMU_EM4CONF_VREGEN_SHIFT ) ; EMU -> EM4CONF = em4conf ; #elif defined ( _EMU_EM4CTRL_MASK ) uint32_t em4ctrl = EMU -> EM4CTRL ; em4ctrl &= ~ ( _EMU_EM4CTRL_RETAINLFXO_MASK | _EMU_EM4CTRL_RETAINLFRCO_MASK | _EMU_EM4CTRL_RETAINULFRCO_MASK | _EMU_EM4CTRL_EM4STATE_MASK | _EMU_EM4CTRL_EM4IORETMODE_MASK ) ; em4ctrl |= ( em4Init -> retainLfxo ? EMU_EM4CTRL_RETAINLFXO : 0 ) | ( em4Init -> retainLfrco ? EMU_EM4CTRL_RETAINLFRCO : 0 ) | ( em4Init -> retainUlfrco ? EMU_EM4CTRL_RETAINULFRCO : 0 ) | ( em4Init -> em4State ? EMU_EM4CTRL_EM4STATE_EM4H : 0 ) | ( em4Init -> pinRetentionMode ) ; EMU -> EM4CTRL = em4ctrl ; #endif #if defined ( _EMU_CTRL_EM4HVSCALE_MASK ) EMU -> CTRL = ( EMU -> CTRL & ~ _EMU_CTRL_EM4HVSCALE_MASK ) | ( em4Init -> vScaleEM4HVoltage << _EMU_CTRL_EM4HVSCALE_SHIFT ) ; #endif }
@brief
   Update EMU module with Energy Mode 4 configuration
@brief Update EMU module with Energy Mode 4 configuration
/* Init for platforms with EMU->EM4CONF register */ /* Clear fields that will be reconfigured */ /* Configure new settings */ /* Apply configuration. Note that lock can be set after this stage. */ /* Init for platforms with EMU->EM4CTRL register */