• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *
15  * Description: Provides Systick driver api \n
16  *
17  * History: \n
18  * 2022-08-01, Create file. \n
19  */
20 #ifndef SYSTICK_H
21 #define SYSTICK_H
22 
23 #include <stdint.h>
24 #include "errcode.h"
25 
26 #ifdef __cplusplus
27 #if __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30 #endif /* __cplusplus */
31 
32 /**
33  * @defgroup drivers_driver_systick Systick
34  * @ingroup  drivers_driver
35  * @{
36  */
37 
38 /**
39  * @if Eng
40  * @brief  Initialize the Systick.
41  * @retval ERRCODE_SUCC Success.
42  * @retval Other        Failure. For details, see @ref errcode_t.
43  * @else
44  * @brief  初始化Systick。
45  * @retval ERRCODE_SUCC 成功。
46  * @retval Other        失败,参考 @ref errcode_t 。
47  * @endif
48  */
49 void uapi_systick_init(void);
50 
51 /**
52  * @if Eng
53  * @brief  Deinitialize the Systick.
54  * @retval ERRCODE_SUCC Success.
55  * @retval Other        Failure. For details, see @ref errcode_t.
56  * @else
57  * @brief  去初始化Systick。
58  * @retval ERRCODE_SUCC 成功。
59  * @retval Other        失败,参考 @ref errcode_t 。
60  * @endif
61  */
62 void uapi_systick_deinit(void);
63 
64 /**
65  * @if Eng
66  * @brief  Clear Systick count.
67  * @retval ERRCODE_SUCC Success.
68  * @retval Other        Failure. For details, see @ref errcode_t.
69  * @else
70  * @brief  清除Systick计数。
71  * @retval ERRCODE_SUCC 成功。
72  * @retval Other        失败,参考 @ref errcode_t 。
73  * @endif
74  */
75 errcode_t uapi_systick_count_clear(void);
76 
77 /**
78  * @if Eng
79  * @brief  Get Systick count.
80  * @retval Systick current count.
81  * @else
82  * @brief  获取Systick计数值。
83  * @retval Systick当前计数值。
84  * @endif
85  */
86 uint64_t uapi_systick_get_count(void);
87 
88 /**
89  * @if Eng
90  * @brief  Get the Systick second.
91  * @retval The current second of Systick.
92  * @else
93  * @brief  获取Systick计数秒值。
94  * @retval Systick当前计数秒值。
95  * @endif
96  */
97 uint64_t uapi_systick_get_s(void);
98 
99 /**
100  * @if Eng
101  * @brief  Get the Systick ms.
102  * @retval The current ms of Systick.
103  * @else
104  * @brief  获取Systick计数毫秒值。
105  * @retval Systick当前计数毫秒值。
106  * @endif
107  */
108 uint64_t uapi_systick_get_ms(void);
109 
110 /**
111  * @if Eng
112  * @brief  Get the Systick us.
113  * @retval The current us of Systick.
114  * @else
115  * @brief  获取Systick计数微秒值。
116  * @retval Systick当前计数微秒值。
117  * @endif
118  */
119 uint64_t uapi_systick_get_us(void);
120 
121 /**
122  * @if Eng
123  * @brief  Delay by count.
124  * @param  [in]  c_delay Delay time.
125  * @retval ERRCODE_SUCC Success.
126  * @retval Other        Failure. For details, see @ref errcode_t.
127  * @else
128  * @brief  按计数延时
129  * @param  [in]  c_delay 延时时间。
130  * @retval ERRCODE_SUCC 成功。
131  * @retval Other        失败,参考 @ref errcode_t 。
132  * @endif
133  */
134 errcode_t uapi_systick_delay_count(uint64_t c_delay);
135 
136 /**
137  * @if Eng
138  * @brief  Delay by s.
139  * @param  [in]  s_delay Delay time.
140  * @retval ERRCODE_SUCC Success.
141  * @retval Other        Failure. For details, see @ref errcode_t.
142  * @else
143  * @brief  按秒数延时。
144  * @param  [in]  s_delay 延时时间。
145  * @retval ERRCODE_SUCC 成功。
146  * @retval Other        失败,参考 @ref errcode_t 。
147  * @endif
148  */
149 errcode_t uapi_systick_delay_s(uint32_t s_delay);
150 
151 /**
152  * @if Eng
153  * @brief  Delay by ms.
154  * @param  [in]  m_delay Delay time.
155  * @retval ERRCODE_SUCC Success.
156  * @retval Other        Failure. For details, see @ref errcode_t.
157  * @else
158  * @brief  按毫秒数延时。
159  * @param  [in]  m_delay 延时时间。
160  * @retval ERRCODE_SUCC 成功。
161  * @retval Other        失败,参考 @ref errcode_t 。
162  * @endif
163  */
164 errcode_t uapi_systick_delay_ms(uint32_t m_delay);
165 
166 /**
167  * @if Eng
168  * @brief  Delay by us.
169  * @param  [in]  u_delay Delay time.
170  * @retval ERRCODE_SUCC Success.
171  * @retval Other        Failure. For details, see @ref errcode_t.
172  * @else
173  * @brief  按微秒数延时。
174  * @param  [in]  u_delay 延时时间。
175  * @retval ERRCODE_SUCC 成功。
176  * @retval Other        失败,参考 @ref errcode_t 。
177  * @endif
178  */
179 errcode_t uapi_systick_delay_us(uint32_t u_delay);
180 
181 #if defined(CONFIG_SYSTICK_SUPPORT_LPM)
182 /**
183  * @if Eng
184  * @brief  Suspend the Systick.
185  * @param  [in]  arg Argument for suspend.
186  * @retval ERRCODE_SUCC Success.
187  * @retval Other        Failure. For details, see @ref errcode_t.
188  * @else
189  * @brief  挂起Systick。
190  * @param  [in]  arg 挂起所需要的参数。
191  * @retval ERRCODE_SUCC 成功。
192  * @retval Other        失败,参考 @ref errcode_t 。
193  * @endif
194  */
195 errcode_t uapi_systick_suspend(uintptr_t arg);
196 
197 /**
198  * @if Eng
199  * @brief  Resume the Systick.
200  * @param  [in]  arg Argument for resume.
201  * @retval ERRCODE_SUCC Success.
202  * @retval Other        Failure. For details, see @ref errcode_t.
203  * @else
204  * @brief  恢复Systick。
205  * @param  [in]  arg 恢复所需要的参数。
206  * @retval ERRCODE_SUCC 成功。
207  * @retval Other        失败,参考 @ref errcode_t 。
208  * @endif
209  */
210 errcode_t uapi_systick_resume(uintptr_t arg);
211 #endif  /* CONFIG_SYSTICK_SUPPORT_LPM */
212 
213 /**
214  * @}
215  */
216 
217 #ifdef __cplusplus
218 #if __cplusplus
219 }
220 #endif /* __cplusplus */
221 #endif /* __cplusplus */
222 
223 #endif