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

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/app/include/soft_timer.h b/ap/app/include/soft_timer.h
new file mode 100755
index 0000000..447e3b3
--- /dev/null
+++ b/ap/app/include/soft_timer.h
@@ -0,0 +1,169 @@
+/**
+ * @file soft_timer.h
+ * @brief Èí¶¨Ê±Æ÷Í·Îļþ
+ *
+ * Copyright (C) 2017 Sanechips Technology Co., Ltd.
+ *
+ */
+
+#ifndef _SOFT_TIMER_H_
+#define _SOFT_TIMER_H_
+
+/*******************************************************************************
+ *                           Include header files                              *
+ ******************************************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "message.h"
+#include "os_type_def.h"
+
+
+/*******************************************************************************
+ *                             Macro definitions                               *
+ ******************************************************************************/
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷µÄ×î´ó¸öÊý
+ */
+#define MAX_SOFT_TIMER_NUM 32
+
+/**
+ * @brief ¶¨Ê±Æ÷ÀàÐͱê־λucFlagµÄºê,´Ë¶¨Ê±Æ÷Ö»´¥·¢Ò»´Î
+ */
+#define TIMER_FLAG_ONCE  0
+
+/**
+ * @brief ¶¨Ê±Æ÷ÀàÐͱê־λucFlagµÄºê,´Ë¶¨Ê±Æ÷³ÖÐøÓÐЧ
+ */
+#define TIMER_FLAG_RESTART 1
+
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷´íÎóÂ붨Ò壬»Øµ÷º¯ÊýΪ¿Õ
+ */
+#define SOFTTIMER_ERRCODE_CALLBACK_NULL 1
+
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷´íÎóÂ붨Ò壬³õʼ»¯Ê§°Ü
+ */
+#define SOFTTIMER_ERRCODE_INIT_FAIL 	2
+
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷´íÎóÂ붨Ò壬´´½¨µÄÈí¶¨Ê±Æ÷³¬¹ý×î´ó¸öÊý
+ */
+#define SOFTTIMER_ERRCODE_QUEUE_FULL 	3
+
+/**
+ * @brief Èí¼þ¶¨Ê±Æ÷´íÎóÂ붨Ò壬´´½¨µÄÈí¶¨Ê±Æ÷idÒѾ­´æÔÚ
+ */
+#define SOFTTIMER_ERRCODE_TIMERID_EXIST 4
+
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/**
+ * @brief Ó²¼þ¶¨Ê±Æ÷µÄ²½³¤£¬10ms
+ */
+#define TIMER_STEP 10
+
+/*if the thread of soft timer is exist, 0 means not exist*/
+#define   SOFT_TIMER_THREAD_NULL  0
+#define   SOFT_TIMER_THREAD_EXIST  1
+
+#endif//#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+
+/*******************************************************************************
+ *                             Type definitions                                *
+ ******************************************************************************/
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/*¶¨ÒåÈí¼þ¶¨Ê±Æ÷µÄÊý¾Ý½á¹¹*/
+typedef struct tagSOFT_TIMER {
+	struct tagSOFT_TIMER *prev;
+	struct tagSOFT_TIMER *next;
+	int used;
+	int done;
+	int timerValue;
+
+	USHORT usTimerID;      /*¶¨Ê±Æ÷ID,ÓÃÀ´Çø·Ö²»Í¬µÄÈí¼þ¶¨Ê±Æ÷, 0±êʶ*/
+	UCHAR  ucFlag;         /*¶¨Ê±Æ÷ÀàÐͱê־λ*/
+	UCHAR  ucReserved;     /*±£Áô×Ö¶Î*/
+	ULONG  ulCurInterval;   /*µ±Ç°¶¨Ê±Æ÷³¬Ê±Ê£Óàʱ¼ä£¬µ¥Î» ºÁÃë(×¢Òâ²»ÊÇ΢Ãë)£¬±ØÐ붨ÒåΪӲ¼þ¶¨Ê±Æ÷²½³¤µÄ±¶Êý*/
+	ULONG  ulNextInterval;  /*³¬Ê±ºó¶¨Ê±Æ÷ÖØÖõļä¸ô£¬µ¥Î» ºÁÃë(×¢Òâ²»ÊÇ΢Ãë)*/
+	void * (*procCallBack)(void *); /*¶¨Ò嶨ʱÆ÷³¬Ê±ºóµÄ»Øµ÷´¦Àíº¯ÊýÖ¸Õë*/
+	void   *args;                /*¶¨Ò嶨ʱÆ÷³¬Ê±ºóµÄ»Øµ÷´¦Àíº¯ÊýµÄ²ÎÊý*/
+} SOFT_TIMER;
+
+typedef struct tagMSG_TIMERBUF {
+	LONG   lMsgType;        /*ÏûÏ¢ÀàÐÍ£¬Õâ¸öÊÇÓÃÀ´¿ØÖÆÏûÏ¢ÊÕÈ¡µÄÓÅÏÈ˳ÐòµÄ*/
+	USHORT usMsgCmd;        /*ÏûÏ¢Â룬Õâ¸öÊÇÓÃÀ´Ö¸Ê¾ÏûÏ¢µÄÄÚÈÝÊÇʲôµÄ*/
+	USHORT usDataLen;       /*Я´øµÄÓÐЧÊý¾Ý³¤¶È*/
+	UCHAR  aucDataBuf[4];   /*Я´øµÄÓÐЧÊý¾Ýbuffer,´æ·Å¶¨Ê±Æ÷index*/
+	ULONG  ulMagic;         /*ħÊõ×Ö£¬Õý³£Çé¿öÏÂֵΪMSG_MAGIC_WORD*/
+} T_TIMER_MSG_BUF;
+
+#endif//#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+/*******************************************************************************
+ *                       Global variable declarations                          *
+ ******************************************************************************/
+
+
+/*******************************************************************************
+ *                       Global function declarations                          *
+ ******************************************************************************/
+/**
+ * @brief ´´½¨Èí¶¨Ê±Æ÷½Ó¿Ú
+ * @param usTimerID      Èë²Î£¬Èí¶¨Ê±Æ÷id£¬ÓÃÀ´Çø·Ö²»Í¬µÄÈí¼þ¶¨Ê±Æ÷
+ * @param ucFlag         Èë²Î£¬¶¨Ê±Æ÷ÀàÐͱê־λ
+ * @param ulInterval     Èë²Î£¬Èí¶¨Ê±Æ÷³¬Ê±Ê±¼ä¼ä¸ô£¬µ¥Î»£ºms
+ * @param procCallBack   Èë²Î£¬¶¨Ê±Æ÷³¬Ê±ºóµÄ»Øµ÷º¯ÊýÖ¸Õë
+ * @param args           Èë²Î£¬¶¨Ê±Æ÷³¬Ê±ºóµÄ»Øµ÷º¯Êý²ÎÊý
+ * @return OK ³É¹¦£¬ÆäËûֵʧ°Ü
+ * @retval OK  ³É¹¦
+ * @retval SOFTTIMER_ERRCODE_CALLBACK_NULL  Èí¶¨Ê±Æ÷µÄ»Øµ÷º¯ÊýµØÖ·Îª¿Õ
+ * @retval SOFTTIMER_ERRCODE_INIT_FAIL      Èí¶¨Ê±Æ÷³õʼ»¯Ê§°Ü
+ * @retval SOFTTIMER_ERRCODE_QUEUE_FULL     ´´½¨µÄÈí¶¨Ê±Æ÷³¬¹ý×î´ó¸öÊýÏÞÖÆ
+ * @retval SOFTTIMER_ERRCODE_TIMERID_EXIST  ¸ÃÈí¶¨Ê±Æ÷idÒѾ­´æÔÚ
+ * @note
+ * @warning
+ */
+LONG sc_timer_create(USHORT usTimerID,
+                     UCHAR ucFlag,
+                     ULONG ulInterval,
+                     void * (*procCallBack)(void *),
+                     void *args);
+
+/**
+ * @brief ɾ³ýÈí¶¨Ê±Æ÷½Ó¿Ú
+ * @param usTimerID   Èë²Î£¬ÒªÉ¾³ýµÄÈí¶¨Ê±Æ÷id
+ * @return OK£º³É¹¦£¬ERROR£ºÊ§°Ü
+ * @retval OK  ³É¹¦
+ * @retval ERROR  ʧ°Ü
+ * @note
+ * @warning
+ */
+LONG sc_timer_delete(USHORT usTimerID);
+
+#ifndef LIBSOFT_TIMER_API_NEW
+LONG CreateSoftTimer(USHORT usTimerID,
+                     UCHAR ucFlag,
+                     ULONG ulInterval,
+                     void * (*procCallBack)(void *),
+                     void *args);
+LONG DeleteSoftTimer(USHORT usTimerID);
+#endif
+
+/*******************************************************************************
+ *                      Inline function implementations                        *
+ ******************************************************************************/
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif  // #ifndef _SOFT_TIMER_H_
+