le_gpio_interface.h File Reference

#include "legato.h"

Go to the source code of this file.

Typedefs

typedef void(* le_gpio_DisconnectHandler_t) (void *)
 
typedef struct le_gpio_ChangeEventHandler * le_gpio_ChangeEventHandlerRef_t
 
typedef void(* le_gpio_ChangeCallbackFunc_t) (bool state, void *contextPtr)
 

Enumerations

enum  le_gpio_Polarity_t { LE_GPIO_ACTIVE_HIGH = 0, LE_GPIO_ACTIVE_LOW = 1 }
 
enum  le_gpio_Edge_t { LE_GPIO_EDGE_NONE = 0, LE_GPIO_EDGE_RISING = 1, LE_GPIO_EDGE_FALLING = 2, LE_GPIO_EDGE_BOTH = 3 }
 
enum  le_gpio_PullUpDown_t { LE_GPIO_PULL_OFF = 0, LE_GPIO_PULL_DOWN = 1, LE_GPIO_PULL_UP = 2 }
 

Functions

void le_gpio_ConnectService (void)
 
le_result_t le_gpio_TryConnectService (void)
 
void le_gpio_SetServerDisconnectHandler (le_gpio_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
void le_gpio_DisconnectService (void)
 
le_result_t le_gpio_SetInput (le_gpio_Polarity_t polarity)
 
le_result_t le_gpio_SetPushPullOutput (le_gpio_Polarity_t polarity, bool value)
 
le_result_t le_gpio_SetTriStateOutput (le_gpio_Polarity_t polarity)
 
le_result_t le_gpio_SetOpenDrainOutput (le_gpio_Polarity_t polarity, bool value)
 
le_result_t le_gpio_EnablePullUp (void)
 
le_result_t le_gpio_EnablePullDown (void)
 
le_result_t le_gpio_DisableResistors (void)
 
le_result_t le_gpio_Activate (void)
 
le_result_t le_gpio_Deactivate (void)
 
le_result_t le_gpio_SetHighZ (void)
 
bool le_gpio_Read (void)
 
le_gpio_ChangeEventHandlerRef_t le_gpio_AddChangeEventHandler (le_gpio_Edge_t trigger, le_gpio_ChangeCallbackFunc_t handlerPtr, void *contextPtr, int32_t sampleMs)
 
void le_gpio_RemoveChangeEventHandler (le_gpio_ChangeEventHandlerRef_t handlerRef)
 
le_result_t le_gpio_SetEdgeSense (le_gpio_Edge_t trigger)
 
le_result_t le_gpio_DisableEdgeSense (void)
 
bool le_gpio_IsOutput (void)
 
bool le_gpio_IsInput (void)
 
le_gpio_Edge_t le_gpio_GetEdgeSense (void)
 
le_gpio_Polarity_t le_gpio_GetPolarity (void)
 
bool le_gpio_IsActive (void)
 
le_gpio_PullUpDown_t le_gpio_GetPullUpDown (void)
 

Detailed Description

Legato GPIO include file.

Typedef Documentation

◆ le_gpio_ChangeCallbackFunc_t

typedef void(* le_gpio_ChangeCallbackFunc_t) (bool state, void *contextPtr)

State change event handler (callback).

◆ le_gpio_ChangeEventHandlerRef_t

typedef struct le_gpio_ChangeEventHandler* le_gpio_ChangeEventHandlerRef_t

Reference type used by Add/Remove functions for EVENT 'le_gpio_ChangeEvent'

◆ le_gpio_DisconnectHandler_t

typedef void(* le_gpio_DisconnectHandler_t) (void *)

Type for handler called when a server disconnects.

Enumeration Type Documentation

◆ le_gpio_Edge_t

Edge transitions.

Enumerator
LE_GPIO_EDGE_NONE 

No edge detection.

LE_GPIO_EDGE_RISING 

Notify when voltage goes from low to high.

LE_GPIO_EDGE_FALLING 

Notify when voltage goes from high to low.

LE_GPIO_EDGE_BOTH 

Notify when pin voltage changes state in either direction.

◆ le_gpio_Polarity_t

Pin polarities.

Enumerator
LE_GPIO_ACTIVE_HIGH 

GPIO active-high, output is 1.

LE_GPIO_ACTIVE_LOW 

GPIO active-low, output is 0.

◆ le_gpio_PullUpDown_t

Pull up or down.

Enumerator
LE_GPIO_PULL_OFF 

Neither resistor is enabled.

LE_GPIO_PULL_DOWN 

Pulldown resistor is enabled.

LE_GPIO_PULL_UP 

Pullup resistor is enabled.

Function Documentation

◆ le_gpio_Activate()

le_result_t le_gpio_Activate ( void  )

Set output pin to active state.

Warning
Only valid for output pins.

◆ le_gpio_AddChangeEventHandler()

le_gpio_ChangeEventHandlerRef_t le_gpio_AddChangeEventHandler ( le_gpio_Edge_t  trigger,
le_gpio_ChangeCallbackFunc_t  handlerPtr,
void *  contextPtr,
int32_t  sampleMs 
)

Add handler function for EVENT 'le_gpio_ChangeEvent'

Register a callback function to be called when an input pin changes state.

If the pin is not capable of interrupt-driven operation, then it will be sampled every sampleMs milliseconds. Otherwise, sampleMs will be ignored.

If this fails, either because the handler cannot be registered, or setting the edge detection fails, then it will return a NULL reference.

Parameters
[in]triggerChange(s) that should trigger the callback to be called.
[in]handlerPtrThe callback function.
[in]contextPtr
[in]sampleMsIf not interrupt capable, sample the input this often (ms).

◆ le_gpio_ConnectService()

void le_gpio_ConnectService ( void  )

Connect the current client thread to the service providing this API. Block until the service is available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.

This function is created automatically.

◆ le_gpio_Deactivate()

le_result_t le_gpio_Deactivate ( void  )

Set output pin to inactive state.

Warning
Only valid for output pins.

◆ le_gpio_DisableEdgeSense()

le_result_t le_gpio_DisableEdgeSense ( void  )

Turn off edge detection

◆ le_gpio_DisableResistors()

le_result_t le_gpio_DisableResistors ( void  )

Disable the pull-up and pull-down resistors. Does nothing if both are already disabled.

◆ le_gpio_DisconnectService()

void le_gpio_DisconnectService ( void  )

Disconnect the current client thread from the service providing this API.

Normally, this function doesn't need to be called. After this function is called, there's no longer a connection to the service, and the functions in this API can't be used. For details, see Client-specific Functions.

This function is created automatically.

◆ le_gpio_EnablePullDown()

le_result_t le_gpio_EnablePullDown ( void  )

Enable the pull-down resistor (disables pull-up if previously enabled).

◆ le_gpio_EnablePullUp()

le_result_t le_gpio_EnablePullUp ( void  )

Enable the pull-up resistor (disables pull-down if previously enabled).

◆ le_gpio_GetEdgeSense()

le_gpio_Edge_t le_gpio_GetEdgeSense ( void  )

Get the current value of edge sensing.

Returns
The current configured value
Note
it is invalid to read the edge sense of an output

◆ le_gpio_GetPolarity()

le_gpio_Polarity_t le_gpio_GetPolarity ( void  )

Get the current value the pin polarity.

Returns
The current configured value

◆ le_gpio_GetPullUpDown()

le_gpio_PullUpDown_t le_gpio_GetPullUpDown ( void  )

Get the current value of pull up and down resistors.

Returns
The current configured value

◆ le_gpio_IsActive()

bool le_gpio_IsActive ( void  )

Check if the pin is currently active.

Returns
true = active, false = inactive.
Note
this function can only be used on output pins

◆ le_gpio_IsInput()

bool le_gpio_IsInput ( void  )

Check if the pin is configured as an input.

Returns
true = input, false = output.

◆ le_gpio_IsOutput()

bool le_gpio_IsOutput ( void  )

Check if the pin is configured as an output.

Returns
true = output, false = input.

◆ le_gpio_Read()

bool le_gpio_Read ( void  )

Read value of GPIO input pin.

Returns
true = active, false = inactive.
Note
It is invalid to read an output pin.

◆ le_gpio_RemoveChangeEventHandler()

void le_gpio_RemoveChangeEventHandler ( le_gpio_ChangeEventHandlerRef_t  handlerRef)

Remove handler function for EVENT 'le_gpio_ChangeEvent'

Parameters
[in]handlerRef

◆ le_gpio_SetEdgeSense()

le_result_t le_gpio_SetEdgeSense ( le_gpio_Edge_t  trigger)

Set the edge detection mode. This function can only be used when a handler is registered in order to prevent interrupts being generated and not handled

Parameters
[in]triggerChange(s) that should trigger the callback to be called.

◆ le_gpio_SetHighZ()

le_result_t le_gpio_SetHighZ ( void  )

Set output pin to high impedance state.

Warning
Only valid for tri-state or open-drain output pins.

◆ le_gpio_SetInput()

le_result_t le_gpio_SetInput ( le_gpio_Polarity_t  polarity)

Configure the pin as an input pin.

Parameters
[in]polarityActive-high or active-low.

◆ le_gpio_SetOpenDrainOutput()

le_result_t le_gpio_SetOpenDrainOutput ( le_gpio_Polarity_t  polarity,
bool  value 
)

Configure the pin as an open-drain output pin. "High" is a high-impedance state, while "Low" pulls the pin to ground.

Parameters
[in]polarityActive-high or active-low.
[in]valueInitial value to drive (true = active, false = inactive)

◆ le_gpio_SetPushPullOutput()

le_result_t le_gpio_SetPushPullOutput ( le_gpio_Polarity_t  polarity,
bool  value 
)

Configure the pin as a push-pull output pin.

Parameters
[in]polarityActive-high or active-low.
[in]valueInitial value to drive (true = active, false = inactive)

◆ le_gpio_SetServerDisconnectHandler()

void le_gpio_SetServerDisconnectHandler ( le_gpio_DisconnectHandler_t  disconnectHandler,
void *  contextPtr 
)

Set handler called when server disconnection is detected.

When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants to continue without exiting, it should call longjmp() from inside the handler.

◆ le_gpio_SetTriStateOutput()

le_result_t le_gpio_SetTriStateOutput ( le_gpio_Polarity_t  polarity)

Configure the pin as a tri-state output pin.

Note
The initial state will be high-impedance.
Parameters
[in]polarityActive-high or active-low.

◆ le_gpio_TryConnectService()

le_result_t le_gpio_TryConnectService ( void  )

Try to connect the current client thread to the service providing this API. Return with an error if the service is not available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.

This function is created automatically.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.