blob: a00a3c0e273d86bc72bebfae8c692c8174daa744 [file] [log] [blame]
b.liud440f9f2025-04-18 10:44:31 +08001#ifndef __QL_GPIO_INTERNAL_H
2#define __QL_GPIO_INTERNAL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include "ql_gpio.h"
9
10typedef enum{
11 INTERNAL_BEGIN = -1,
12 INTERNAL_GPIO_10 = 10,
13 INTERNAL_GPIO_11 = 11,
14 INTERNAL_GPIO_19 = 19,
15 INTERNAL_GPIO_21 = 21,
16 INTERNAL_GPIO_22 = 22,
17 INTERNAL_GPIO_23 = 23,
18 INTERNAL_GPIO_24 = 24,
19 INTERNAL_GPIO_25 = 25,
20 INTERNAL_GPIO_26 = 26,
21 INTERNAL_GPIO_27 = 27,
22 INTERNAL_GPIO_31 = 31,
23 INTERNAL_GPIO_32 = 32,
24 INTERNAL_GPIO_33 = 33,
25 INTERNAL_GPIO_34 = 34,
26 INTERNAL_GPIO_35 = 35,
27 INTERNAL_GPIO_36 = 36,
28 INTERNAL_GPIO_37 = 37,
29 INTERNAL_GPIO_38 = 38,
30 INTERNAL_GPIO_39 = 39,
31 INTERNAL_GPIO_40 = 40,
32 INTERNAL_GPIO_43 = 43,
33 INTERNAL_GPIO_48 = 48,
34 INTERNAL_GPIO_49 = 49,
35 INTERNAL_GPIO_50 = 50,
36 INTERNAL_GPIO_51 = 51,
37 INTERNAL_GPIO_52 = 52,
38 INTERNAL_GPIO_53 = 53,
39 INTERNAL_GPIO_54 = 54,
40 INTERNAL_GPIO_55 = 55,
41 INTERNAL_GPIO_56 = 56,
42 INTERNAL_GPIO_57 = 57,
43 INTERNAL_GPIO_58 = 58,
44 INTERNAL_GPIO_59 = 59,
45 INTERNAL_GPIO_99 = 99,
46 INTERNAL_GPIO_117 = 117,
47 INTERNAL_GPIO_118 = 118,
48 INTERNAL_GPIO_119 = 119,
49 INTERNAL_GPIO_120 = 120,
50 INTERNAL_GPIO_122 = 122,
51 INTERNAL_GPIO_123 = 123,
52 INTERNAL_GPIO_126 = 126,
53 INTERNAL_END = 127
54}INTERNAL_ENUM_PINNAME;
55
56
57/*****************************************************************
58* Function: __ql_gpio_init
59*
60* Description:
61* This function enables the GPIO function of the specified pin,
62* and initialize the configurations, including direction,
63* level and pull selection.
64*
65* Parameters:
66* pin_name:
67* Pin name, one value of INTERNAL_ENUM_PINNAME.
68* dir:
69* The initial direction of GPIO, one value of ENUM_PIN_DIRECTION.
70* level:
71* The initial level of GPIO, one value of ENUM_PIN_LEVEL.
72* pullSel:
73* Pull selection, one value of ENUM_PIN_PULLSEL.
74* Return:
75* RES_OK, this function succeeds.
76* RES_IO_NOT_SUPPORT, the input GPIO is invalid.
77* RES_IO_ERR, the function failed
78* other place. For example this GPIO has been using as EINT.
79*****************************************************************/
80int __ql_gpio_init(INTERNAL_ENUM_PINNAME pin_name,
81 ENUM_PIN_DIRECTION dir,
82 ENUM_PIN_LEVEL level,
83 ENUM_PIN_PULLSEL pull_sel
84 );
85
86/*****************************************************************
87* Function: __ql_gpio_base_init
88*
89* Description:
90* This function enables the GPIO function of the specified pin.
91*
92* Parameters:
93* pin_name:
94* Pin name, one value of INTERNAL_ENUM_PINNAME.
95*
96* Return:
97* RES_OK, this function succeeds.
98* RES_IO_NOT_SUPPORT, the input GPIO is invalid.
99* RES_IO_ERR, the function failed
100*****************************************************************/
101int __ql_gpio_base_init(INTERNAL_ENUM_PINNAME pin_name );
102
103/*****************************************************************
104* Function: __ql_gpio_set_level
105*
106* Description:
107* This function sets the level of the specified GPIO.
108*
109* Parameters:
110* pin_name:
111* Pin name, one value of INTERNAL_ENUM_PINNAME.
112* level:
113* The initial level of GPIO, one value of ENUM_PIN_LEVEL.
114* Return:
115* RES_OK, this function succeeds.
116* RES_IO_NOT_SUPPORT, the input GPIO is invalid.
117* RES_IO_ERR, the function failed
118* other place. For example this GPIO has been using as EINT.
119*****************************************************************/
120int __ql_gpio_set_level(INTERNAL_ENUM_PINNAME pin_name, ENUM_PIN_LEVEL level);
121
122/*****************************************************************
123* Function: __ql_gpio_get_level
124*
125* Description:
126* This function gets the level of the specified GPIO.
127*
128* Parameters:
129* pin_name:
130* Pin name, one value of INTERNAL_ENUM_PINNAME.
131* Return:
132* The level value of the specified GPIO, which is
133* nonnegative integer.
134* RES_IO_NOT_SUPPORT, the input GPIO is invalid.
135*****************************************************************/
136int __ql_gpio_get_level(INTERNAL_ENUM_PINNAME pin_name);
137
138/*****************************************************************
139* Function: __ql_gpio_set_direction
140*
141* Description:
142* This function sets the direction of the specified GPIO.
143*
144* Parameters:
145* pin_name:
146* Pin name, one value of INTERNAL_ENUM_PINNAME.
147* dir:
148* The initial direction of GPIO, one value of ENUM_PIN_DIRECTION.
149* Return:
150* RES_OK, this function succeeds.
151* RES_IO_NOT_SUPPORT, the input GPIO is invalid.
152* RES_IO_ERR, the function failed
153* other place. For example this GPIO has been using as EINT.
154*****************************************************************/
155int __ql_gpio_set_direction(INTERNAL_ENUM_PINNAME pin_name, ENUM_PIN_DIRECTION dir);
156
157/*****************************************************************
158* Function: __ql_gpio_get_direction
159*
160* Description:
161* This function gets the direction of the specified GPIO.
162*
163* Parameters:
164* pin_name:
165* Pin name, one value of INTERNAL_ENUM_PINNAME.
166* Return:
167* 0 INPUT
168* 1 OUTPUT
169* RES_IO_NOT_SUPPORT, the input GPIO is invalid.
170* other place. For example this GPIO has been using as EINT.
171*****************************************************************/
172int __ql_gpio_get_direction(INTERNAL_ENUM_PINNAME pin_name);
173
174
175/*****************************************************************
176* Function: __ql_gpio_set_pull_selection
177*
178* Description:
179* This function sets the pull selection of the specified GPIO.
180*
181* Parameters:
182* pin_name:
183* Pin name, one value of INTERNAL_ENUM_PINNAME.
184* ENUM_PIN_PULLSEL:
185* Pull selection, one value of ENUM_PIN_PULLSEL.
186* Return:
187* RES_OK, this function succeeds.
188* RES_IO_NOT_SUPPORT, the input GPIO is invalid.
189* RES_IO_ERR, the function failed
190* other place. For example this GPIO has been using as EINT.
191*****************************************************************/
192int __ql_gpio_set_pull_selection(INTERNAL_ENUM_PINNAME pin_name, ENUM_PIN_PULLSEL pull_sel);
193
194/*****************************************************************
195* Function: __ql_gpio_get_pull_selection
196*
197* Description:
198* This function gets the pull selection of the specified GPIO.
199*
200* Parameters:
201* pin_name:
202* Pin name, one value of INTERNAL_ENUM_PINNAME.
203* Return:
204* 0 no pull
205* 1 pull down
206* 3 pull up
207*****************************************************************/
208int __ql_gpio_get_pull_selection(INTERNAL_ENUM_PINNAME pin_name);
209
210/*****************************************************************
211* Function: __ql_gpio_uninit
212*
213* Description:
214* This function releases the specified GPIO that was
215* initialized by calling ql_gpio_init() previously.
216* After releasing, the GPIO can be used for other purpose.
217* Parameters:
218* pin_name:
219* Pin name, one value of INTERNAL_ENUM_PINNAME.
220* Return:
221* RES_OK, this function succeeds.
222* RES_IO_NOT_SUPPORT, the input GPIO is invalid.
223* RES_IO_ERR, the function failed
224* other place. For example this GPIO has been using as EINT.
225*****************************************************************/
226int __ql_gpio_uninit(INTERNAL_ENUM_PINNAME pin_name);
227
228//------------------------------------------------------------------------------
229/*
230* Function: __ql_eint_enable
231*
232* Description:
233* Set the interrupt sense mode, and enable interrupt.
234*
235* Parameters:
236* eint_pin_name:
237* EINT pin name, one value of INTERNAL_ENUM_PINNAME that has
238* the interrupt function.
239*
240* eint_type:
241* Interrupt type, level-triggered or edge-triggered.
242* Now, only edge-triggered interrupt is supported.
243*
244* eint_callback:
245* call back function
246*
247* Return:
248* RES_OK, this function succeeds.
249* else failed to execute the function.
250*/
251//------------------------------------------------------------------------------
252int __ql_eint_enable(INTERNAL_ENUM_PINNAME eint_pin_name, ENUM_EINT_TYPE eint_type, ql_eint_callback eint_callback);
253
254
255//------------------------------------------------------------------------------
256/*
257* Function: __ql_eint_disable
258*
259* Description:
260* Disable the interrupt sense.
261*
262* Parameters:
263* eint_pin_name:
264* EINT pin name, one value of INTERNAL_ENUM_PINNAME that has
265* the interrupt function.
266*
267* Return:
268* RES_OK, this function succeeds.
269* else failed to execute the function.
270*/
271//------------------------------------------------------------------------------
272int __ql_eint_disable(INTERNAL_ENUM_PINNAME eint_pin_name);
273
274
275/*-----------------------------------------------------------------------------------------------*/
276/**
277Function: __ql_set_gpio_function
278*
279* Description:
280* set pin function.
281*
282* Parameters:
283* pin_name:
284* EINT pin name, one value of INTERNAL_ENUM_PINNAME.
285* func:
286* pin function,value range from 0 to 7
287*
288* Return:
289* RES_OK, this function succeeds.
290* else failed to execute the function.
291*/
292/*-----------------------------------------------------------------------------------------------*/
293int __ql_set_gpio_function(INTERNAL_ENUM_PINNAME pin_name,unsigned int func);
294
295
296/*-----------------------------------------------------------------------------------------------*/
297/*Function: __ql_get_gpio_function
298*
299* Description:
300* get pin function.
301*
302* Parameters:
303* pin_name:
304* EINT pin name, one value of INTERNAL_ENUM_PINNAME.
305*
306* Return:
307* return 0-7, this function succeeds.
308* else failed to execute the function.
309*/
310/*-----------------------------------------------------------------------------------------------*/
311int __ql_get_gpio_function(INTERNAL_ENUM_PINNAME pin_name);
312
313/*-----------------------------------------------------------------------------------------------*/
314/*Function: __ql_check_pin_function_status
315*
316* Description:
317* Check whether the pin is gpio function.
318*
319* Parameters:
320* pin_name:
321* EINT pin name, one value of INTERNAL_ENUM_PINNAME.
322*
323* Return:
324* return 1, this pin is gpio function.
325* return 0, this pin is not gpio function.
326* else failed to execute the function.
327*/
328/*-----------------------------------------------------------------------------------------------*/
329int __ql_check_pin_function_status(INTERNAL_ENUM_PINNAME pin_name);
330
331#ifdef __cplusplus
332}
333#endif
334
335#endif