• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------------
2  * Copyright (c) Huawei Technologies Co., Ltd. 2013-2018. All rights reserved.
3  * Description: Software Timer Manager
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  * 1. Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
9  * of conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  * --------------------------------------------------------------------------- */
26 
27 #ifndef _LOS_SWTMR_PRI_H
28 #define _LOS_SWTMR_PRI_H
29 
30 #include "los_swtmr.h"
31 
32 #ifdef __cplusplus
33 #if __cplusplus
34 extern "C" {
35 #endif /* __cplusplus */
36 #endif /* __cplusplus */
37 
38 /**
39  * @ingroup los_swtmr
40  * Software timer state
41  */
42 enum SwtmrState {
43     OS_SWTMR_STATUS_UNUSED,             /**< The software timer is not used. */
44     OS_SWTMR_STATUS_CREATED,            /**< The software timer is created. */
45     OS_SWTMR_STATUS_TICKING             /**< The software timer is timing. */
46 };
47 
48 /**
49  * @ingroup los_swtmr
50  * Structure of the callback function that handles software timer timeout
51  */
52 typedef struct {
53     SWTMR_PROC_FUNC     handler;        /**< Callback function that handles software timer timeout */
54     UINT32              arg;            /**< Parameter passed in when the callback function
55                                              that handles software timer timeout is called */
56 } SwtmrHandlerItem;
57 
58 extern SWTMR_CTRL_S *g_swtmrCBArray;
59 
60 #define OS_SWT_FROM_SID(swtmrId)    ((SWTMR_CTRL_S *)g_swtmrCBArray + ((swtmrId) % LOSCFG_BASE_CORE_SWTMR_LIMIT))
61 
62 /**
63  * @ingroup los_swtmr
64  * @brief Scan a software timer.
65  *
66  * @par Description:
67  * <ul>
68  * <li>This API is used to scan a software timer when a Tick interrupt occurs and determine whether the software timer
69    expires.</li>
70  * </ul>
71  * @attention
72  * <ul>
73  * <li>None.</li>
74  * </ul>
75  *
76  * @param  None.
77  *
78  * @retval None.
79  * @par Dependency:
80  * <ul><li>los_swtmr_pri.h: the header file that contains the API declaration.</li></ul>
81  * @see LOS_SwtmrStop
82  */
83 extern UINT32 OsSwtmrScan(VOID);
84 
85 /**
86  * @ingroup los_swtmr
87  * @brief Initialization software timer.
88  *
89  * @par Description:
90  * <ul>
91  * <li>This API is used to initialization software.</li>
92  * </ul>
93  * @attention
94  * <ul>
95  * <li>None.</li>
96  * </ul>
97  *
98  * @param  None.
99  *
100  * @retval None.
101  * @par Dependency:
102  * <ul><li>los_swtmr_pri.h: the header file that contains the API declaration.</li></ul>
103  * @see None.
104  */
105 extern UINT32 OsSwtmrInit(VOID *swtmrArray);
106 
107 /**
108  * @ingroup los_swtmr
109  * @brief Initialization software timer save array.
110  *
111  * @par Description:
112  * <ul>
113  * <li>This API is used to initialization software timer save array.</li>
114  * </ul>
115  * @attention
116  * <ul>
117  * <li>None.</li>
118  * </ul>
119  *
120  * @param  None.
121  *
122  * @retval LOS_OK or LOS_ERRNO_SWTMR_NO_MEMORY.
123  * @par Dependency:
124  * <ul><li>los_swtmr_pri.h: the header file that contains the API declaration.</li></ul>
125  * @see None.
126  */
127 extern UINT32 OsSwtmrSaveInit(VOID);
128 
129 /**
130  * @ingroup los_swtmr
131  * @brief Get next timeout.
132  *
133  * @par Description:
134  * <ul>
135  * <li>This API is used to get next timeout.</li>
136  * </ul>
137  * @attention
138  * <ul>
139  * <li>None.</li>
140  * </ul>
141  *
142  * @param  None.
143  *
144  * @retval None.
145  * @par Dependency:
146  * <ul><li>los_swtmr_pri.h: the header file that contains the API declaration.</li></ul>
147  * @see None.
148  */
149 extern UINT32 OsSwtmrGetNextTimeout(VOID);
150 
151 /**
152  * @ingroup los_swtmr
153  * @brief Adjust software timer list.
154  *
155  * @par Description:
156  * <ul>
157  * <li>This API is used to adjust software timer list.</li>
158  * </ul>
159  * @attention
160  * <ul>
161  * <li>None.</li>
162  * </ul>
163  *
164  * @param  sleepTime    [IN]    UINT32 Sleep time.
165  *
166  * @retval UINT32    Sleep time.
167  * @par Dependency:
168  * <ul><li>los_swtmr_pri.h: the header file that contains the API declaration.</li></ul>
169  * @see None.
170  */
171 extern VOID OsSwtmrAdjust_Patch(UINT32 sleepTime);
172 
173 /**
174  * @ingroup los_swtmr
175  * Handle function of software timer task .
176  *
177  * @par Description:
178  * <ul>
179  * <li>This API is used to handle the overtime software timer.</li>
180  * </ul>
181  * @attention
182  * <ul>
183  * <li>None.</li>
184  * </ul>
185  *
186  * @param  None.
187  *
188  * @retval None.
189  * @par Dependency:
190  * <ul><li>los_swtmr.inc: the header file that contains the API declaration.</li></ul>
191  * @see None.
192  */
193 extern VOID OsSwtmrTask(VOID);
194 
195 /**
196  * @ingroup los_swtmr
197  * Save enable timer id when start sleep.
198  *
199  * @par Description:
200  * <ul>
201  * <li>This API is used to save enable timer id when start sleep.</li>
202  * </ul>
203  * @attention
204  * <ul>
205  * <li>None.</li>
206  * </ul>
207  *
208  * @param  None.
209  *
210  * @retval None.
211  * @par Dependency:
212  * <ul><li>los_swtmr.inc: the header file that contains the API declaration.</li></ul>
213  * @see None.
214  */
215 extern VOID OsSwtmrSave(VOID);
216 
217 extern SWTMR_CTRL_S *g_swtmrSortList;
218 
219 #ifdef __cplusplus
220 #if __cplusplus
221 }
222 #endif /* __cplusplus */
223 #endif /* __cplusplus */
224 
225 #endif /* _LOS_SWTMR_PRI_H */
226