no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
no_os_gpio.h
Go to the documentation of this file.
1/***************************************************************************/
33
34#ifndef _NO_OS_GPIO_H_
35#define _NO_OS_GPIO_H_
36
37#include <stdint.h>
38
39#define NO_OS_GPIO_OUT 0x01
40#define NO_OS_GPIO_IN 0x00
41
48
62
79
96
109
117 int32_t (*gpio_ops_get)(struct no_os_gpio_desc **,
118 const struct no_os_gpio_init_param *);
121 const struct no_os_gpio_init_param *);
123 int32_t (*gpio_ops_remove)(struct no_os_gpio_desc *);
127 int32_t (*gpio_ops_direction_output)(struct no_os_gpio_desc *, uint8_t);
129 int32_t (*gpio_ops_get_direction)(struct no_os_gpio_desc *, uint8_t *);
131 int32_t (*gpio_ops_set_value)(struct no_os_gpio_desc *, uint8_t);
133 int32_t (*gpio_ops_get_value)(struct no_os_gpio_desc *, uint8_t *);
134};
135
136/* Obtain the GPIO decriptor. */
137int32_t no_os_gpio_get(struct no_os_gpio_desc **desc,
138 const struct no_os_gpio_init_param *param);
139
140/* Obtain optional GPIO descriptor. */
141int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc,
142 const struct no_os_gpio_init_param *param);
143
144/* Free the resources allocated by no_os_gpio_get(). */
145int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc);
146
147/* Enable the input direction of the specified GPIO. */
148int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc);
149
150/* Enable the output direction of the specified GPIO. */
152 uint8_t value);
153
154/* Get the direction of the specified GPIO. */
155int32_t no_os_gpio_get_direction(struct no_os_gpio_desc *desc,
156 uint8_t *direction);
157
158/* Set the value of the specified GPIO. */
159int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc,
160 uint8_t value);
161
162/* Get the value of the specified GPIO. */
163int32_t no_os_gpio_get_value(struct no_os_gpio_desc *desc,
164 uint8_t *value);
165
166#endif // _NO_OS_GPIO_H_
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition no_os_gpio.c:100
int32_t no_os_gpio_get_direction(struct no_os_gpio_desc *desc, uint8_t *direction)
Get the direction of the specified GPIO.
Definition no_os_gpio.c:168
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition no_os_gpio.c:143
int32_t no_os_gpio_get_optional(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Get the value of an optional GPIO.
Definition no_os_gpio.c:71
int32_t no_os_gpio_set_value(struct no_os_gpio_desc *desc, uint8_t value)
Set the value of the specified GPIO.
Definition no_os_gpio.c:193
no_os_gpio_values
Enum that holds the possible output states of a GPIO.
Definition no_os_gpio.h:101
@ NO_OS_GPIO_LOW
Definition no_os_gpio.h:103
@ NO_OS_GPIO_HIGH_Z
Definition no_os_gpio.h:107
@ NO_OS_GPIO_HIGH
Definition no_os_gpio.h:105
no_os_gpio_pull_up
Enum that holds the possible pull up/ pull down resistor configuration.
Definition no_os_gpio.h:53
@ NO_OS_PULL_DOWN_WEAK
Definition no_os_gpio.h:60
@ NO_OS_PULL_NONE
Definition no_os_gpio.h:54
@ NO_OS_PULL_DOWN
Definition no_os_gpio.h:58
@ NO_OS_PULL_UP_WEAK
Definition no_os_gpio.h:59
@ NO_OS_PULL_UP
Definition no_os_gpio.h:56
int32_t no_os_gpio_direction_input(struct no_os_gpio_desc *desc)
Enable the input direction of the specified GPIO.
Definition no_os_gpio.c:120
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition no_os_gpio.c:45
int32_t no_os_gpio_get_value(struct no_os_gpio_desc *desc, uint8_t *value)
Get the value of the specified GPIO.
Definition no_os_gpio.c:217
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
enum no_os_gpio_pull_up pull
Definition no_os_gpio.h:90
void * extra
Definition no_os_gpio.h:94
int32_t number
Definition no_os_gpio.h:88
int32_t port
Definition no_os_gpio.h:86
const struct no_os_gpio_platform_ops * platform_ops
Definition no_os_gpio.h:92
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
void * extra
Definition no_os_gpio.h:77
int32_t number
Definition no_os_gpio.h:71
enum no_os_gpio_pull_up pull
Definition no_os_gpio.h:73
int32_t port
Definition no_os_gpio.h:69
const struct no_os_gpio_platform_ops * platform_ops
Definition no_os_gpio.h:75
Structure holding gpio function pointers that point to the platform specific function.
Definition no_os_gpio.h:115
int32_t(* gpio_ops_set_value)(struct no_os_gpio_desc *, uint8_t)
Definition no_os_gpio.h:131
int32_t(* gpio_ops_get_direction)(struct no_os_gpio_desc *, uint8_t *)
Definition no_os_gpio.h:129
int32_t(* gpio_ops_direction_output)(struct no_os_gpio_desc *, uint8_t)
Definition no_os_gpio.h:127
int32_t(* gpio_ops_direction_input)(struct no_os_gpio_desc *)
Definition no_os_gpio.h:125
int32_t(* gpio_ops_get_value)(struct no_os_gpio_desc *, uint8_t *)
Definition no_os_gpio.h:133
int32_t(* gpio_ops_get_optional)(struct no_os_gpio_desc **, const struct no_os_gpio_init_param *)
Definition no_os_gpio.h:120
int32_t(* gpio_ops_get)(struct no_os_gpio_desc **, const struct no_os_gpio_init_param *)
Definition no_os_gpio.h:117
int32_t(* gpio_ops_remove)(struct no_os_gpio_desc *)
Definition no_os_gpio.h:123