[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/include/rtc_timer.h b/ap/app/include/rtc_timer.h
new file mode 100755
index 0000000..3dbecf6
--- /dev/null
+++ b/ap/app/include/rtc_timer.h
@@ -0,0 +1,171 @@
+/**
+* @file rtc_timer.h
+* @brief Public APIs of Sanechips
+*
+* Copyright (C) 2017 Sanechips Technology Co., Ltd.
+* @author  Linxu Gebin
+* @defgroup si_id Sanechips
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 2 as
+* published by the Free Software Foundation.
+*************************************************************************
+*/
+
+#ifndef _RTC_TIMER_H
+#define _RTC_TIMER_H
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#include  <sys/time.h>
+#include "message.h"
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+******************************************************************************/
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+/**
+* @brief rtc message type
+* @note
+*/
+enum RTC_CPU {
+	RTC_CPU_CP = 0,   //rtcÓÉcp·¢Æð
+	RTC_CPU_AP,       //rtcÓÉAP·¢Æð
+};
+
+/**
+* @brief rtc type
+* @note
+*/
+typedef enum {
+	RTC_ID_START = 0,
+	WIFI_INTERVAL_SLEEP,
+	WIFI_PWR_SAVE,
+	WIFI_WAKE_UP_SYSTEM,
+	WIFI_WPS_RESULT_CHECK,
+	WIFI_TSW_SLEEP,
+	WIFI_TSW_WAKEUP,
+	WIFI_ACL_SERVICE,
+	WDT_TEMP_PROTECT,
+	RTC_SAFECARE_CONTIME,
+	RTC_SAFECARE_DELAY,
+	RTC_ID_FP_CLOCK,
+	RTC_ID_NOTDISTURB_BEGIN,
+	RTC_ID_NOTDISTURB_END,
+	RTC_ID_MMI_ALARM,
+	RTC_ID_MMI_CLOCK_MODE_CHECK,
+	RTC_ID_TRACK_BEGIN,
+	RTC_ID_TRACK_UPLOAD=RTC_ID_TRACK_BEGIN,
+	RTC_ID_TRACK_BASE,
+	RTC_ID_TRACK_SERVER_CON,
+	RTC_ID_TRACK_SLAVE_SERVER_CON,
+	RTC_ID_TRACK_SLAVE_SERVER_CMD,
+	RTC_ID_TRACK_DEBUG_SERVER_CON,
+	RTC_ID_TRACK_LINK,
+	RTC_ID_TRACK_LINK_TIMEOUT,
+	RTC_ID_TRACK_AGPS,
+	RTC_ID_TRACK_WEATHER_UPDATE,
+	RTC_ID_TRACK_END,
+	RTC_ID_END,
+} RTC_ID;
+#endif
+
+/**
+* @brief rtc ÏûÏ¢ÀàÐÍ
+* @param RTC_MSG_ALARM_ELAPSED µ±¶¨Ê±Æ÷´¥·¢Ê±»á·¢Õâ¸öÏûÏ¢¸ø¶¨Ê±Æ÷ÓµÓÐÕß
+* @param RTC_MSG_TIME_CHANGED RTCʱ¼ä¸üÐÂ:±íʾÊÀ½çʱ¼ä·¢Éú±ä»¯£¬¼´Ê±¼äͬ²½Íê³É»òÕßÓû§ÊÖ¶¯ÖØÐÂÉèÖõ±Ç°µÄÊÀ½çʱ¼äÁË£¬´ËʱRTC½ø³Ì»á¹ã²¥¸øÒÑ×¢²áÊÀ½çʱ¼äµÄÄ£¿é£¬ÒÔÈÃÏà¹ØÄ£¿é½øÐÐÊÀ½çʱ¼ä¶¨Ê±Æ÷µÄÖØÐÂÉèÖÃ
+* @note
+*/
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+enum RTC_MSG_CMD {
+	RTC_MSG_GET_TIME = MSG_CMD_RTC_BASE,	//»ñȡʱ¼ä£¬Ö±½Óµ÷ÓÃlinuxϵͳʱ¼ä½Ó¿Ú
+	RTC_MSG_SET_TIME,						//ÉèÖÃʱ¼ä
+	RTC_MSG_ADD_ALARM,						//Ìí¼Órtc¶¨Ê±Æ÷
+	RTC_MSG_DEL_ALARM,						//ɾ³ýrtc¶¨Ê±Æ÷
+	RTC_MSG_ALARM_TIMEOUT,					//RTC alarm¶¨Ê±Æ÷ʱ¼ä³¬Ê±
+	RTC_MSG_TIMER_TIMEOUT,					//RTC timer¶¨Ê±Æ÷ʱ¼ä³¬Ê±
+	RTC_MSG_ALARM_ELAPSED,					//µ±¶¨Ê±Æ÷´¥·¢Ê±»á·¢Õâ¸öÏûÏ¢¸ø¶¨Ê±Æ÷ÓµÓÐÕß
+	RTC_MSG_DEL_ALL,						//Çå³ýËùÓйػú²»±£´æµÄ¶¨Ê±Æ÷£¬·ñÔòrtc¶¨Ê±Æ÷µ½µã»¹»áÉϱ¨
+	RTC_MSG_TIME_CHANGED,					//RTCʱ¼ä¸üÐÂ:±íʾÊÀ½çʱ¼ä·¢Éú±ä»¯£¬¼´Ê±¼äͬ²½Íê³É»òÕßÓû§ÊÖ¶¯ÖØÐÂÉèÖõ±Ç°µÄÊÀ½çʱ¼äÁË£¬´ËʱRTC½ø³Ì»á¹ã²¥¸øÒÑ×¢²áÊÀ½çʱ¼äµÄÄ£¿é£¬ÒÔÈÃÏà¹ØÄ£¿é½øÐÐÊÀ½çʱ¼ä¶¨Ê±Æ÷µÄÖØÐÂÉèÖÃ
+};
+#endif
+
+/**
+* @brief rtc data buffer
+* @param srcModule ´´½¨¶¨Ê±Æ÷µÄÄ£¿é
+* @param module ¶¨Ê±Æ÷id
+* @param ulSec ¼ä¸ôʱ¼ä£¬µ¥Î»:s
+* @param time_val  µ±Ç°Ê±¼ä
+* @param wakeup   ¹Ø»ú»½ÐÑ£¬1:´ò¿ª£¬0:¹Ø±Õ
+* @param is_utc  ÊÇ·ñutcʱ¼ä£¬
+* @param cpu  rtc·¢ÆðµÄcpu£¬ 0: cp, 1:ap
+* @note utcʱ¼äÕý³£±È½Ï³¤£¬ÓÃWKALM¶¨Ê±Æ÷
+*/
+typedef struct tag_RTC_DATA_BUF {
+	int srcModule;
+	unsigned int   module;
+	unsigned long   ulSec;
+	unsigned long time_val;
+	int wakeup;
+	int is_utc;
+	int cpu;
+} RTC_DATA_BUF;
+
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+/**
+* @brief  Ìí¼Ó¶¨Ê±Æ÷
+* @param ulSec	¶¨Ê±Æ÷ʱ¼ä£¬µ¥Î»Ãë
+* @param rtc_id	¶¨Ê±Æ÷ID
+* @param src_id	´´½¨¶¨Ê±Æ÷µÄÄ£¿éID
+* @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1
+*/
+int rtc_timer_add(unsigned long ulSec, RTC_ID rtc_id, int src_id);
+
+/**
+* @brief Ìí¼Ó¶¨Ê±Æ÷
+* @param time	¶¨Ê±Æ÷ʱ¼ä£¬µ¥Î»ÊÀ½çʱÖÓ,ÐèÒªÌî: tm_sec/tm_min/tm_hour/tm_mday/tm_mon/tm_year
+* @param rtc_id	¶¨Ê±Æ÷ID£¬
+* @param src_id	´´½¨¶¨Ê±Æ÷µÄÄ£¿éID
+* @param wakeup	¹Ø»úÊÇ·ñ»½ÐÑ
+* @note wakeup	ÊÇ0²»»½ÐÑ, 1 »½ÐÑ
+* @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1
+*/
+int rtc_timer_add_utc(struct tm *time, RTC_ID rtc_id, int src_id, int wakeup);
+
+
+/**
+* @brief ɾ³ý¶¨Ê±Æ÷
+* @param rtc_id	¶¨Ê±Æ÷ID
+* @param src_id	´´½¨¶¨Ê±Æ÷µÄÄ£¿éID
+* @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1
+*/
+int rtc_timer_del(RTC_ID rtc_id, int src_id);
+
+
+/**
+* @brief ɾ³ýËùÓж¨Ê±Æ÷
+* @param src_id		ɾ³ý¶¨Ê±Æ÷µÄÄ£¿éID
+* @param req_cmd	»Ø¸´µÄÏûÏ¢cmd
+* @return ³É¹¦·µ»Ø0£¬Ê§°Ü·µ»Ø-1
+*/
+int rtc_timer_del_all(int src_id, unsigned short req_cmd);
+
+
+/**
+* @brief ÉèÖÃrtcµ±Ç°Ê±¼ä
+* @param src_id	ÉèÖÃʱ¼äµÄÄ£¿éID
+* @return ÉèÖÃrtcµ±Ç°Ê±¼ä
+*/
+int  rtc_set_time(int src_id);
+
+#endif
+
+