/* Delays number of milliseconds in sleep mode (EM2) using the RTC but but returns if an event wakes up the MCU.  */
uint32_t UTIL_waitForEvent(uint32_t timeout)
/* Delays number of milliseconds in sleep mode (EM2) using the RTC but but returns if an event wakes up the MCU.  */
uint32_t UTIL_waitForEvent(uint32_t timeout)
{
   uint32_t remaining;
   rtcComplete = false;
   RTCDRV_StartTimer( rtcId, rtcdrvTimerTypeOneshot, timeout, rtcCb, 0 );
   EMU_EnterEM2( true );
   if( rtcComplete ){
      remaining = 0;
   }
   else {
      RTCDRV_TimeRemaining( rtcId, &remaining );
   }
   return remaining;
}