1  /*
2  * Copyright (C) 2017-2024 Alibaba Group Holding Limited
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 /******************************************************************************
20  * @file     tick.h
21  * @brief    Header File for TICK Driver
22  * @version  V1.0
23  * @date     28. Sep 2020
24  ******************************************************************************/
25 
26 #ifndef _DRV_TICK_H_
27 #define _DRV_TICK_H_
28 
29 #include <stdint.h>
30 #include <stdint.h>
31 #include <drv/common.h>
32 
33 #ifndef CONFIG_SYSTICK_HZ
34 #define CONFIG_SYSTICK_HZ  100U
35 #endif
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /**
42   \brief       Initializes the resources needed for the TICK interface
43   \return      error code \ref csi_error_t
44 */
45 csi_error_t csi_tick_init(void);
46 
47 /**
48   \brief       De-initialize TICK Interface
49 */
50 void csi_tick_uninit(void);
51 
52 /**
53   \brief       Get the sys-tick, one tick == (1000 / CONFIG_SYSTICK_HZ) ms
54   \return      the sys-tick
55 */
56 uint32_t csi_tick_get(void);
57 
58 /**
59   \brief       Get the time which start from csi_tick_init
60   \return      The time which start from csi_tick_init (ms)
61 */
62 uint32_t csi_tick_get_ms(void);
63 
64 /**
65   \brief       Get the time which start from csi_tick_init
66   \return      The time which start from csi_tick_init (us)
67 */
68 uint64_t csi_tick_get_us(void);
69 
70 /**
71   \brief       Increase the sys-tick
72 */
73 void csi_tick_increase(void);
74 
75 #ifdef __cplusplus
76 }
77 #endif
78 
79 #endif /*_DRV_TICK_H_*/
80