| | |
| | | #include "system_general_para.h" |
| | | #include "main.h" |
| | | #include "extern_rtc.h" |
| | | #include "time.h" |
| | | |
| | | //uint8_t read_data_buf_A_l[200] ={0}; |
| | | //uint8_t read_data_buf_B_l[200] ={0}; |
| | |
| | | |
| | | __IO FlagStatus sys_run_period = RESET; // ϵͳ¼¤»îÖÜÆÚ |
| | | |
| | | SYS_DELAY_SEC_PARA_T sys_delay_sec_para_g = { .gprs_timeout_para.delay_flag = RESET, \ |
| | | .gprs_timeout_para.delay_time = 0, \ |
| | | SYS_DELAY_SEC_PARA_T sys_delay_sec_para_g = { .wrc_timeout_para.delay_flag = RESET, \ |
| | | .wrc_timeout_para.delay_time = 0, \ |
| | | .sys_active_time.delay_flag = RESET, \ |
| | | .sys_active_time.delay_time = SYS_WAKE_UP_TIME, \ |
| | | .sys_restart_delay_time.delay_flag = RESET, \ |
| | | .sys_restart_delay_time.delay_time = 180, \ |
| | | |
| | | }; |
| | | |
| | | FUN_START_CTRL_PARA_T sys_fun_run_ctrl_g; |
| | | |
| | | |
| | | /*******************³£ÓõĴúÂ빤¾ß********************************/ |
| | | /****************************************** |
| | |
| | | * output: none |
| | | * return: none |
| | | *****************************************/ |
| | | ErrorStatus ucharcmp(uint8_t *dataA,uint8_t *dataB,u16 data_length) |
| | | ErrorStatus ucharcmp(uint8_t *dataA,uint8_t *dataB,uint16_t data_length) |
| | | { |
| | | u16 index_i=0; |
| | | uint16_t index_i=0; |
| | | ErrorStatus return_flag=FAIL; |
| | | for(index_i=0;index_i<data_length;index_i++) |
| | | { |
| | |
| | | * output: none |
| | | * return: none |
| | | *****************************************/ |
| | | void arrayA_2_arrayB(uint8_t * aA , uint8_t * aB, u16 len, BIG_OR_LITTLE_ENDIAN mode) |
| | | void arrayA_2_arrayB(uint8_t * aA , uint8_t * aB, uint16_t len, BIG_OR_LITTLE_ENDIAN mode) |
| | | { |
| | | u16 index; |
| | | uint16_t index; |
| | | uint8_t *ptra,*ptrb; |
| | | |
| | | if(mode==LITTLE_ENDIAN) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /****************************************** |
| | | * func: IntervalTriggerHandle |
| | | * desc: ¼ä¸ô´¥·¢£¬Ö»¿¼ÂÇ1ÌìÄڵ쬼ä¸ôʱ³¤³¬¹ý1ÌìµÄ²»¿¼ÂÇ£¬±ÈÈç1ÌìÄڵļä¸ô60·ÖÖÓ´¥·¢Ò»´Î |
| | | * input: IntervalTime¼ä¸ôʱ¼ä£¬µ¥Î»·Ö ; IntervalFirstTimeBCDÊ×´Îʱ¼ä,ʱ£¬·Ö£¬Ê±ÔÚǰ |
| | | * output: FlagStatus SET±íʾÉúЧ |
| | | * return: none |
| | | *****************************************/ |
| | | FlagStatus IntervalTriggerHandle(sClockBCD sys_clockBCD_in,uint16_t IntervalTime,uint8_t *IntervalFirstTimeBCD) |
| | | { |
| | | //¼ä¸ôÉϱ¨ÔÝʱ²»¿¼ÂǼä¸ô³¬¹ý1440·ÖÖÓ£¬Ò²¾ÍÊdz¬¹ý1Ìì¡£ |
| | | uint16_t FirstTime; //Ê×´ÎÉϱ¨Ê±¼ä£¬ÕÛËã³É·ÖÖÓ |
| | | uint16_t NextTime; //Ï´ÎÉϱ¨Ê±¼ä£¬·ÖÖÓ |
| | | uint16_t CurrentTime;//µ±Ç°Ê±¼ä£¬ÕÛËã³É·ÖÖÓ |
| | | uint16_t Count_i=0; |
| | | uint16_t ComparisonsNumber; |
| | | |
| | | |
| | | if(IntervalTime==0) |
| | | { |
| | | return RESET; |
| | | } |
| | | |
| | | FirstTime = (uint16_t)BCD_2_DECIMAL(IntervalFirstTimeBCD[0]) * 60 + BCD_2_DECIMAL(IntervalFirstTimeBCD[1]); |
| | | |
| | | CurrentTime = (uint16_t)BCD_2_DECIMAL(sys_clockBCD_in.hour) *60 + BCD_2_DECIMAL(sys_clockBCD_in.min); |
| | | NextTime = FirstTime; |
| | | |
| | | ComparisonsNumber = (IntervalTime !=0)? 1440/IntervalTime +1 : 1; |
| | | |
| | | if(sys_clockBCD_in.sec == 0) //ΪÁ˼õÉÙ×ÊÔ´ÀË·Ñ£¬Ö»ÓÐÔÚÃëÖÓ=0ʱÅÐ¶Ï |
| | | { |
| | | for(Count_i =0;Count_i<ComparisonsNumber;Count_i++) |
| | | { |
| | | if(NextTime == CurrentTime ) |
| | | { |
| | | return SET; |
| | | } |
| | | else |
| | | { |
| | | NextTime = NextTime + IntervalTime; //Ï´ÎÉϱ¨Ê±¼äµã |
| | | if(NextTime>=1440) |
| | | { |
| | | NextTime -=1440; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return RESET; |
| | | } |
| | | |
| | | //IO¿ÚÑÓ³ÙÏû¶¶¼ì²â |
| | | FlagStatus IO_JitterEliminationCheck(GPIO_Type* GPIOx, uint32_t GPIO_Pin,uint16_t delay_time_ms,BitAction bit_status) |
| | | { |
| | | if(delay_time_ms>1000) //Ŀǰ×î´ó¼ì²â1000msÑÓʱ£¬Ì«´ó×îϵͳÔì³ÉÓ°Ïì |
| | | return RESET; |
| | | |
| | | if(GPIO_ReadInputDataBit(GPIOx, GPIO_Pin) == bit_status){ |
| | | if(delay_time_ms > 0) |
| | | delay_ms(delay_time_ms); |
| | | if(GPIO_ReadInputDataBit(GPIOx, GPIO_Pin) == bit_status){ |
| | | return SET; |
| | | }else{ |
| | | return RESET; |
| | | } |
| | | |
| | | }else{ |
| | | return RESET; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /****************************************** |
| | | * func: Time_Compare |
| | | * desc: Á½ÈÕÆÚ±È½Ï£¨²îÖµ£© |
| | | * input: |
| | | pDate1 ʱ¼ä1 BCD |
| | | pDate2 ʱ¼ä2 BCD |
| | | * output: none |
| | | * return: Á½Ê±¼ä²îÖµ ʱ¼ä1´óÓÚʱ¼ä2£¬·µ»ØÕýÊý£¬ÏàµÈ·µ»Ø0£¬Ð¡·µ»Ø¸ºÊý |
| | | *****************************************/ |
| | | int Datecmp(const uint8_t *pDate1, const uint8_t *pDate2) |
| | | { |
| | | uint16_t temp_year[2]; |
| | | time_t date_time1, date_time2; |
| | | struct tm date_tm1 = {0}, date_tm2 = {0}; |
| | | /*°ÑÄê·Ý²¹ÍêÕû Hex*/ |
| | | temp_year[0] = 2000 + BCD_2_DECIMAL(pDate1[0]); |
| | | temp_year[1] = 2000 + BCD_2_DECIMAL(pDate2[0]); |
| | | /*ʱ¼ä½á¹¹Ì帳ֵ*/ |
| | | date_tm1.tm_year = temp_year[0] - 1900; |
| | | date_tm1.tm_mon = BCD_2_DECIMAL(pDate1[1]) - 1; |
| | | date_tm1.tm_mday = BCD_2_DECIMAL(pDate1[2]); |
| | | date_tm1.tm_hour = BCD_2_DECIMAL(pDate1[3]); |
| | | date_tm1.tm_min = BCD_2_DECIMAL(pDate1[4]); |
| | | date_tm1.tm_sec = BCD_2_DECIMAL(pDate1[5]); |
| | | |
| | | date_tm2.tm_year = temp_year[1] - 1900; |
| | | date_tm2.tm_mon = BCD_2_DECIMAL(pDate2[1]) - 1; |
| | | date_tm2.tm_mday = BCD_2_DECIMAL(pDate2[2]); |
| | | date_tm2.tm_hour = BCD_2_DECIMAL(pDate2[3]); |
| | | date_tm2.tm_min = BCD_2_DECIMAL(pDate2[4]); |
| | | date_tm2.tm_sec = BCD_2_DECIMAL(pDate2[5]); |
| | | /*»ñµÃ´Ó1900Äê1ÔÂ1ÈÕ0ʱ0·Ö0ÃëÖÁ½ñµÄÃëÊý*/ |
| | | date_time1 = mktime(&date_tm1); |
| | | date_time2 = mktime(&date_tm2); |
| | | |
| | | // if (date_time1 > date_time2) |
| | | // { |
| | | // *diff_value = date_time1 - date_time2; |
| | | // return 1; |
| | | // } |
| | | // else if (date_time1 < date_time2) |
| | | // { |
| | | // *diff_value = date_time2 - date_time1; |
| | | // return -1; |
| | | // } |
| | | return (int)(date_time1 - date_time2); |
| | | } |
| | | |
| | | |
| | | |