/*
 * 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)
	{
      /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
    }
    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)
    {
      /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
    }
    RTC->ATIM0 = config->alarm.raw0;	
    RTC->ATIM1 = config->alarm.raw1;    
  }
  return XMC_RTC_STATUS_OK;
}
示例#2
0
文件: xmc_rtc.c 项目: BHTes16/ecarui
/*
 * Sets the RTC_TIM0, RTC_TIM1 registers with time values
 */
void XMC_RTC_SetTime(const XMC_RTC_TIME_t *const time)
{
  XMC_ASSERT("XMC_RTC_SetTime:Wrong seconds value", ((uint32_t)time->seconds < XMC_RTC_MAXSECONDS));
  XMC_ASSERT("XMC_RTC_SetTime:Wrong minutes value", ((uint32_t)time->minutes < XMC_RTC_MAXMINUTES));
  XMC_ASSERT("XMC_RTC_SetTime:Wrong hours value", ((uint32_t)time->hours < XMC_RTC_MAXHOURS));
  XMC_ASSERT("XMC_RTC_SetTime:Wrong month day value", ((uint32_t)time->days < XMC_RTC_MAXDAYS));
  XMC_ASSERT("XMC_RTC_SetTime:Wrong week day value", ((uint32_t)time->daysofweek < XMC_RTC_MAXDAYSOFWEEK));
  XMC_ASSERT("XMC_RTC_SetTime:Wrong month value", ((uint32_t)time->month < XMC_RTC_MAXMONTH));
  XMC_ASSERT("XMC_RTC_SetTime:Wrong year value", ((uint32_t)time->year < XMC_RTC_MAXYEAR));

  #if (XMC_RTC_INIT_SEQUENCE == 1U)
      while ((XMC_SCU_GetMirrorStatus() & SCU_GENERAL_MIRRSTS_RTC_TIM0_Msk) != 0U)
      { 
         /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
      }
      RTC->TIM0 = time->raw0;
      
      while ((XMC_SCU_GetMirrorStatus() & SCU_GENERAL_MIRRSTS_RTC_TIM1_Msk) != 0U)
      {
        /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
      }
      RTC->TIM1 = time->raw1;	     
  #endif
  #if (XMC_RTC_INIT_SEQUENCE == 0U)
      while ((XMC_SCU_GetMirrorStatus() & (SCU_GENERAL_MIRRSTS_RTC_TIM0_Msk | SCU_GENERAL_MIRRSTS_RTC_TIM1_Msk)) != 0U)
      {
        /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
      }
      RTC->TIM0 = time->raw0;
      RTC->TIM1 = time->raw1;	; 
  #endif  
}
示例#3
0
文件: xmc_rtc.c 项目: BHTes16/ecarui
/*
 * Sets the RTC module alarm time value
 */
void XMC_RTC_SetAlarm(const XMC_RTC_ALARM_t *const alarm)
{
  XMC_ASSERT("XMC_RTC_SetAlarm:Wrong seconds value", ((uint32_t)alarm->seconds < XMC_RTC_MAXSECONDS));
  XMC_ASSERT("XMC_RTC_SetAlarm:Wrong minutes value", ((uint32_t)alarm->minutes < XMC_RTC_MAXMINUTES));
  XMC_ASSERT("XMC_RTC_SetAlarm:Wrong hours value", ((uint32_t)alarm->hours < XMC_RTC_MAXHOURS));
  XMC_ASSERT("XMC_RTC_SetAlarm:Wrong days value", ((uint32_t)alarm->days < XMC_RTC_MAXDAYS));
  XMC_ASSERT("XMC_RTC_SetAlarm:Wrong month value", ((uint32_t)alarm->month < XMC_RTC_MAXMONTH));
  XMC_ASSERT("XMC_RTC_SetAlarm:Wrong year value", ((uint32_t)alarm->year < XMC_RTC_MAXYEAR));

  #if (XMC_RTC_INIT_SEQUENCE == 1U)
      while ((XMC_SCU_GetMirrorStatus() & SCU_GENERAL_MIRRSTS_RTC_ATIM0_Msk) != 0U)
      {
        /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
      }
      RTC->ATIM0 = alarm->raw0;
      
      while ((XMC_SCU_GetMirrorStatus() & SCU_GENERAL_MIRRSTS_RTC_ATIM1_Msk) != 0U)
      {
        /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
      }
      RTC->ATIM1 = alarm->raw1; 
  #endif
  #if (XMC_RTC_INIT_SEQUENCE == 0U)
      while ((XMC_SCU_GetMirrorStatus() & (SCU_GENERAL_MIRRSTS_RTC_ATIM0_Msk | SCU_GENERAL_MIRRSTS_RTC_ATIM1_Msk)) != 0U)
      {
        /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
      }
      RTC->ATIM0 = alarm->raw0;
      RTC->ATIM1 = alarm->raw1; 
  #endif  
}
示例#4
0
文件: xmc_rtc.c 项目: BHTes16/ecarui
/*
 * Enables RTC peripheral to start counting time
 */
void XMC_RTC_Start(void)
{
  while((XMC_SCU_GetMirrorStatus() & SCU_GENERAL_MIRRSTS_RTC_CTR_Msk) != 0U)
  {
    /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
  }
  RTC->CTR |= (uint32_t)RTC_CTR_ENB_Msk;
}
示例#5
0
文件: xmc_rtc.c 项目: BHTes16/ecarui
/*
 * Sets the RTC module prescaler value
 */
void XMC_RTC_SetPrescaler(uint16_t prescaler)
{
  XMC_ASSERT("XMC_RTC_SetPrescaler:Wrong prescaler value", (prescaler < XMC_RTC_MAXPRESCALER));
  
  while((XMC_SCU_GetMirrorStatus() & SCU_GENERAL_MIRRSTS_RTC_CTR_Msk) != 0U)
  {
    /* check SCU_MIRRSTS to ensure that no transfer over serial interface is pending */
  }
  RTC->CTR = (RTC->CTR & ~(uint32_t)RTC_CTR_DIV_Msk) |
             ((uint32_t)prescaler << (uint32_t)RTC_CTR_DIV_Pos);
}