• 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  * @brief Obtains the handle of a pin.
40  *
41  * You must call this function before setting a pin properties.
42  *
43  * @param pinName Indicates the pin which you want to setting properties.
44  *
45  * @return Returns the pointer to the {@link DevHandle} of the pin controller which
46  * to get a pin if the operation is successful;
47  * returns <b>NULL</b> otherwise.
48  * @since 1.0
49  */
50 DevHandle PinGet(const char *pinName);
51 
52 /**
53  * @brief Releases the handle of a pin.
54  *
55  * If you no longer need to access the pin, you should call this function to close its handle so as
56  * to release unused memory resources.
57  *
58  * @param handle Indicates the pointer to the device handle of the pin.
59  *
60  * @since 1.0
61  */
62 void PinPut(DevHandle handle);
63 
64 /**
65  * @brief Set the pin pullType configuration.
66  *
67  * You can call this function when you need to set the pin pull configuration.
68  * @param handle Indicates the pointer to the device handle of the pin.
69  * @param pullType Indicates the type of pin pull.
70  *
71  * @return Returns <b>0</b> if set the pin Pull configuration operation is successfully;
72  * Returns a negative value otherwise.
73  * @since 1.0
74  */
75 int32_t PinSetPull(DevHandle handle, enum PinPullType pullType);
76 
77 /**
78  * @brief Get the pin pullType configuration.
79  *
80  * You can call this function when you need to get the pin pull configuration.
81  *
82  * @param handle Indicates the pointer to the device handle of the pin.
83  * @param pullType Indicates the pointer of the Pin Pull Type.
84  * @return Returns <b>0</b> if get the pin Pull configuration operation is successfully;
85  * Returns a negative value otherwise.
86  * @since 1.0
87  */
88 int32_t PinGetPull(DevHandle handle, enum PinPullType *pullType);
89 
90 /**
91  * @brief Set the pin strength configuration.
92  *
93  * You can call this function when you need to set the pin strength configuration.
94  * @param handle Indicates the pointer to the device handle of the pin.
95  * @param strength Indicates the value of pin strength.
96  *
97  * @return Returns <b>0</b> if set the pin strength configuration operation is successfully;
98  * Returns a negative value otherwise.
99  * @since 1.0
100  */
101 int32_t PinSetStrength(DevHandle handle, uint32_t strength);
102 
103 /**
104  * @brief Get the pin strength configuration.
105  *
106  * You can call this function when you need to get the pin strength configuration.
107  *
108  * @param handle Indicates the pointer to the device handle of the pin.
109  * @param strength Indicates the pointer of the Pin strength value.
110  * @return Returns <b>0</b> if get the pin strength configuration operation is successfully;
111  * Returns a negative value otherwise.
112  * @since 1.0
113  */
114 int32_t PinGetStrength(DevHandle handle, uint32_t *strength);
115 
116 /**
117  * @brief Set the pin function configuration.
118  *
119  * You can call this function when you need to set the pin function configuration.
120  *
121  * @param handle Indicates the pointer to the device handle of the pin description.
122  * @param funcName Indicates the pointer of the pin function.
123  * @return Returns <b>0</b> if set the pin function configuration operation is successfully;
124  * returns a negative value otherwise.
125  * @since 1.0
126  */
127 int32_t PinSetFunc(DevHandle handle, const char *funcName);
128 
129 /**
130  * @brief Get the pin function configuration.
131  *
132  * You can call this function when you need to get the pin function configuration.
133  *
134  * @param handle Indicates the pointer to the device handle of the pin description.
135  * @param funcName Indicates the double pointer of the pin function.
136  * @return Returns <b>0</b> if get the pin function configuration operation is successfully;
137  * returns a negative value otherwise.
138  * @since 1.0
139  */
140 int32_t PinGetFunc(DevHandle handle, const char **funcName);
141 
142 #ifdef __cplusplus
143 #if __cplusplus
144 }
145 #endif
146 #endif /* __cplusplus */
147 
148 #endif /* PIN_IF_H */
149