Private
Public Access
2
0

gpio: Add gpio chardev interface

Signed-off-by: Mihai Stefanescu <mihai.t.gh.stefanescu@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Mihai Stefanescu
2017-08-27 19:10:17 +02:00
committed by Brendan Le Foll
parent aa7006cce9
commit 1665e09928
4 changed files with 1477 additions and 237 deletions

View File

@@ -106,6 +106,26 @@ struct _firmata {
};
#endif
struct _gpio_group {
int is_required;
int dev_fd;
int gpiod_handle;
unsigned int gpio_chip;
/* We can have multiple lines in a gpio group. */
unsigned int num_gpio_lines;
unsigned int *gpio_lines;
/* R/W stuff.*/
unsigned char *rw_values;
/* Reverse mapping to original pin number indexes. */
unsigned int *gpio_group_to_pins_table;
unsigned int flags;
/* Event specific fields. */
int *event_handles;
};
/**
* A structure representing a gpio pin.
*/
@@ -134,8 +154,30 @@ struct _gpio {
#ifdef PERIPHERALMAN
AGpio *bgpio;
#endif
/* TODO: The below members should be integrated in gpio_group struct. */
int dev_fd;
int gpiod_handle;
unsigned int gpio_chip;
unsigned int gpio_line;
/* Multiple gpio support. These members are treated separately for now until multiple gpio support is accepted. */
unsigned int num_chips;
struct _gpio_group *gpio_group;
/* Pin index passed by the user to gpio_group structures. */
int *pin_to_gpio_table;
unsigned int num_pins;
struct _gpio *next;
};
/* Macro for looping over gpio chips. */
#define for_each_gpio_group(group, dev) \
for (int k = 0; \
k < dev->num_chips && (group = &dev->gpio_group[k]); \
++k) \
if (dev->gpio_group[k].is_required)
/**
* A structure representing a I2C bus
*/
@@ -315,6 +357,10 @@ typedef struct {
mraa_mux_t mux[6]; /** Array holding information about mux */
unsigned int output_enable; /** Output Enable GPIO, for level shifting */
mraa_pin_cap_complex_t complex_cap;
/* GPIOD_INTERFACE */
unsigned int gpio_chip;
unsigned int gpio_line;
/*@}*/
} mraa_pin_t;
@@ -447,6 +493,7 @@ typedef struct _board_t {
mraa_pininfo_t* pins; /**< Pointer to pin array */
mraa_adv_func_t* adv_func; /**< Pointer to advanced function disptach table */
struct _board_t* sub_platform; /**< Pointer to sub platform */
mraa_boolean_t chardev_capable; /**< Decide what interface is being used: old sysfs or new char device*/
/*@}*/
} mraa_board_t;