/* RTC driver for XMC microcontroller family. 
Initialize the RTC peripheral  */
XMC_RTC_STATUS_t XMC_RTC_Init(const XMC_RTC_CONFIG_t *const config)
/* RTC driver for XMC microcontroller family. 
Initialize the RTC peripheral  */
XMC_RTC_STATUS_t XMC_RTC_Init(const XMC_RTC_CONFIG_t *const config)
{
  if (XMC_RTC_IsRunning() == false)
  {
    if (XMC_RTC_IsEnabled() == false)
    {
      XMC_RTC_Enable();
	}
    XMC_RTC_SetPrescaler(config->prescaler);
	while ((XMC_SCU_GetMirrorStatus() & (SCU_GENERAL_MIRRSTS_RTC_TIM0_Msk | SCU_GENERAL_MIRRSTS_RTC_TIM1_Msk)) != 0U)
	{
    }
    RTC->TIM0 = config->time.raw0;
    RTC->TIM1 = config->time.raw1;
    while ((XMC_SCU_GetMirrorStatus() & (SCU_GENERAL_MIRRSTS_RTC_ATIM0_Msk | SCU_GENERAL_MIRRSTS_RTC_ATIM1_Msk)) != 0U)
    {
    }
    RTC->ATIM0 = config->alarm.raw0;    RTC->ATIM1 = config->alarm.raw1;    
  }
  return XMC_RTC_STATUS_OK;
}