le_gpio_common.h

Go to the documentation of this file.
1 
2 /*
3  * ====================== WARNING ======================
4  *
5  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
6  * DO NOT MODIFY IN ANY WAY.
7  *
8  * ====================== WARNING ======================
9  */
10 /**
11  * @file le_gpio_common.h
12  *
13  * Type definitions for le_gpio.
14  *
15  */
16 #ifndef LE_GPIO_COMMON_H_INCLUDE_GUARD
17 #define LE_GPIO_COMMON_H_INCLUDE_GUARD
18 
19 
20 #include "legato.h"
21 
22 #define IFGEN_LE_GPIO_PROTOCOL_ID "eb4b6dc575d64f27484e7657275f11fd"
23 #define IFGEN_LE_GPIO_MSG_SIZE 20
24 /** @addtogroup le_gpio
25  * @{ **/
26 
27 
28 //--------------------------------------------------------------------------------------------------
29 /**
30  * Pin polarities.
31  */
32 //--------------------------------------------------------------------------------------------------
33 typedef enum
34 {
36  ///< GPIO active-high, output is 1
38  ///< GPIO active-low, output is 0
39 }
41 
42 
43 //--------------------------------------------------------------------------------------------------
44 /**
45  * Edge transitions.
46  */
47 //--------------------------------------------------------------------------------------------------
48 typedef enum
49 {
51  ///< No edge detection
53  ///< Notify when voltage goes from low to high.
55  ///< Notify when voltage goes from high to low.
57  ///< Notify when pin voltage changes state in either direction.
58 }
60 
61 
62 //--------------------------------------------------------------------------------------------------
63 /**
64  * Reference type used by Add/Remove functions for EVENT 'le_gpio_ChangeEvent'
65  */
66 //--------------------------------------------------------------------------------------------------
67 typedef struct le_gpio_ChangeEventHandler* le_gpio_ChangeEventHandlerRef_t;
68 
69 
70 //--------------------------------------------------------------------------------------------------
71 /**
72  * Pull up or down.
73  */
74 //--------------------------------------------------------------------------------------------------
75 typedef enum
76 {
78  ///< Neither resistor is enabled
80  ///< Pulldown resistor is enabled
82  ///< Pullup resistor is enabled
83 }
85 
86 
87 //--------------------------------------------------------------------------------------------------
88 /**
89  * State change event handler (callback).
90  */
91 //--------------------------------------------------------------------------------------------------
92 typedef void (*le_gpio_ChangeCallbackFunc_t)
93 (
94  bool state,
95  ///< New state of pin (true = active, false = inactive).
96  void* contextPtr
97  ///<
98 );
99 
100 
101 //--------------------------------------------------------------------------------------------------
102 /**
103  * Get if this client bound locally.
104  */
105 //--------------------------------------------------------------------------------------------------
106 LE_SHARED bool ifgen_le_gpio_HasLocalBinding
107 (
108  void
109 );
110 
111 
112 //--------------------------------------------------------------------------------------------------
113 /**
114  * Init data that is common across all threads
115  */
116 //--------------------------------------------------------------------------------------------------
117 LE_SHARED void ifgen_le_gpio_InitCommonData
118 (
119  void
120 );
121 
122 
123 //--------------------------------------------------------------------------------------------------
124 /**
125  * Perform common initialization and open a session
126  */
127 //--------------------------------------------------------------------------------------------------
128 LE_SHARED le_result_t ifgen_le_gpio_OpenSession
129 (
130  le_msg_SessionRef_t _ifgen_sessionRef,
131  bool isBlocking
132 );
133 
134 //--------------------------------------------------------------------------------------------------
135 /**
136  * Configure the pin as an input pin.
137  */
138 //--------------------------------------------------------------------------------------------------
139 LE_SHARED le_result_t ifgen_le_gpio_SetInput
140 (
141  le_msg_SessionRef_t _ifgen_sessionRef,
142  le_gpio_Polarity_t polarity
143  ///< [IN] Active-high or active-low.
144 );
145 
146 //--------------------------------------------------------------------------------------------------
147 /**
148  * Configure the pin as a push-pull output pin.
149  */
150 //--------------------------------------------------------------------------------------------------
151 LE_SHARED le_result_t ifgen_le_gpio_SetPushPullOutput
152 (
153  le_msg_SessionRef_t _ifgen_sessionRef,
154  le_gpio_Polarity_t polarity,
155  ///< [IN] Active-high or active-low.
156  bool value
157  ///< [IN] Initial value to drive (true = active, false = inactive)
158 );
159 
160 //--------------------------------------------------------------------------------------------------
161 /**
162  * Configure the pin as a tri-state output pin.
163  *
164  * @note The initial state will be high-impedance.
165  */
166 //--------------------------------------------------------------------------------------------------
167 LE_SHARED le_result_t ifgen_le_gpio_SetTriStateOutput
168 (
169  le_msg_SessionRef_t _ifgen_sessionRef,
170  le_gpio_Polarity_t polarity
171  ///< [IN] Active-high or active-low.
172 );
173 
174 //--------------------------------------------------------------------------------------------------
175 /**
176  * Configure the pin as an open-drain output pin. "High" is a high-impedance state, while "Low"
177  * pulls the pin to ground.
178  */
179 //--------------------------------------------------------------------------------------------------
180 LE_SHARED le_result_t ifgen_le_gpio_SetOpenDrainOutput
181 (
182  le_msg_SessionRef_t _ifgen_sessionRef,
183  le_gpio_Polarity_t polarity,
184  ///< [IN] Active-high or active-low.
185  bool value
186  ///< [IN] Initial value to drive (true = active, false = inactive)
187 );
188 
189 //--------------------------------------------------------------------------------------------------
190 /**
191  * Enable the pull-up resistor (disables pull-down if previously enabled).
192  */
193 //--------------------------------------------------------------------------------------------------
194 LE_SHARED le_result_t ifgen_le_gpio_EnablePullUp
195 (
196  le_msg_SessionRef_t _ifgen_sessionRef
197 );
198 
199 //--------------------------------------------------------------------------------------------------
200 /**
201  * Enable the pull-down resistor (disables pull-up if previously enabled).
202  */
203 //--------------------------------------------------------------------------------------------------
204 LE_SHARED le_result_t ifgen_le_gpio_EnablePullDown
205 (
206  le_msg_SessionRef_t _ifgen_sessionRef
207 );
208 
209 //--------------------------------------------------------------------------------------------------
210 /**
211  * Disable the pull-up and pull-down resistors. Does nothing if both are already disabled.
212  */
213 //--------------------------------------------------------------------------------------------------
214 LE_SHARED le_result_t ifgen_le_gpio_DisableResistors
215 (
216  le_msg_SessionRef_t _ifgen_sessionRef
217 );
218 
219 //--------------------------------------------------------------------------------------------------
220 /**
221  * Set output pin to active state.
222  *
223  * @warning Only valid for output pins.
224  */
225 //--------------------------------------------------------------------------------------------------
226 LE_SHARED le_result_t ifgen_le_gpio_Activate
227 (
228  le_msg_SessionRef_t _ifgen_sessionRef
229 );
230 
231 //--------------------------------------------------------------------------------------------------
232 /**
233  * Set output pin to inactive state.
234  *
235  * @warning Only valid for output pins.
236  */
237 //--------------------------------------------------------------------------------------------------
238 LE_SHARED le_result_t ifgen_le_gpio_Deactivate
239 (
240  le_msg_SessionRef_t _ifgen_sessionRef
241 );
242 
243 //--------------------------------------------------------------------------------------------------
244 /**
245  * Set output pin to high impedance state.
246  *
247  * @warning Only valid for tri-state or open-drain output pins.
248  */
249 //--------------------------------------------------------------------------------------------------
250 LE_SHARED le_result_t ifgen_le_gpio_SetHighZ
251 (
252  le_msg_SessionRef_t _ifgen_sessionRef
253 );
254 
255 //--------------------------------------------------------------------------------------------------
256 /**
257  * Read value of GPIO input pin.
258  *
259  * @return true = active, false = inactive.
260  *
261  * @note It is invalid to read an output pin.
262  */
263 //--------------------------------------------------------------------------------------------------
264 LE_SHARED bool ifgen_le_gpio_Read
265 (
266  le_msg_SessionRef_t _ifgen_sessionRef
267 );
268 
269 //--------------------------------------------------------------------------------------------------
270 /**
271  * Add handler function for EVENT 'le_gpio_ChangeEvent'
272  *
273  * Register a callback function to be called when an input pin changes state.
274  *
275  * If the pin is not capable of interrupt-driven operation, then it will be sampled every
276  * sampleMs milliseconds. Otherwise, sampleMs will be ignored.
277  *
278  * If this fails, either because the handler cannot be registered, or setting the
279  * edge detection fails, then it will return a NULL reference.
280  */
281 //--------------------------------------------------------------------------------------------------
282 LE_SHARED le_gpio_ChangeEventHandlerRef_t ifgen_le_gpio_AddChangeEventHandler
283 (
284  le_msg_SessionRef_t _ifgen_sessionRef,
285  le_gpio_Edge_t trigger,
286  ///< [IN] Change(s) that should trigger the callback to be called.
287  le_gpio_ChangeCallbackFunc_t handlerPtr,
288  ///< [IN] The callback function.
289  void* contextPtr,
290  ///< [IN]
291  int32_t sampleMs
292  ///< [IN] If not interrupt capable, sample the input this often (ms).
293 );
294 
295 //--------------------------------------------------------------------------------------------------
296 /**
297  * Remove handler function for EVENT 'le_gpio_ChangeEvent'
298  */
299 //--------------------------------------------------------------------------------------------------
300 LE_SHARED void ifgen_le_gpio_RemoveChangeEventHandler
301 (
302  le_msg_SessionRef_t _ifgen_sessionRef,
304  ///< [IN]
305 );
306 
307 //--------------------------------------------------------------------------------------------------
308 /**
309  * Set the edge detection mode. This function can only be used when a handler is registered
310  * in order to prevent interrupts being generated and not handled
311  */
312 //--------------------------------------------------------------------------------------------------
313 LE_SHARED le_result_t ifgen_le_gpio_SetEdgeSense
314 (
315  le_msg_SessionRef_t _ifgen_sessionRef,
316  le_gpio_Edge_t trigger
317  ///< [IN] Change(s) that should trigger the callback to be called.
318 );
319 
320 //--------------------------------------------------------------------------------------------------
321 /**
322  * Turn off edge detection
323  */
324 //--------------------------------------------------------------------------------------------------
325 LE_SHARED le_result_t ifgen_le_gpio_DisableEdgeSense
326 (
327  le_msg_SessionRef_t _ifgen_sessionRef
328 );
329 
330 //--------------------------------------------------------------------------------------------------
331 /**
332  * Check if the pin is configured as an output.
333  *
334  * @return true = output, false = input.
335  */
336 //--------------------------------------------------------------------------------------------------
337 LE_SHARED bool ifgen_le_gpio_IsOutput
338 (
339  le_msg_SessionRef_t _ifgen_sessionRef
340 );
341 
342 //--------------------------------------------------------------------------------------------------
343 /**
344  * Check if the pin is configured as an input.
345  *
346  * @return true = input, false = output.
347  */
348 //--------------------------------------------------------------------------------------------------
349 LE_SHARED bool ifgen_le_gpio_IsInput
350 (
351  le_msg_SessionRef_t _ifgen_sessionRef
352 );
353 
354 //--------------------------------------------------------------------------------------------------
355 /**
356  * Get the current value of edge sensing.
357  *
358  * @return The current configured value
359  *
360  * @note it is invalid to read the edge sense of an output
361  */
362 //--------------------------------------------------------------------------------------------------
363 LE_SHARED le_gpio_Edge_t ifgen_le_gpio_GetEdgeSense
364 (
365  le_msg_SessionRef_t _ifgen_sessionRef
366 );
367 
368 //--------------------------------------------------------------------------------------------------
369 /**
370  * Get the current value the pin polarity.
371  *
372  * @return The current configured value
373  */
374 //--------------------------------------------------------------------------------------------------
375 LE_SHARED le_gpio_Polarity_t ifgen_le_gpio_GetPolarity
376 (
377  le_msg_SessionRef_t _ifgen_sessionRef
378 );
379 
380 //--------------------------------------------------------------------------------------------------
381 /**
382  * Check if the pin is currently active.
383  *
384  * @return true = active, false = inactive.
385  *
386  * @note this function can only be used on output pins
387  */
388 //--------------------------------------------------------------------------------------------------
389 LE_SHARED bool ifgen_le_gpio_IsActive
390 (
391  le_msg_SessionRef_t _ifgen_sessionRef
392 );
393 
394 //--------------------------------------------------------------------------------------------------
395 /**
396  * Get the current value of pull up and down resistors.
397  *
398  * @return The current configured value
399  */
400 //--------------------------------------------------------------------------------------------------
401 LE_SHARED le_gpio_PullUpDown_t ifgen_le_gpio_GetPullUpDown
402 (
403  le_msg_SessionRef_t _ifgen_sessionRef
404 );
405 /** @} **/
406 #endif // LE_GPIO_COMMON_H_INCLUDE_GUARD
No edge detection.
Definition: le_gpio_common.h:50
GPIO active-high, output is 1.
Definition: le_gpio_common.h:35
void(* le_gpio_ChangeCallbackFunc_t)(bool state, void *contextPtr)
Definition: le_gpio_common.h:93
#define LE_SHARED
Definition: le_basics.h:287
le_result_t
Definition: le_basics.h:46
Notify when voltage goes from low to high.
Definition: le_gpio_common.h:52
struct le_gpio_ChangeEventHandler * le_gpio_ChangeEventHandlerRef_t
Definition: le_gpio_common.h:67
le_gpio_Edge_t
Definition: le_gpio_common.h:48
Notify when voltage goes from high to low.
Definition: le_gpio_common.h:54
Notify when pin voltage changes state in either direction.
Definition: le_gpio_common.h:56
GPIO active-low, output is 0.
Definition: le_gpio_common.h:37
Pulldown resistor is enabled.
Definition: le_gpio_common.h:79
Neither resistor is enabled.
Definition: le_gpio_common.h:77
struct le_msg_Session * le_msg_SessionRef_t
Definition: le_messaging.h:860
le_gpio_Polarity_t
Definition: le_gpio_common.h:33
le_gpio_PullUpDown_t
Definition: le_gpio_common.h:75
Pullup resistor is enabled.
Definition: le_gpio_common.h:81