Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
gpio.h File Reference

Go to the source code of this file.

Data Structures

struct  _GPIO_PROPERTIES
struct  _GPIO_EVENT
struct  _GPIO_PIN
struct  _GPIO_DEVICE
struct  _GPIO_INFO

Macros

#define GPIO_NAME_PREFIX   "GPIO"
 Name prefix for GPIO Devices.
#define GPIO_TYPE_NONE   0
#define GPIO_TYPE_MAX   0
#define GPIO_STATE_DISABLED   0
#define GPIO_STATE_ENABLED   1
#define GPIO_STATE_MAX   1
#define GPIO_FLAG_NONE   0x00000000
#define GPIO_FLAG_PULL_UP   0x00000001
 Device supports Pull Up on a pin.
#define GPIO_FLAG_PULL_DOWN   0x00000002
 Device supports Pull Down on a pin.
#define GPIO_FLAG_TRIGGER_LOW   0x00000004
 Device supports Trigger on Low level on a pin.
#define GPIO_FLAG_TRIGGER_HIGH   0x00000008
 Device supports Trigger on High level on a pin.
#define GPIO_FLAG_TRIGGER_RISING   0x00000010
 Device supports Trigger on Rising edge on a pin.
#define GPIO_FLAG_TRIGGER_FALLING   0x00000020
 Device supports Trigger on Falling edge on a pin.
#define GPIO_FLAG_TRIGGER_EDGE   0x00000040
 Device supports Trigger on any edge (Rising or Falling) on a pin.
#define GPIO_FLAG_TRIGGER_ASYNC   0x00000080
 Device supports Trigger on Asynchronous Rising/Falling edge on a pin.
#define GPIO_EVENT_FLAG_NONE   0x00000000
#define GPIO_EVENT_FLAG_REPEAT   0x00000001
 Event will be repeated until cancelled.
#define GPIO_EVENT_FLAG_INTERRUPT   0x00000002
 Event will be dispatched by interrupt handler (If applicable).

Typedefs

typedef struct _GPIO_PROPERTIES GPIO_PROPERTIES
typedef struct _GPIO_DEVICE GPIO_DEVICE
 Forward declared for GPIOPin.
typedef struct _GPIO_PIN GPIO_PIN
 Forward declared for GPIOEvent.
typedef struct _GPIO_EVENT GPIO_EVENT
typedef uint32_t STDCALL(* gpio_enumerate_cb) (GPIO_DEVICE *gpio, void *data)
typedef uint32_t STDCALL(* gpio_notification_cb) (DEVICE *device, void *data, uint32_t notification)
typedef uint32_t STDCALL(* gpio_device_start_proc) (GPIO_DEVICE *gpio)
typedef uint32_t STDCALL(* gpio_device_stop_proc) (GPIO_DEVICE *gpio)
typedef uint32_t STDCALL(* gpio_device_read_proc) (GPIO_DEVICE *gpio, uint32_t reg)
typedef void STDCALL(* gpio_device_write_proc) (GPIO_DEVICE *gpio, uint32_t reg, uint32_t value)
typedef uint32_t STDCALL(* gpio_device_input_get_proc) (GPIO_DEVICE *gpio, uint32_t pin)
typedef uint32_t STDCALL(* gpio_device_input_wait_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t trigger, uint32_t timeout)
typedef uint32_t STDCALL(* gpio_device_input_event_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t trigger, uint32_t flags, uint32_t timeout, gpio_event_cb callback, void *data)
typedef uint32_t STDCALL(* gpio_device_input_cancel_proc) (GPIO_DEVICE *gpio, uint32_t pin)
typedef uint32_t STDCALL(* gpio_device_output_set_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t level)
typedef uint32_t STDCALL(* gpio_device_pull_get_proc) (GPIO_DEVICE *gpio, uint32_t pin)
typedef uint32_t STDCALL(* gpio_device_pull_select_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t mode)
typedef uint32_t STDCALL(* gpio_device_function_get_proc) (GPIO_DEVICE *gpio, uint32_t pin)
typedef uint32_t STDCALL(* gpio_device_function_select_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t mode)
typedef uint32_t STDCALL(* gpio_device_get_properties_proc) (GPIO_DEVICE *gpio, GPIO_PROPERTIES *properties)
typedef struct _GPIO_INFO GPIO_INFO

Functions

uint32_t STDCALL gpio_device_start (GPIO_DEVICE *gpio)
 Start the specified GPIO device and enable access.
uint32_t STDCALL gpio_device_stop (GPIO_DEVICE *gpio)
 Stop the specified GPIO device and disable access.
uint32_t STDCALL gpio_device_read (GPIO_DEVICE *gpio, uint32_t reg)
 Perform a direct read from a register of the specified GPIO device.
void STDCALL gpio_device_write (GPIO_DEVICE *gpio, uint32_t reg, uint32_t value)
 Perform a direct write to a register of the specified GPIO device.
uint32_t STDCALL gpio_device_input_get (GPIO_DEVICE *gpio, uint32_t pin)
 Get the current state of an input pin on the specified GPIO device.
uint32_t STDCALL gpio_device_input_wait (GPIO_DEVICE *gpio, uint32_t pin, uint32_t trigger, uint32_t timeout)
 Wait for the state of a input pin to change on the specified GPIO device.
uint32_t STDCALL gpio_device_input_event (GPIO_DEVICE *gpio, uint32_t pin, uint32_t trigger, uint32_t flags, uint32_t timeout, gpio_event_cb callback, void *data)
 Schedule a function to be called when the state of a input pin changes on the specified GPIO device.
uint32_t STDCALL gpio_device_input_cancel (GPIO_DEVICE *gpio, uint32_t pin)
 Cancel a previously scheduled event callback function for an input pin on the specified GPIO device.
uint32_t STDCALL gpio_device_output_set (GPIO_DEVICE *gpio, uint32_t pin, uint32_t level)
 Set the state of a output pin on the specified GPIO device.
uint32_t STDCALL gpio_device_level_get (GPIO_DEVICE *gpio, uint32_t pin)
 Get the current level (state) of a pin on the specified GPIO device.
uint32_t STDCALL gpio_device_level_set (GPIO_DEVICE *gpio, uint32_t pin, uint32_t level)
 Set the level (state) of a pin on the specified GPIO device.
uint32_t STDCALL gpio_device_pull_get (GPIO_DEVICE *gpio, uint32_t pin)
 Get the current pull state of a pin on the specified GPIO device.
uint32_t STDCALL gpio_device_pull_select (GPIO_DEVICE *gpio, uint32_t pin, uint32_t mode)
 Change the pull state of a pin on the specified GPIO device.
uint32_t STDCALL gpio_device_function_get (GPIO_DEVICE *gpio, uint32_t pin)
 Get the current function of a pin on the specified GPIO device.
uint32_t STDCALL gpio_device_function_select (GPIO_DEVICE *gpio, uint32_t pin, uint32_t mode)
 Change the function of a pin on the specified GPIO device.
uint32_t STDCALL gpio_device_properties (GPIO_DEVICE *gpio, GPIO_PROPERTIES *properties)
 Get the properties for the specified GPIO device.
uint32_t STDCALL gpio_device_get_properties (GPIO_DEVICE *gpio, GPIO_PROPERTIES *properties)
 Get the properties for the specified GPIO device.
GPIO_DEVICE *STDCALL gpio_device_create (void)
 Create a new GPIO entry.
GPIO_DEVICE *STDCALL gpio_device_create_ex (uint32_t size)
 Create a new GPIO entry.
uint32_t STDCALL gpio_device_destroy (GPIO_DEVICE *gpio)
 Destroy an existing GPIO entry.
uint32_t STDCALL gpio_device_register (GPIO_DEVICE *gpio)
 Register a new GPIO in the GPIO table.
uint32_t STDCALL gpio_device_deregister (GPIO_DEVICE *gpio)
 Deregister a GPIO from the GPIO table.
GPIO_DEVICE *STDCALL gpio_device_find (uint32_t gpioid)
 Find a GPIO device by ID in the GPIO table.
GPIO_DEVICE *STDCALL gpio_device_find_by_name (const char *name)
 Find a GPIO device by name in the GPIO table.
GPIO_DEVICE *STDCALL gpio_device_find_by_description (const char *description)
 Find a GPIO device by description in the GPIO table.
uint32_t STDCALL gpio_device_enumerate (gpio_enumerate_cb callback, void *data)
 Enumerate all GPIO devices in the GPIO table.
uint32_t STDCALL gpio_device_notification (GPIO_DEVICE *gpio, gpio_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
 Register a notification for GPIO device changes.
uint32_t STDCALL gpio_get_count (void)
 Get the current GPIO count.
GPIO_DEVICE *STDCALL gpio_device_get_default (void)
 Get the current default GPIO device.
uint32_t STDCALL gpio_device_set_default (GPIO_DEVICE *gpio)
 Set the current default GPIO device.
GPIO_DEVICE *STDCALL gpio_device_check (GPIO_DEVICE *gpio)
 Check if the supplied GPIO is in the GPIO table.
uint32_t STDCALL gpio_type_to_string (uint32_t gpiotype, char *string, uint32_t len)
 Convert a GPIO type value to a string.
uint32_t STDCALL gpio_state_to_string (uint32_t gpiostate, char *string, uint32_t len)
 Convert a GPIO state value to a string.
GPIO_EVENT *STDCALL gpio_device_create_event (GPIO_DEVICE *gpio, GPIO_PIN *pin, gpio_event_cb callback, void *data, uint32_t timeout)
 Create a new event using the supplied parameters.
uint32_t STDCALL gpio_device_destroy_event (GPIO_DEVICE *gpio, GPIO_EVENT *event)
 Destroy an existing event.
uint32_t STDCALL gpio_device_register_event (GPIO_DEVICE *gpio, GPIO_PIN *pin, GPIO_EVENT *event)
 Register an event in the event list of the supplied Pin.
uint32_t STDCALL gpio_device_deregister_event (GPIO_DEVICE *gpio, GPIO_PIN *pin, GPIO_EVENT *event)
 Deregister an event from the event list of the supplied Pin.
uint32_t STDCALL gpio_pin_to_string (uint32_t pin, char *string, uint32_t len)
uint32_t STDCALL gpio_level_to_string (uint32_t level, char *string, uint32_t len)
uint32_t STDCALL gpio_trigger_to_string (uint32_t trigger, char *string, uint32_t len)
uint32_t STDCALL gpio_pull_to_string (uint32_t value, char *string, uint32_t len)
uint32_t STDCALL gpio_function_to_string (uint32_t value, char *string, uint32_t len)

Macro Definition Documentation

◆ GPIO_NAME_PREFIX

#define GPIO_NAME_PREFIX   "GPIO"

Name prefix for GPIO Devices.

GPIO specific constants

◆ GPIO_TYPE_NONE

#define GPIO_TYPE_NONE   0

GPIO Device Types

◆ GPIO_TYPE_MAX

#define GPIO_TYPE_MAX   0

◆ GPIO_STATE_DISABLED

#define GPIO_STATE_DISABLED   0

GPIO Device States

◆ GPIO_STATE_ENABLED

#define GPIO_STATE_ENABLED   1

◆ GPIO_STATE_MAX

#define GPIO_STATE_MAX   1

◆ GPIO_FLAG_NONE

#define GPIO_FLAG_NONE   0x00000000

GPIO Device Flags

◆ GPIO_FLAG_PULL_UP

#define GPIO_FLAG_PULL_UP   0x00000001

Device supports Pull Up on a pin.

◆ GPIO_FLAG_PULL_DOWN

#define GPIO_FLAG_PULL_DOWN   0x00000002

Device supports Pull Down on a pin.

◆ GPIO_FLAG_TRIGGER_LOW

#define GPIO_FLAG_TRIGGER_LOW   0x00000004

Device supports Trigger on Low level on a pin.

◆ GPIO_FLAG_TRIGGER_HIGH

#define GPIO_FLAG_TRIGGER_HIGH   0x00000008

Device supports Trigger on High level on a pin.

◆ GPIO_FLAG_TRIGGER_RISING

#define GPIO_FLAG_TRIGGER_RISING   0x00000010

Device supports Trigger on Rising edge on a pin.

◆ GPIO_FLAG_TRIGGER_FALLING

#define GPIO_FLAG_TRIGGER_FALLING   0x00000020

Device supports Trigger on Falling edge on a pin.

◆ GPIO_FLAG_TRIGGER_EDGE

#define GPIO_FLAG_TRIGGER_EDGE   0x00000040

Device supports Trigger on any edge (Rising or Falling) on a pin.

◆ GPIO_FLAG_TRIGGER_ASYNC

#define GPIO_FLAG_TRIGGER_ASYNC   0x00000080

Device supports Trigger on Asynchronous Rising/Falling edge on a pin.

◆ GPIO_EVENT_FLAG_NONE

#define GPIO_EVENT_FLAG_NONE   0x00000000

GPIO Event Flags

◆ GPIO_EVENT_FLAG_REPEAT

#define GPIO_EVENT_FLAG_REPEAT   0x00000001

Event will be repeated until cancelled.

◆ GPIO_EVENT_FLAG_INTERRUPT

#define GPIO_EVENT_FLAG_INTERRUPT   0x00000002

Event will be dispatched by interrupt handler (If applicable).

Typedef Documentation

◆ GPIO_PROPERTIES

GPIO specific types GPIO Properties

◆ GPIO_DEVICE

typedef struct _GPIO_DEVICE GPIO_DEVICE

Forward declared for GPIOPin.

GPIO Device

◆ GPIO_PIN

typedef struct _GPIO_PIN GPIO_PIN

Forward declared for GPIOEvent.

◆ GPIO_EVENT

typedef struct _GPIO_EVENT GPIO_EVENT

GPIO Event

◆ gpio_enumerate_cb

typedef uint32_t STDCALL(* gpio_enumerate_cb) (GPIO_DEVICE *gpio, void *data)

GPIO Enumeration Callback

◆ gpio_notification_cb

typedef uint32_t STDCALL(* gpio_notification_cb) (DEVICE *device, void *data, uint32_t notification)

GPIO Notification Callback

◆ gpio_device_start_proc

typedef uint32_t STDCALL(* gpio_device_start_proc) (GPIO_DEVICE *gpio)

GPIO Device Methods

◆ gpio_device_stop_proc

typedef uint32_t STDCALL(* gpio_device_stop_proc) (GPIO_DEVICE *gpio)

◆ gpio_device_read_proc

typedef uint32_t STDCALL(* gpio_device_read_proc) (GPIO_DEVICE *gpio, uint32_t reg)

◆ gpio_device_write_proc

typedef void STDCALL(* gpio_device_write_proc) (GPIO_DEVICE *gpio, uint32_t reg, uint32_t value)

◆ gpio_device_input_get_proc

typedef uint32_t STDCALL(* gpio_device_input_get_proc) (GPIO_DEVICE *gpio, uint32_t pin)

◆ gpio_device_input_wait_proc

typedef uint32_t STDCALL(* gpio_device_input_wait_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t trigger, uint32_t timeout)

◆ gpio_device_input_event_proc

typedef uint32_t STDCALL(* gpio_device_input_event_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t trigger, uint32_t flags, uint32_t timeout, gpio_event_cb callback, void *data)

◆ gpio_device_input_cancel_proc

typedef uint32_t STDCALL(* gpio_device_input_cancel_proc) (GPIO_DEVICE *gpio, uint32_t pin)

◆ gpio_device_output_set_proc

typedef uint32_t STDCALL(* gpio_device_output_set_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t level)

◆ gpio_device_pull_get_proc

typedef uint32_t STDCALL(* gpio_device_pull_get_proc) (GPIO_DEVICE *gpio, uint32_t pin)

◆ gpio_device_pull_select_proc

typedef uint32_t STDCALL(* gpio_device_pull_select_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t mode)

◆ gpio_device_function_get_proc

typedef uint32_t STDCALL(* gpio_device_function_get_proc) (GPIO_DEVICE *gpio, uint32_t pin)

◆ gpio_device_function_select_proc

typedef uint32_t STDCALL(* gpio_device_function_select_proc) (GPIO_DEVICE *gpio, uint32_t pin, uint32_t mode)

◆ gpio_device_get_properties_proc

typedef uint32_t STDCALL(* gpio_device_get_properties_proc) (GPIO_DEVICE *gpio, GPIO_PROPERTIES *properties)

◆ GPIO_INFO

typedef struct _GPIO_INFO GPIO_INFO

GPIO Info (Pin Information)

Function Documentation

◆ gpio_device_start()

uint32_t STDCALL gpio_device_start ( GPIO_DEVICE * gpio)

Start the specified GPIO device and enable access.

GPIO Functions

Parameters
GPIOThe GPIO device to start
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ gpio_device_stop()

uint32_t STDCALL gpio_device_stop ( GPIO_DEVICE * gpio)

Stop the specified GPIO device and disable access.

Parameters
GPIOThe GPIO device to stop
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ gpio_device_read()

uint32_t STDCALL gpio_device_read ( GPIO_DEVICE * gpio,
uint32_t reg )

Perform a direct read from a register of the specified GPIO device.

Parameters
GPIOThe GPIO device to read from
RegThe memory register to read from
Returns
The value of the memory register

◆ gpio_device_write()

void STDCALL gpio_device_write ( GPIO_DEVICE * gpio,
uint32_t reg,
uint32_t value )

Perform a direct write to a register of the specified GPIO device.

Parameters
GPIOThe GPIO device to write to
RegThe memory register to write to
ValueThe value to write to the register

◆ gpio_device_input_get()

uint32_t STDCALL gpio_device_input_get ( GPIO_DEVICE * gpio,
uint32_t pin )

Get the current state of an input pin on the specified GPIO device.

Parameters
GPIOThe GPIO device to get from
PinThe pin to get the state for (eg GPIO_PIN_1)
Returns
The current state (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure

◆ gpio_device_input_wait()

uint32_t STDCALL gpio_device_input_wait ( GPIO_DEVICE * gpio,
uint32_t pin,
uint32_t trigger,
uint32_t timeout )

Wait for the state of a input pin to change on the specified GPIO device.

Parameters
GPIOThe GPIO device to wait for
PinThe pin to wait for the state to change (eg GPIO_PIN_1)
TriggerThe trigger event to wait for (eg GPIO_TRIGGER_HIGH)
TimeoutNumber of milliseconds to wait for the change (INFINITE to wait forever)
Returns
The state after the change (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure or timeout

◆ gpio_device_input_event()

uint32_t STDCALL gpio_device_input_event ( GPIO_DEVICE * gpio,
uint32_t pin,
uint32_t trigger,
uint32_t flags,
uint32_t timeout,
gpio_event_cb callback,
void * data )

Schedule a function to be called when the state of a input pin changes on the specified GPIO device.

Parameters
GPIOThe GPIO device to schedule the callback for
PinThe pin to schedule the state change for (eg GPIO_PIN_1)
TriggerThe trigger event which will cause the function to be called (eg GPIO_TRIGGER_HIGH)
FlagsThe flags to control the event (eg GPIO_EVENT_FLAG_REPEAT)
TimeoutThe number of milliseconds before the scheduled trigger expires (INFINITE to never expire)
CallbackThe function to be called when the trigger occurs
DataA pointer to be pass to the function when the trigger occurs (Optional)
Returns
ERROR_SUCCESS if the trigger was scheduled successfully or another error code on failure
Note
The pin and trigger that caused the event will be passed to the callback function

◆ gpio_device_input_cancel()

uint32_t STDCALL gpio_device_input_cancel ( GPIO_DEVICE * gpio,
uint32_t pin )

Cancel a previously scheduled event callback function for an input pin on the specified GPIO device.

Parameters
GPIOThe GPIO device to cancel the callback for
PinThe pin to cancel the state change for (eg GPIO_PIN_1)
Returns
ERROR_SUCCESS if the callback was cancelled successfully or another error code on failure

◆ gpio_device_output_set()

uint32_t STDCALL gpio_device_output_set ( GPIO_DEVICE * gpio,
uint32_t pin,
uint32_t level )

Set the state of a output pin on the specified GPIO device.

Parameters
GPIOThe GPIO device to set for
PinThe pin to set the state for (eg GPIO_PIN_1)
LevelThe state to set the pin to (eg GPIO_LEVEL_HIGH)
Returns
ERROR_SUCCESS if completed successfully or another error code on failure

◆ gpio_device_level_get()

uint32_t STDCALL gpio_device_level_get ( GPIO_DEVICE * gpio,
uint32_t pin )

Get the current level (state) of a pin on the specified GPIO device.

Parameters
GPIOThe GPIO device to get from
PinThe pin to get the level for (eg GPIO_PIN_1)
Returns
The current level (eg GPIO_LEVEL_HIGH) or GPIO_LEVEL_UNKNOWN on failure
Note
This function is a synonym for GPIODeviceInputGet as in many cases the level can be read from a pin regardless of input or output mode. This may help to make code clearer or easier to understand in some cases

◆ gpio_device_level_set()

uint32_t STDCALL gpio_device_level_set ( GPIO_DEVICE * gpio,
uint32_t pin,
uint32_t level )

Set the level (state) of a pin on the specified GPIO device.

Parameters
GPIOThe GPIO device to set for
PinThe pin to set the level for (eg GPIO_PIN_1)
LevelThe level to set the pin to (eg GPIO_LEVEL_HIGH)
Returns
ERROR_SUCCESS if completed successfully or another error code on failure
Note
This function is a synonym for GPIODeviceOutputSet as in many cases the level can be set for a pin regardless of input or output mode. This may help to make code clearer or easier to understand in some cases

◆ gpio_device_pull_get()

uint32_t STDCALL gpio_device_pull_get ( GPIO_DEVICE * gpio,
uint32_t pin )

Get the current pull state of a pin on the specified GPIO device.

Parameters
GPIOThe GPIO device to get from
PinThe pin to get the pull state for (eg GPIO_PIN_1)
Returns
The current pull state of the pin (eg GPIO_PULL_UP) or GPIO_PULL_UNKNOWN on failure

◆ gpio_device_pull_select()

uint32_t STDCALL gpio_device_pull_select ( GPIO_DEVICE * gpio,
uint32_t pin,
uint32_t mode )

Change the pull state of a pin on the specified GPIO device.

Parameters
GPIOThe GPIO device to set for
PinThe pin to change the pull state for (eg GPIO_PIN_1)
ModeThe pull state to set for the pin (eg GPIO_PULL_UP)
Returns
ERROR_SUCCESS if completed successfully or another error code on failure

◆ gpio_device_function_get()

uint32_t STDCALL gpio_device_function_get ( GPIO_DEVICE * gpio,
uint32_t pin )

Get the current function of a pin on the specified GPIO device.

Parameters
GPIOThe GPIO device to get from
PinThe pin to get the function for (eg GPIO_PIN_1)
Returns
The current function of the pin (eg GPIO_FUNCTION_IN) or GPIO_FUNCTION_UNKNOWN on failure

◆ gpio_device_function_select()

uint32_t STDCALL gpio_device_function_select ( GPIO_DEVICE * gpio,
uint32_t pin,
uint32_t mode )

Change the function of a pin on the specified GPIO device.

Parameters
GPIOThe GPIO device to set for
PinThe pin to change the function for (eg GPIO_PIN_1)
ModeThe function to set for the pin (eg GPIO_FUNCTION_OUT)
Returns
ERROR_SUCCESS if completed successfully or another error code on failure

◆ gpio_device_properties()

uint32_t STDCALL gpio_device_properties ( GPIO_DEVICE * gpio,
GPIO_PROPERTIES * properties )

Get the properties for the specified GPIO device.

Parameters
GPIOThe GPIO device to get properties from
PropertiesPointer to a TGPIOProperties structure to fill in
Returns
ERROR_SUCCESS if completed or another error code on failure
Note
Replaced by GPIODeviceGetProperties for consistency

◆ gpio_device_get_properties()

uint32_t STDCALL gpio_device_get_properties ( GPIO_DEVICE * gpio,
GPIO_PROPERTIES * properties )

Get the properties for the specified GPIO device.

Parameters
GPIOThe GPIO device to get properties from
PropertiesPointer to a TGPIOProperties structure to fill in
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ gpio_device_create()

GPIO_DEVICE *STDCALL gpio_device_create ( void )

Create a new GPIO entry.

Returns
Pointer to new GPIO entry or nil if GPIO could not be created

◆ gpio_device_create_ex()

GPIO_DEVICE *STDCALL gpio_device_create_ex ( uint32_t size)

Create a new GPIO entry.

Parameters
SizeSize in bytes to allocate for new GPIO (Including the GPIO entry)
Returns
Pointer to new GPIO entry or nil if GPIO could not be created

◆ gpio_device_destroy()

uint32_t STDCALL gpio_device_destroy ( GPIO_DEVICE * gpio)

Destroy an existing GPIO entry.

Parameters
GPIOThe GPIO device to destroy
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ gpio_device_register()

uint32_t STDCALL gpio_device_register ( GPIO_DEVICE * gpio)

Register a new GPIO in the GPIO table.

Parameters
GPIOThe GPIO device to register
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ gpio_device_deregister()

uint32_t STDCALL gpio_device_deregister ( GPIO_DEVICE * gpio)

Deregister a GPIO from the GPIO table.

Parameters
GPIOThe GPIO device to deregister
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ gpio_device_find()

GPIO_DEVICE *STDCALL gpio_device_find ( uint32_t gpioid)

Find a GPIO device by ID in the GPIO table.

Parameters
GPIOIdThe ID number of the GPIO device to find
Returns
Pointer to GPIO device entry or nil if not found

◆ gpio_device_find_by_name()

GPIO_DEVICE *STDCALL gpio_device_find_by_name ( const char * name)

Find a GPIO device by name in the GPIO table.

Parameters
NameThe name of the GPIO to find (eg GPIO0)
Returns
Pointer to GPIO device entry or nil if not found

◆ gpio_device_find_by_description()

GPIO_DEVICE *STDCALL gpio_device_find_by_description ( const char * description)

Find a GPIO device by description in the GPIO table.

Parameters
DescriptionThe description of the GPIO to find (eg BCM2836 GPIO)
Returns
Pointer to GPIO device entry or nil if not found

◆ gpio_device_enumerate()

uint32_t STDCALL gpio_device_enumerate ( gpio_enumerate_cb callback,
void * data )

Enumerate all GPIO devices in the GPIO table.

Parameters
CallbackThe callback function to call for each GPIO in the table
DataA private data pointer to pass to callback for each GPIO in the table
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ gpio_device_notification()

uint32_t STDCALL gpio_device_notification ( GPIO_DEVICE * gpio,
gpio_notification_cb callback,
void * data,
uint32_t notification,
uint32_t flags )

Register a notification for GPIO device changes.

Parameters
GPIOThe GPIO device to notify changes for (Optional, pass nil for all GPIO devices)
CallbackThe function to call when a notification event occurs
DataA private data pointer to pass to callback when a notification event occurs
NotificationThe events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
FlagsThe flags to control the notification (eg NOTIFIER_FLAG_WORKER)

◆ gpio_get_count()

uint32_t STDCALL gpio_get_count ( void )

Get the current GPIO count.

GPIO Helper Functions

◆ gpio_device_get_default()

GPIO_DEVICE *STDCALL gpio_device_get_default ( void )

Get the current default GPIO device.

◆ gpio_device_set_default()

uint32_t STDCALL gpio_device_set_default ( GPIO_DEVICE * gpio)

Set the current default GPIO device.

◆ gpio_device_check()

GPIO_DEVICE *STDCALL gpio_device_check ( GPIO_DEVICE * gpio)

Check if the supplied GPIO is in the GPIO table.

◆ gpio_type_to_string()

uint32_t STDCALL gpio_type_to_string ( uint32_t gpiotype,
char * string,
uint32_t len )

Convert a GPIO type value to a string.

◆ gpio_state_to_string()

uint32_t STDCALL gpio_state_to_string ( uint32_t gpiostate,
char * string,
uint32_t len )

Convert a GPIO state value to a string.

◆ gpio_device_create_event()

GPIO_EVENT *STDCALL gpio_device_create_event ( GPIO_DEVICE * gpio,
GPIO_PIN * pin,
gpio_event_cb callback,
void * data,
uint32_t timeout )

Create a new event using the supplied parameters.

Note
Event must be registered by calling GPIODeviceRegisterEvent
Caller must hold the GPIO device lock

◆ gpio_device_destroy_event()

uint32_t STDCALL gpio_device_destroy_event ( GPIO_DEVICE * gpio,
GPIO_EVENT * event )

Destroy an existing event.

Note
Event must be deregistered first by calling GPIODeviceDeregisterEvent
Caller must hold the GPIO device lock

◆ gpio_device_register_event()

uint32_t STDCALL gpio_device_register_event ( GPIO_DEVICE * gpio,
GPIO_PIN * pin,
GPIO_EVENT * event )

Register an event in the event list of the supplied Pin.

Note
Event must be created by calling GPIODeviceCreateEvent
Caller must hold the GPIO device lock

◆ gpio_device_deregister_event()

uint32_t STDCALL gpio_device_deregister_event ( GPIO_DEVICE * gpio,
GPIO_PIN * pin,
GPIO_EVENT * event )

Deregister an event from the event list of the supplied Pin.

Note
Event must be destroyed by calling GPIODeviceDestroyEvent
Caller must hold the GPIO device lock

◆ gpio_pin_to_string()

uint32_t STDCALL gpio_pin_to_string ( uint32_t pin,
char * string,
uint32_t len )

◆ gpio_level_to_string()

uint32_t STDCALL gpio_level_to_string ( uint32_t level,
char * string,
uint32_t len )

◆ gpio_trigger_to_string()

uint32_t STDCALL gpio_trigger_to_string ( uint32_t trigger,
char * string,
uint32_t len )

◆ gpio_pull_to_string()

uint32_t STDCALL gpio_pull_to_string ( uint32_t value,
char * string,
uint32_t len )

◆ gpio_function_to_string()

uint32_t STDCALL gpio_function_to_string ( uint32_t value,
char * string,
uint32_t len )