blob: 0738e062203d7dadc658f13efec68f82ba7923fa [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*******************************************************************************
2 * Copyright (C) 2014, ZTE Corporation.
3 *
4 * File Name:
5 * File Mark:
6 * Description: all function defines provided by sys module
7 * Others:
8 * Version: 1.0
9 * Author: limeifeng
10 * Date: 2014-01-17
11 * History 1:
12 * Date:
13 * Version:
14 * Author:
15 * Modification:
16 * History 2:
17 ********************************************************************************/
18
19#ifndef _DRVS_TIMER_H
20#define _DRVS_TIMER_H
21
22/****************************************************************************
23* Include files
24****************************************************************************/
25#ifdef _OS_LINUX
26#include <linux/delay.h>
27#endif
28
29/****************************************************************************
30* Macros
31****************************************************************************/
32
33#define SYSTIMER_INT TIMER0_INT
34
35/****************************************************************************
36* Types
37****************************************************************************/
38
39
40typedef enum _T_ZDrv_TimerId
41{
42 TIMER0 = 0,/*ps timer0--sysTick */
43 TIMER1 = 1,/*ps timer1--psm wake timer,must AON tiner**/
44 TIMER2 = 2,/*ps timer2--psm compensate timer,must AON tiner*/
45 TIMER3 = 3,/* rm timer1*/
46 TIMER4 = 4,/*ps rm timer--uicc timer*/
47 NUM_TIMERS
48}T_ZDrv_TimerId;
49
50typedef enum _T_ZDrv_TIMER_SRC_CLK
51{
52 CLK_32K = 0,
53 CLK_26M,
54}T_ZDrv_TIMER_SRC_CLK;
55
56typedef enum _T_ZDrv_TIMER_SRC_DIV
57{
58 CLK_DIV0 = 0,
59 CLK_DIV2 = 1,
60 CLK_DIV4 = 3,
61 CLK_DIV6 = 5,
62 CLK_DIV8 = 7,
63 CLK_DIV10 = 9,
64 CLK_DIV12 = 11,
65 CLK_DIV14 = 13,
66 CLK_DIV16 = 15,
67 CLK_DIV_NUM,
68}T_ZDrv_TIMER_SRC_DIV;
69
70typedef enum _T_ZDrv_CLK_PTV
71{
72 CLK_PTV0 =0, /*not divide the work clock*/
73 CLK_PTV1 , /*divide the work clock 2 times*/
74 CLK_PTV2, /*divide the work clock 4 times*/
75 CLK_PTV3, /*divide the work clock 8 times*/
76 CLK_PTV4,
77 CLK_PTV5,
78 CLK_PTV6,
79 CLK_PTV7,
80 CLK_PTV8,
81 CLK_PTV9,
82 CLK_PTV10,
83 CLK_PTV11,
84 CLK_PTV12,
85 CLK_PTV13,
86 CLK_PTV14,
87 CLK_PTV15,
88 CLK_PTV16,
89 CLK_PTV17,
90 CLK_PTV18,
91 CLK_PTV19,
92 CLK_PTV20,
93 CLK_PTV21,
94 CLK_PTV22,
95 CLK_PTV23,
96 CLK_PTV24,
97 CLK_PTV25,
98 CLK_PTV26,
99 CLK_PTV27,
100 CLK_PTV28,
101 CLK_PTV29,
102 CLK_PTV30,
103 CLK_PTV31, /*divide the work clock 2**31 times*/
104 CLK_PTV_NUM,
105}T_ZDrv_CLK_PTV;
106
107/*CLK_1MHz: src_clk=26MHz CLK_1KHz: src_clk=32KHz.*/
108typedef enum _T_ZDrv_TIMER_CLK
109{
110 CLK_1MHz = 0,
111 CLK_1KHz,
112 TIMER_CLK_NUM,
113}T_ZDrv_TIMER_CLK;
114
115typedef VOID (*ZDRV_TIMER_CALLBACK)(VOID);
116typedef VOID (*ZDRV_TIMER_ISR_CALLBACK)( UINT32 uiTimerId );
117
118/****************************************************************************
119* Constants
120****************************************************************************/
121
122/****************************************************************************
123* Global Variables
124****************************************************************************/
125
126/****************************************************************************
127* Function Prototypes
128****************************************************************************/
129
130
131/*******************************************************************************
132 * Function: zDrvTimer_Stamp
133 * Description:¸Ãº¯ÊýÓÃÓÚ»ñȡϵͳtimerÆô¶¯ºóµÄϵͳÕý³£ÔËÐеľø¶Ôʱ¼ä£¬²»°üº¬ÏµÍ³¹ØÖжÏ
134 * ³¬¹ý1ms£¬ÒÔ¼°ÏµÍ³Ë¯ÃßµÄʱ¼ä²¹³¥¡£
135 * Parameters:
136 * Input:
137 *
138 * Output: ϵͳÔËÐÐʱ¼ä£¬26M(µ¥Î»:us) 32K(µ¥Î»:ms)
139 *
140 * Returns:
141 *
142 * Others:
143 ********************************************************************************/
144UINT32 zDrvTimer_Stamp( VOID );
145
146/**************************************************************************
147* Functin: zDrvTimer_Create
148* Description: This function is used to create a timer.
149* Parameters:
150* (IN)
151* pCallback: callback function pointer.
152* bPeriod: if auto-restart after the interval val reached zero
153* (OUT)
154* None.
155* Returns:
156* timer id if successed. [1, timers number )
157* DRV_ERROR if failed.
158* Others:
159* None.
160**************************************************************************/
161SINT32 zDrvTimer_Create( ZDRV_TIMER_CALLBACK pCallback, BOOL bPeriod );
162
163
164/**************************************************************************
165* Functin: zDrvTimer_Release
166* Description: This function is used to release a timer.
167* Parameters:
168* (IN)
169* uiTimerId: the id of created timer.
170* (OUT)
171* None.
172* Returns:
173* DRV_SUCCESS: successed.
174* DRV_ERROR if failed.
175* Others:
176* None.
177**************************************************************************/
178SINT32 zDrvTimer_Release( UINT32 uiTimerId );
179
180/**************************************************************************
181* Functin: zDrvTimer_Start
182* Description: This function is used to start a timer.
183* Parameters:
184* (IN)
185* uiTimerId: the id of created timer.
186* uiDuration: time length. Unit: us
187* (OUT)
188* None.
189* Returns:
190* DRV_SUCCESS: successed.
191* DRV_ERROR if failed.
192* Others:
193* None.
194**************************************************************************/
195SINT32 zDrvTimer_Start( UINT32 uiTimerId, UINT32 uiDuration );
196
197/*******************************************************************************
198 * Function:zDrvTimer_SetWorkClk
199 * Description:ÉèÖÃTIMER_ID µÄʱÖÓԴƵÂÊÊ¡µçרÓã¬ÆäËüÄ£¿é²»ÔÊÐíµ÷ÓÃ
200 * Parameters:
201 * Input:TIMER_ID : Timer ID , zDrvTimer_Open µÄÈë²Î¡£
202 * tick: CLK_1MHz£¬Ê±ÖÓÔ´Ñ¡Ôñ26M¡£
203 CLK_1KHz£¬ ʱÖÓÔ´Ñ¡Ôñ32K¡£
204 * Output:³É¹¦·µ»ØDRV_SUCCESS£¬ÆäËûÖµ±íʾʧ°ÜÔ­Òò¡£
205 *
206 * Returns:
207 *
208 *
209 * Others:Ê¡µçרÓã¬ÆäËüÄ£¿é²»ÔÊÐíµ÷ÓÃ!!!
210 ********************************************************************************/
211SINT32 zDrvTimer_SetWorkClk(T_ZDrv_TimerId TIMER_ID, T_ZDrv_TIMER_CLK tick);
212/*******************************************************************************
213* Function: zDrvTimer_SetCallBack
214* Description: ¿ÉÒÔÔÚzDrvTimer_StartTimerº¯ÊýÖÐÉ趨»Øµ÷º¯Êý¶ø²»Óô˺¯Êý
215* ´Ëº¯ÊýÌṩһÖÖÔÚzDrvTimer_StartTimerÖ®Íâ×¢²á»Øµ÷µÄ·½·¨¡£
216* Parameters:
217* Input:uiTimerId : Timer ID , zDrvTimer_Open µÄ·µ»ØÖµ
218* fIsrCb: Ï£ÍûÔÚ¶¨Ê±µ½0ʱµÄtimerÖжÏISRÖÐÖ´ÐеĻص÷º¯Êý¡£
219* Output:
220*
221* Returns:
222*
223* Others:Ê¡µçרÓã¬ÆäËüÄ£¿é²»ÔÊÐíµ÷ÓÃ!!!
224********************************************************************************/
225SINT32 zDrvTimer_SetCallBack(T_ZDrv_TimerId uiTimerId, ZDRV_TIMER_ISR_CALLBACK fIsrCb);
226
227/*******************************************************************************
228 * Function:zDrvTimer_Open
229 * Description:µ÷ÓÃÁ÷³Ì:zDrvTimer_Open->zDrvTimer_SetWorkClk->zDrvTimer_StartTimer->zDrvTimer_Close
230 * Parameters:
231 * Input:
232 *
233 * Output:
234 *
235 * Returns:
236 *
237 *
238 * Others:Ê¡µçרÓã¬ÆäËüÄ£¿é²»ÔÊÐíµ÷ÓÃ
239 ********************************************************************************/
240SINT32 zDrvTimer_Open( T_ZDrv_TimerId TIMER_ID);
241/*******************************************************************************
242 * Function:zDrvTimer_Close
243 * Description:¹Ø±Õ¶ÔÓ¦¶¨Ê±Æ÷²¢Ð¶ÔØÖжÏ
244 * Parameters:
245 * Input:
246 *
247 * Output:
248 *
249 * Returns:³É¹¦·µ»ØDRV_SUCCESS£¬ÆäËûÖµ±íʾʧ°ÜÔ­Òò¡£
250 *
251 *
252 * Others:Ê¡µçרÓã¬ÆäËüÄ£¿é²»ÔÊÐíµ÷ÓÃ!!!
253 ********************************************************************************/
254SINT32 zDrvTimer_Close( T_ZDrv_TimerId uiTimerId );
255/*******************************************************************************
256 * Function:zDrvTimer_StartTimer
257 * Description:
258 * Parameters:
259 * Input:
260 *
261 * Output:
262 *
263 * Returns:³É¹¦·µ»ØDRV_SUCCESS£¬ÆäËûÖµ±íʾʧ°ÜÔ­Òò¡£
264 *
265 *
266 * Others:Ê¡µçרÓã¬ÆäËüÄ£¿é²»ÔÊÐíµ÷ÓÃ!!!
267 ********************************************************************************/
268SINT32 zDrvTimer_StartTimer( T_ZDrv_TimerId uiTimerId, UINT32 uiDuration, BOOL bPeriod , ZDRV_TIMER_ISR_CALLBACK fIsrCb );
269
270/*******************************************************************************
271 * Function:zDrvTimer_Remain
272 * Description:²éѯµ±Ç°¶¨Ê±Æ÷Ê£Óඨʱʱ¼ä¡£
273 * Parameters:
274 * Input:
275 *
276 * Output:
277 *
278 * Returns:Ê£Óඨʱʱ¼ä£¬µ¥Î»¸ù¾ÝzDrvTimer_SetWorkClkº¯ÊýÉèÖõÄʱÖÓԴƵÂÊÈ·¶¨
279 * ʱÖÓԴΪ1M_HZʱµ¥Î»Îªus£¬1K_HZʱµ¥Î»Îªms¡£
280 *
281 *
282 * Others:Ê¡µçרÓã¬ÆäËüÄ£¿é²»ÔÊÐíµ÷ÓÃ!!!
283 ********************************************************************************/
284UINT32 zDrvTimer_Remain( T_ZDrv_TimerId uiTimerId );
285/*******************************************************************************
286 * Function:zDrvTimer_StopTimer
287 * Description:Í£Ö¹¶¨Ê±Æ÷¼ÆÊ±¡£
288 * Parameters:
289 * Input:
290 *
291 * Output:
292 *
293 * Returns:³É¹¦·µ»ØDRV_SUCCESS£¬ÆäËûÖµ±íʾʧ°ÜÔ­Òò¡£
294 *
295 *
296 * Others:Ê¡µçרÓã¬ÆäËüÄ£¿é²»ÔÊÐíµ÷ÓÃ!!!
297 ********************************************************************************/
298SINT32 zDrvTimer_StopTimer( T_ZDrv_TimerId uiTimerId );
299#endif/*_DRVS_TIMER_H*/
300