/* Configures the appropriate peripherals and puts the MCU in sleep mode.  */
void PMU_Sleep(uint32_t SleepMode, uint32_t SleepCtrl)
/* Configures the appropriate peripherals and puts the MCU in sleep mode.  */
void PMU_Sleep(uint32_t SleepMode, uint32_t SleepCtrl)
{
  LPC_SYSCON->PDAWAKECFG = LPC_SYSCON->PDRUNCFG;
  LPC_SYSCON->PDSLEEPCFG = SleepCtrl;
  switch ( SleepMode )
  {
    case MCU_POWER_DOWN:
      SCB->SCR |= NVIC_LP_SLEEPDEEP;
      LPC_PMU->PCON = 0x2;
      break;
    case MCU_DEEP_SLEEP:
      SCB->SCR |= NVIC_LP_SLEEPDEEP;
      LPC_PMU->PCON = 0x1;
      break;
    case MCU_SLEEP:
    default:
      break;
  }
  __WFI();
  return;
}