forked from SZV10X_Software/SZV103_FM33A0xxEV_SiZhu

jinlicong
2024-05-15 d14dd3a2106de793fbe08dc5a12cf80defd3258a
Function/EXTERN_RTC/extern_rtc.c
@@ -4,9 +4,8 @@
#include "gpio.h"
#include "system_general_para.h"
//__IO CALENDAR_TIME_T calendar_g = {0};
__IO sClockBCD sys_clockBCD_g = {24,1,1,0,0,0};
//__IO CALENDAR_TIME_T calendar_test_g = {0};
void RTC_GPIO_Init(void)
{
@@ -31,10 +30,31 @@
   
   if((yearDec>99)||(yearDec<20)||(monthDec>12)||(monthDec==0)||(dayDec>31)||(dayDec==0)||(hourDec>23)||(minDec>59)||(secDec>59))
   {
      //ËÑË÷ʱ¼äÎÞЧ
      //ʱ¼äÎÞЧ
      return FAIL;
   }else
   {
      switch(monthDec)
      {
         case 4:
         case 6:
         case 9:
         case 11:
            if(dayDec>30)
               return FAIL;
         case 2:
            if(((yearDec&0x3) != 0) && (dayDec>28)){
               return FAIL;
            }
            else if(((yearDec&0x3) == 0) && (dayDec > 29)){
               return FAIL;
            }
            break;
         default:
            break;
      }
      return PASS;
   }
}
@@ -157,7 +177,33 @@
      return PASS;
   }else
   {
      return FAIL;
      //ÔÙ¶ÁÒ»´Î
      R8025T_Read(0,rtc_time,7);
      calendar_l.year = rtc_time[6];
      calendar_l.month = rtc_time[5];
      calendar_l.day = rtc_time[4];
      calendar_l.hour = rtc_time[2];
      calendar_l.min = rtc_time[1];
      calendar_l.sec = rtc_time[0];
      if(TimeEffectJudgm(calendar_l)==PASS) //¶ÁÈ¡µÄʱ¼äÕýÈ·²Å²Ù×÷Ö¸Õë
      {
         calendar_p->sec = rtc_time[0];
         calendar_p->min = rtc_time[1];
         calendar_p->hour = rtc_time[2];
         calendar_p->day = rtc_time[4];
         calendar_p->month = rtc_time[5];
         calendar_p->year = rtc_time[6];
   #ifdef RS232_PRINTF
      printf("EX_RTC_TIME = %X-%02X-%02X-%02X-%02X-%02X \r\n",calendar_p->year,calendar_p->month,calendar_p->day,
                                                                                             calendar_p->hour,calendar_p->minute,calendar_p->second);
   #endif
         return PASS;
      }else
      {
         return FAIL;
      }
   }
}