text: #include "power.h"
  #include <drivers/board.h>
  #include <regs/regs.h>
  
  namespace Ion {
  namespace Device {
  namespace Power {
  
  using namespace Regs;
  
  void sleepConfiguration() {
    // Decrease HCLK frequency
    Board::setStandardFrequency(Device::Board::Frequency::Low);
  
  #if REGS_PWR_CONFIG_ADDITIONAL_FIELDS
    // Disable over-drive
    PWR.CR()->setODSWEN(false);
    while(!PWR.CSR()->getODSWRDY()) {
    }
    PWR.CR()->setODEN(true);
  #endif
  
    CORTEX.SCR()->setSLEEPDEEP(false);
  }
  
  void stopConfiguration() {
    PWR.CR()->setMRUDS(true); // Main regulator in Low Voltage and Flash memory in Deep Sleep mode when the device is in Stop mode
    PWR.CR()->setLPUDS(true); // Low-power regulator in under-drive mode if LPDS bit is set and Flash memory in power-down when the device is in Stop under-drive mode
    PWR.CR()->setLPDS(true); // Low-power Voltage regulator on. Takes longer to wake up.
    PWR.CR()->setFPDS(true); // Put the flash to sleep. Takes longer to wake up.
  
    CORTEX.SCR()->setSLEEPDEEP(true);
  }
  
  }
  }
  }
  