Comments (2)
I'm thinking:
diff --git a/src/gpio.h b/src/gpio.h
index d489cec..eda6ca8 100644
--- a/src/gpio.h
+++ b/src/gpio.h
@@ -41,12 +41,27 @@ typedef enum gpio_edge {
GPIO_EDGE_BOTH /* Both edges X -> !X */
} gpio_edge_t;
+typedef enum gpio_bias {
+ GPIO_BIAS_DEFAULT, /* Default line bias */
+ GPIO_BIAS_PULL_UP, /* Pull-up */
+ GPIO_BIAS_PULL_DOWN, /* Pull-down */
+ GPIO_BIAS_DISABLE, /* Disable line bias */
+} gpio_bias_t;
+
+typedef enum gpio_drive {
+ GPIO_DRIVE_DEFAULT, /* Default line drive (push-pull) */
+ GPIO_DRIVE_OPEN_DRAIN, /* Open drain */
+ GPIO_DRIVE_OPEN_SOURCE, /* Open source */
+} gpio_drive_t;
+
typedef struct gpio_handle gpio_t;
/* Primary Functions */
gpio_t *gpio_new(void);
int gpio_open(gpio_t *gpio, const char *path, unsigned int line, gpio_direction_t direction);
int gpio_open_name(gpio_t *gpio, const char *path, const char *name, gpio_direction_t direction);
+int gpio_open_advanced(gpio_t *gpio, const char *path, unsigned int line, gpio_direction_t direction, gpio_bias_t bias, gpio_drive_t drive, bool inverted, const char *label);
+int gpio_open_name_advanced(gpio_t *gpio, const char *path, const char *name, gpio_direction_t direction, gpio_bias_t bias, gpio_drive_t drive, bool inverted, const char *label);
int gpio_open_sysfs(gpio_t *gpio, unsigned int line, gpio_direction_t direction);
int gpio_read(gpio_t *gpio, bool *value);
int gpio_write(gpio_t *gpio, bool value);
@@ -63,15 +78,22 @@ int gpio_poll_multiple(gpio_t **gpios, size_t count, int timeout_ms, bool *gpios
/* Getters */
int gpio_get_direction(gpio_t *gpio, gpio_direction_t *direction);
int gpio_get_edge(gpio_t *gpio, gpio_edge_t *edge);
+int gpio_get_bias(gpio_t *gpio, gpio_bias_t *bias);
+int gpio_get_drive(gpio_t *gpio, gpio_drive_t *drive);
+int gpio_get_inverted(gpio_t *gpio, bool *inverted);
/* Setters */
int gpio_set_direction(gpio_t *gpio, gpio_direction_t direction);
int gpio_set_edge(gpio_t *gpio, gpio_edge_t edge);
+int gpio_set_bias(gpio_t *gpio, gpio_bias_t edge);
+int gpio_set_drive(gpio_t *gpio, gpio_drive_t drive);
+int gpio_set_inverted(gpio_t *gpio, bool inverted);
/* Miscellaneous Properties */
unsigned int gpio_line(gpio_t *gpio);
int gpio_fd(gpio_t *gpio);
int gpio_name(gpio_t *gpio, char *str, size_t len);
+int gpio_label(gpio_t *gpio, char *str, size_t len);
int gpio_chip_fd(gpio_t *gpio);
int gpio_chip_name(gpio_t *gpio, char *str, size_t len);
int gpio_chip_label(gpio_t *gpio, char *str, size_t len);
The gpio_open_advanced()
and gpio_open_name_advanced()
are a bit of a mouthful, but they support everything the kernel's got so far for gpio-cdev, and shouldn't be too big of a problem for language bindings.
from c-periphery.
Cool, once you push changes I'll add to my Java bindings. The only thing I'd mention is the number parameters which is usually 7 maximum before most static code analysis kicks them out. I guess you could use a struct, but I'll leave that up to you. I'm just mimicking with a Java method.
from c-periphery.
Related Issues (20)
- Change param name
- Handle allocating on stack HOT 7
- Warning spi.c in function 'spi_tostring' HOT 3
- How to keep the pin's value HOT 5
- PWM functions are hardware PWM ? HOT 1
- Bias compile settings HOT 4
- SPI R/W REG HOT 2
- serial_set_parity(serial, PARITY_ODD) fails on RaspiPi3 B+ HOT 1
- test_gpio gpio_set_bias(gpio, GPIO_BIAS_PULL_UP) fails HOT 1
- gpio_open_sysfs(): Opening GPIO: writing 'export': Invalid argument [errno 22] HOT 1
- Update GPIO code? HOT 2
- ADC - implemented? HOT 3
- Portage error: make: *** No rule to make target 'install'. Stop. HOT 1
- Jetson Nano - not operate discrete output (GPIO), SPI works HOT 1
- Gpio
- GPIO_V2_LINE_FLAG_EVENT_CLOCK_REALTIME missing for Debian 11 x86/x86_64
- Building on Rasberry Pi HOT 1
- spi.c Error message builder is buggy HOT 1
- Unknown CMake command "check_source_compiles" on Debian Bullseye
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from c-periphery.