• 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 PIN driver api \n
16  *
17  * History: \n
18  * 2022-08-25, Create file. \n
19  */
20 #ifndef PINCTRL_H
21 #define PINCTRL_H
22 
23 #include <stdint.h>
24 #include <stddef.h>
25 #include "errcode.h"
26 #include "pinctrl_porting.h"
27 
28 #ifdef __cplusplus
29 #if __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32 #endif /* __cplusplus */
33 
34 /**
35  * @defgroup drivers_driver_pinctrl Pinctrl
36  * @ingroup  drivers_driver
37  * @{
38  */
39 
40 /**
41  * @if Eng
42  * @brief  Initialize the Pinctrl.
43  * @note   This function should be called before other functions of this module are called.
44  * @else
45  * @brief  初始化Pinctrl.
46  * @note   该函数应该在其他本模块函数被调用前执行。
47  * @endif
48  */
49 void uapi_pin_init(void);
50 
51 /**
52  * @if Eng
53  * @brief  Deinitialize the Pinctrl.
54  * @else
55  * @brief  去初始化Pinctrl.
56  * @endif
57  */
58 void uapi_pin_deinit(void);
59 
60 /**
61  * @if Eng
62  * @brief  Set the PIN mode.
63  * @param  [in] pin Definition of IO. see @ref pin_t.
64  * @param  [in] mode Multiplexing mode. see @ref pin_mode_t.
65  * @retval ERRCODE_SUCC Success.
66  * @retval Other        Failure. For details, see @ref errcode_t.
67  * @else
68  * @brief  设置引脚复用模式。
69  * @param  [in] pin io,参考 @ref pin_t 。
70  * @param  [in] mode 复用模式,参考 @ref pin_mode_t 。
71  * @retval ERRCODE_SUCC 成功。
72  * @retval Other        失败,参考 @ref errcode_t 。
73  * @endif
74  */
75 errcode_t uapi_pin_set_mode(pin_t pin, pin_mode_t mode);
76 
77 /**
78  * @if Eng
79  * @brief  Get the PIN mode.
80  * @param  [in] pin Definition of IO, see @ref pin_t.
81  * @return  Multiplexing mode, see @ref pin_mode_t.
82  * @else
83  * @brief  获取引脚复用模式。
84  * @param  [in] pin io,参考 @ref pin_t 。
85  * @return 复用模式,参考 @ref pin_mode_t 。
86  * @endif
87  */
88 pin_mode_t uapi_pin_get_mode(pin_t pin);
89 
90 /**
91  * @if Eng
92  * @brief  Set the drive-strength of PIN.
93  * @param  [in] pin Definition of IO, see @ref pin_t.
94  * @param  [in] ds Drive strength, see @ref pin_drive_strength_t.
95  * @retval ERRCODE_SUCC Success.
96  * @retval Other        Failure. For details, see @ref errcode_t.
97  * @else
98  * @brief  设置引脚驱动能力。
99  * @param  [in] pin io,参考 @ref pin_t 。
100  * @param  [in] ds 驱动能力,参考 @ref pin_drive_strength_t 。
101  * @retval ERRCODE_SUCC 成功。
102  * @retval Other        失败,参考 @ref errcode_t 。
103  * @endif
104  */
105 errcode_t uapi_pin_set_ds(pin_t pin, pin_drive_strength_t ds);
106 
107 /**
108  * @if Eng
109  * @brief  Get the drive-strength of PIN.
110  * @param  [in] pin Definition of IO, see @ref pin_t.
111  * @return  Drive strength, see @ref pin_drive_strength_t.
112  * @else
113  * @brief  获取引脚驱动能力。
114  * @param  [in] pin io,参考 @ref pin_t 。
115  * @return 驱动能力,参考 @ref pin_drive_strength_t 。
116  * @endif
117  */
118 pin_drive_strength_t uapi_pin_get_ds(pin_t pin);
119 
120 /**
121  * @if Eng
122  * @brief  Set the pull-up/down status of PIN.
123  * @param  [in] pin Definition of IO, see @ref pin_t.
124  * @param  [in] pull_type pull-up/down type, see @ref pin_pull_t.
125  * @retval ERRCODE_SUCC Success.
126  * @retval Other        Failure. For details, see @ref errcode_t.
127  * @else
128  * @brief  设置引脚上下拉。
129  * @param  [in] pin io,参考 @ref pin_t 。
130  * @param  [in] pull_type 上下拉类型,参考 @ref pin_pull_t 。
131  * @retval ERRCODE_SUCC 成功。
132  * @retval Other        失败,参考 @ref errcode_t 。
133  * @endif
134  */
135 errcode_t uapi_pin_set_pull(pin_t pin, pin_pull_t pull_type);
136 
137 /**
138  * @if Eng
139  * @brief  Get the pull-up/down status of PIN.
140  * @param  [in] pin Definition of IO, see @ref pin_t.
141  * @return  Pull-up/down status, see @ref pin_pull_t.
142  * @else
143  * @brief  获取引脚上下拉状态。
144  * @param  [in] pin io,参考 @ref pin_t 。
145  * @return 上下拉状态,参考 @ref pin_pull_t 。
146  * @endif
147  */
148 pin_pull_t uapi_pin_get_pull(pin_t pin);
149 
150 #if defined(CONFIG_PINCTRL_SUPPORT_IE)
151 /**
152  * @if Eng
153  * @brief  Set the INPUT-Enabled status of PIN.
154  * @param  [in] pin Definition of IO, see @ref pin_t.
155  * @param  [in] ie INPUT-Enabled status, see @ref pin_input_enable_t.
156  * @retval ERRCODE_SUCC Success.
157  * @retval Other        Failure. For details, see @ref errcode_t.
158  * @else
159  * @brief  设置引脚输入使能状态。
160  * @param  [in] pin io,参考 @ref pin_t 。
161  * @param  [in] ie 输入使能状态,参考 @ref pin_input_enable_t 。
162  * @retval ERRCODE_SUCC 成功。
163  * @retval Other        失败,参考 @ref errcode_t 。
164  * @endif
165  */
166 errcode_t uapi_pin_set_ie(pin_t pin, pin_input_enable_t ie);
167 
168 /**
169  * @if Eng
170  * @brief  Get the INPUT-Enabled status of PIN.
171  * @param  [in] pin Definition of IO. see @ref pin_t.
172  * @return INPUT-Enabled status. see @ref pin_input_enable_t.
173  * @else
174  * @brief  获取引脚输入使能状态。
175  * @param  [in] pin io,参考 @ref pin_t 。
176  * @return 输入使能状态,参考 @ref pin_input_enable_t 。
177  * @endif
178  */
179 pin_input_enable_t uapi_pin_get_ie(pin_t pin);
180 #endif /* CONFIG_PINCTRL_SUPPORT_IE */
181 
182 #if defined(CONFIG_PINCTRL_SUPPORT_ST)
183 /**
184  * @if Eng
185  * @brief  Set the Schmitt-Trigger status of PIN.
186  * @param  [in] pin Definition of IO, see @ref pin_t.
187  * @param  [in] st Schmitt-Trigger status, see @ref pin_schmitt_trigger_t.
188  * @retval ERRCODE_SUCC Success.
189  * @retval Other        Failure. For details, see @ref errcode_t.
190  * @else
191  * @brief  设置引脚施密特触发状态。
192  * @param  [in] pin io,参考 @ref pin_t 。
193  * @param  [in] st 施密特触发状态,参考 @ref pin_schmitt_trigger_t 。
194  * @retval ERRCODE_SUCC 成功。
195  * @retval Other        失败,参考 @ref errcode_t 。
196  * @endif
197  */
198 errcode_t uapi_pin_set_st(pin_t pin, pin_schmitt_trigger_t st);
199 
200 /**
201  * @if Eng
202  * @brief  Get the Schmitt-Trigger status of PIN.
203  * @param  [in] pin Definition of IO. see @ref pin_t
204  * @return Schmitt-Trigger status. see @ref pin_schmitt_trigger_t
205  * @else
206  * @brief  获取引脚施密特触发状态。
207  * @param  [in] pin io,参考 @ref pin_t 。
208  * @return 施密特触发状态,参考 @ref pin_schmitt_trigger_t 。
209  * @endif
210  */
211 pin_schmitt_trigger_t uapi_pin_get_st(pin_t pin);
212 #endif /* CONFIG_PINCTRL_SUPPORT_ST */
213 
214 #if defined(CONFIG_PINCTRL_SUPPORT_LPM)
215 /**
216  * @if Eng
217  * @brief  Suspend the PINCTRL.
218  * @param  [in]  arg Argument for suspend.
219  * @retval ERRCODE_SUCC Success.
220  * @retval Other        Failure. For details, see @ref errcode_t.
221  * @else
222  * @brief  挂起PINCTRL。
223  * @param  [in]  arg 挂起所需要的参数。
224  * @retval ERRCODE_SUCC 成功。
225  * @retval Other        失败,参考 @ref errcode_t 。
226  * @endif
227  */
228 errcode_t uapi_pin_suspend(uintptr_t arg);
229 
230 /**
231  * @if Eng
232  * @brief  Resume the PINCTRL.
233  * @param  [in]  arg Argument for resume.
234  * @retval ERRCODE_SUCC Success.
235  * @retval Other        Failure. For details, see @ref errcode_t.
236  * @else
237  * @brief  恢复PINCTRL。
238  * @param  [in]  arg 恢复所需要的参数。
239  * @retval ERRCODE_SUCC 成功。
240  * @retval Other        失败,参考 @ref errcode_t 。
241  * @endif
242  */
243 errcode_t uapi_pin_resume(uintptr_t arg);
244 #endif  /* CONFIG_PINCTRL_SUPPORT_LPM */
245 
246 /**
247  * @}
248  */
249 
250 #ifdef __cplusplus
251 #if __cplusplus
252 }
253 #endif /* __cplusplus */
254 #endif /* __cplusplus */
255 
256 #endif