Skip to content

Commit

Permalink
Merge pull request #45 from superna9999/ftdi-gpio-output-enable
Browse files Browse the repository at this point in the history
ftdi_gpio: add output_enable gpio type
  • Loading branch information
lumag authored Nov 2, 2023
2 parents 5e3bdca + 981a8ba commit b9f7f93
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ftdi-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum {
GPIO_FASTBOOT_KEY, // Usually volume key
GPIO_POWER_KEY, // Key to power the device
GPIO_USB_DISCONNECT, // Simulate main USB connection
GPIO_OUTPUT_ENABLE, // Enable FTDI signals to flow to the board
GPIO_COUNT
};

Expand All @@ -70,6 +71,7 @@ struct ftdi_gpio {

static int ftdi_gpio_device_power(struct ftdi_gpio *ftdi_gpio, bool on);
static void ftdi_gpio_device_usb(struct ftdi_gpio *ftdi_gpio, bool on);
static int ftdi_gpio_toggle_io(struct ftdi_gpio *ftdi_gpio, unsigned int gpio, bool on);

/*
* fdio_gpio parameter: <libftdi description>;[<interface>[;<gpios>...]]
Expand Down Expand Up @@ -139,6 +141,8 @@ static void ftdi_gpio_parse_config(struct ftdi_gpio *ftdi_gpio, char *control_de
gpio_type = GPIO_POWER_KEY;
else if (strncmp("USB_DISCONNECT", name, off - name - 1) == 0)
gpio_type = GPIO_USB_DISCONNECT;
else if (strncmp("OUTPUT_ENABLE", name, off - name - 1) == 0)
gpio_type = GPIO_OUTPUT_ENABLE;
else
errx(1, "GPIOs type invalid: '%s'", name);

Expand Down Expand Up @@ -189,6 +193,9 @@ static void *ftdi_gpio_open(struct device *dev)
else
ftdi_gpio_device_usb(ftdi_gpio, 0);

if (ftdi_gpio->gpio_present[GPIO_OUTPUT_ENABLE])
ftdi_gpio_toggle_io(ftdi_gpio, GPIO_OUTPUT_ENABLE, 1);

usleep(500000);

return ftdi_gpio;
Expand Down

0 comments on commit b9f7f93

Please sign in to comment.