• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 /**
10  * @file pin_if.h
11  *
12  * @brief Declares the standard pin interface functions.
13  *
14  * @since 1.0
15  */
16 
17 #ifndef PIN_IF_H
18 #define PIN_IF_H
19 
20 #include "platform_if.h"
21 
22 #ifdef __cplusplus
23 #if __cplusplus
24 extern "C" {
25 #endif
26 #endif /* __cplusplus */
27 
28 /**
29  * @brief Enumerates pin pull types.
30  *
31  * @since 1.0
32  */
33 enum PinPullType {
34     PIN_PULL_NONE = 0,      /**< SET PIN SUSPEND. */
35     PIN_PULL_UP =  1,       /**< SET PIN RESISTANCE UP. */
36     PIN_PULL_DOWN = 2,      /**< SET PIN RESISTANCE DOWN. */
37 };
38 
39 /**
40  * @brief Obtains the handle of a pin.
41  *
42  * You must call this function before setting a pin properties.
43  *
44  * @param pinName Indicates the pin which you want to setting properties.
45  *
46  * @return Returns the pointer to the {@link DevHandle} of the pin controller which
47  * to get a pin if the operation is successful;
48  * returns <b>NULL</b> otherwise.
49  * @since 1.0
50  */
51 DevHandle PinGet(const char *pinName);
52 
53 /**
54  * @brief Enumerates PIN I/O commands.
55  *
56  * @since 1.0
57  */
58 enum PinIoCmd {
59     PIN_IO_GET = 0,
60     PIN_IO_PUT = 1,
61     PIN_IO_SET_PULL = 2,
62     PIN_IO_GET_PULL = 3,
63     PIN_IO_SET_STRENGTH = 4,
64     PIN_IO_GET_STRENGTH = 5,
65     PIN_IO_SET_FUNC = 6,
66     PIN_IO_GET_FUNC = 7,
67 };
68 
69 /**
70  * @brief Releases the handle of a pin.
71  *
72  * If you no longer need to access the pin, you should call this function to close its handle so as
73  * to release unused memory resources.
74  *
75  * @param handle Indicates the pointer to the device handle of the pin.
76  *
77  * @since 1.0
78  */
79 void PinPut(DevHandle handle);
80 
81 /**
82  * @brief Set the pin pullType configuration.
83  *
84  * You can call this function when you need to set the pin pull configuration.
85  * @param handle Indicates the pointer to the device handle of the pin.
86  * @param pullType Indicates the type of pin pull.
87  *
88  * @return Returns <b>0</b> if set the pin Pull configuration operation is successfully;
89  * Returns a negative value otherwise.
90  * @since 1.0
91  */
92 int32_t PinSetPull(DevHandle handle, enum PinPullType pullType);
93 
94 /**
95  * @brief Get the pin pullType configuration.
96  *
97  * You can call this function when you need to get the pin pull configuration.
98  *
99  * @param handle Indicates the pointer to the device handle of the pin.
100  * @param pullType Indicates the pointer of the Pin Pull Type.
101  * @return Returns <b>0</b> if get the pin Pull configuration operation is successfully;
102  * Returns a negative value otherwise.
103  * @since 1.0
104  */
105 int32_t PinGetPull(DevHandle handle, enum PinPullType *pullType);
106 
107 /**
108  * @brief Set the pin strength configuration.
109  *
110  * You can call this function when you need to set the pin strength configuration.
111  * @param handle Indicates the pointer to the device handle of the pin.
112  * @param strength Indicates the value of pin strength.
113  *
114  * @return Returns <b>0</b> if set the pin strength configuration operation is successfully;
115  * Returns a negative value otherwise.
116  * @since 1.0
117  */
118 int32_t PinSetStrength(DevHandle handle, uint32_t strength);
119 
120 /**
121  * @brief Get the pin strength configuration.
122  *
123  * You can call this function when you need to get the pin strength configuration.
124  *
125  * @param handle Indicates the pointer to the device handle of the pin.
126  * @param strength Indicates the pointer of the Pin strength value.
127  * @return Returns <b>0</b> if get the pin strength configuration operation is successfully;
128  * Returns a negative value otherwise.
129  * @since 1.0
130  */
131 int32_t PinGetStrength(DevHandle handle, uint32_t *strength);
132 
133 /**
134  * @brief Set the pin function configuration.
135  *
136  * You can call this function when you need to set the pin function configuration.
137  *
138  * @param handle Indicates the pointer to the device handle of the pin description.
139  * @param funcName Indicates the pointer of the pin function.
140  * @return Returns <b>0</b> if set the pin function configuration operation is successfully;
141  * returns a negative value otherwise.
142  * @since 1.0
143  */
144 int32_t PinSetFunc(DevHandle handle, const char *funcName);
145 
146 /**
147  * @brief Get the pin function configuration.
148  *
149  * You can call this function when you need to get the pin function configuration.
150  *
151  * @param handle Indicates the pointer to the device handle of the pin description.
152  * @param funcName Indicates the double pointer of the pin function.
153  * @return Returns <b>0</b> if get the pin function configuration operation is successfully;
154  * returns a negative value otherwise.
155  * @since 1.0
156  */
157 int32_t PinGetFunc(DevHandle handle, const char **funcName);
158 
159 #ifdef __cplusplus
160 #if __cplusplus
161 }
162 #endif
163 #endif /* __cplusplus */
164 
165 #endif /* PIN_IF_H */
166