| | |
| | | #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) |
| | | { |
| | | I2c_Scl_Gpio_Init(); |
| | | |
| | | InputtIO(EXT_RTC_INT_PORT,EXT_RTC_INT_PIN,IN_PULLUP); |
| | | InputtIO(EXT_RTC_INT_PORT,EXT_RTC_INT_PIN,IN_NORMAL); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | |