Git Product home page Git Product logo

Comments (2)

vsergeev avatar vsergeev commented on August 14, 2024

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.

sgjava avatar sgjava commented on August 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.