• 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 tsensor port \n
16  *
17  * History: \n
18  * 2023-02-28, Create file. \n
19  */
20 
21 #ifndef TSENSOR_PORTING_H
22 #define TSENSOR_PORTING_H
23 
24 #include <stdint.h>
25 #include <stdbool.h>
26 
27 #ifdef __cplusplus
28 #if __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31 #endif /* __cplusplus */
32 
33 /**
34  * @defgroup drivers_port_tsensor TSENSOR
35  * @ingroup  drivers_port
36  * @{
37  */
38 
39 #if defined(CONFIG_TSENSOR_MULTILEVEL)
40 /**
41  * @if Eng
42  * @brief  Tsensor multilevel interrupt enable level.
43  * @else
44  * @brief  Tsensor多级中断使能。
45  * @endif
46  */
47 typedef enum tsensor_multilevel_en {
48     TSENSOR_MULTILEVEL_EN_LTO0,  /*!< @if Eng Enable interrupt when the temperature falls in the L - 0 position.
49                                           @else   温度降至L-0位置时使能中断。  @endif */
50     TSENSOR_MULTILEVEL_EN_0TO1,      /*!< @if Eng Enable interrupt when the temperature falls in the 0 - 1 position.
51                                           @else   温度降至0-1位置时使能中断。  @endif */
52     TSENSOR_MULTILEVEL_EN_1TO2,      /*!< @if Eng Enable interrupt when the temperature falls in the 1 - 2 position.
53                                           @else   温度降至1-2位置时使能中断。  @endif */
54     TSENSOR_MULTILEVEL_EN_2TO3,      /*!< @if Eng Enable interrupt when the temperature falls in the 2 - 3 position.
55                                           @else   温度降至2-3位置时使能中断。  @endif */
56     TSENSOR_MULTILEVEL_EN_3TOH,      /*!< @if Eng Enable interrupt when the temperature falls in the 3 - H position.
57                                           @else   温度降至3-H位置时使能中断。  @endif */
58     TSENSOR_MULTILEVEL_EN_MAX
59 } tsensor_multilevel_en_t;
60 
61 /**
62  * @if Eng
63  * @brief  Tsensor multilevel threshold value level.
64  * @else
65  * @brief  Tsensor多级阈值级别。
66  * @endif
67  */
68 typedef enum tsensor_multilevel_value {
69     TSENSOR_MULTILEVEL_VAL_0,  /*!< @if Eng Setting the temperature threshold for gear 0.
70                                         @else   设置0档温度阈值。  @endif */
71     TSENSOR_MULTILEVEL_VAL_1,      /*!< @if Eng Setting the temperature threshold for gear 1.
72                                         @else   设置1档温度阈值。  @endif */
73     TSENSOR_MULTILEVEL_VAL_2,      /*!< @if Eng Setting the temperature threshold for gear 2.
74                                         @else   设置2档温度阈值。  @endif */
75     TSENSOR_MULTILEVEL_VAL_3,      /*!< @if Eng Setting the temperature threshold for gear 3.
76                                         @else   设置3档温度阈值。  @endif */
77     TSENSOR_MULTILEVEL_VAL_MAX
78 } tsensor_multilevel_value_t;
79 #endif /* CONFIG_TSENSOR_MULTILEVEL */
80 
81 /**
82  * @if Eng
83  * @brief  Get the base address of a specified Tsensor.
84  * @return The base address of specified Tsensor.
85  * @else
86  * @brief  获取指定Tsensor的基地址。
87  * @return 指定Tsensor的基地址。
88  * @endif
89  */
90 uintptr_t tsensor_port_base_addr_get(void);
91 
92 /**
93  * @if Eng
94  * @brief  Register hal funcs objects into hal_tsensor module.
95  * @else
96  * @brief  将hal funcs对象注册到hal_tsensor模块中。
97  * @endif
98  */
99 void tsensor_port_register_hal_funcs(void);
100 
101 /**
102  * @if Eng
103  * @brief  Unregister hal funcs objects from hal_tsensor module.
104  * @else
105  * @brief  从hal_tsensor模块注销hal funcs对象。
106  * @endif
107  */
108 void tsensor_port_unregister_hal_funcs(void);
109 
110 /**
111  * @if Eng
112  * @brief  Register irq for Tsensor.
113  * @else
114  * @brief  Tsensor注册中断。
115  * @endif
116  */
117 void tsensor_port_register_irq(void);
118 
119 /**
120  * @if Eng
121  * @brief  Unregister irq for Tsensor.
122  * @else
123  * @brief  Tsensor去注册中断。
124  * @endif
125  */
126 void tsensor_port_unregister_irq(void);
127 
128 /**
129  * @if Eng
130  * @brief  Set the divider number of the peripheral device clock.
131  * @param [in] value Enable or disable.
132  * @else
133  * @brief  设置外设时钟分频数。
134  * @param [in] value 启用或禁用。
135  * @endif
136  */
137 void tsensor_port_power_on_and_fre_div(bool value);
138 
139 /**
140  * @if Eng
141  * @brief  Lock of Tsensor interrupt.
142  * @else
143  * @brief  Tsensor中断锁定。
144  * @endif
145  */
146 uint32_t tsensor_port_irq_lock(void);
147 
148 /**
149  * @if Eng
150  * @brief  Unlock of Tsensor interrupt.
151  * @else
152  * @brief  Tsensor中断解锁。
153  * @endif
154  */
155 void tsensor_port_irq_unlock(uint32_t flag);
156 
157 /**
158  * @if Eng
159  * @brief  Get system time MS.
160  * @else
161  * @brief  获取系统时间MS。
162  * @endif
163  */
164 uint64_t tsensor_port_get_ms(void);
165 
166 /**
167  * @}
168  */
169 
170 #ifdef __cplusplus
171 #if __cplusplus
172 }
173 #endif /* __cplusplus */
174 #endif /* __cplusplus */
175 
176 #endif
177