diff options
-rw-r--r-- | app/module/drivers/gpio/gpio_595.c | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/app/module/drivers/gpio/gpio_595.c b/app/module/drivers/gpio/gpio_595.c index 3d3858449c..d9cc66448d 100644 --- a/app/module/drivers/gpio/gpio_595.c +++ b/app/module/drivers/gpio/gpio_595.c @@ -89,26 +89,6 @@ static int setup_pin_dir(const struct device *dev, uint32_t pin, int flags) { return 0; } -static int reg_595_pin_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { - int ret; - - /* Can't do SPI bus operations from an ISR */ - if (k_is_in_isr()) { - return -EWOULDBLOCK; - } - - if ((flags & GPIO_OPEN_DRAIN) != 0U) { - return -ENOTSUP; - }; - - ret = setup_pin_dir(dev, pin, flags); - if (ret) { - LOG_ERR("595: error setting pin direction (%d)", ret); - } - - return ret; -} - static int reg_595_port_get_raw(const struct device *dev, uint32_t *value) { return -ENOTSUP; } static int reg_595_port_set_masked_raw(const struct device *dev, uint32_t mask, uint32_t value) { @@ -161,6 +141,32 @@ static int reg_595_port_toggle_bits(const struct device *dev, uint32_t mask) { return ret; } +static int reg_595_pin_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { + int ret; + + /* Can't do SPI bus operations from an ISR */ + if (k_is_in_isr()) { + return -EWOULDBLOCK; + } + + if ((flags & GPIO_OPEN_DRAIN) != 0U) { + return -ENOTSUP; + }; + + ret = setup_pin_dir(dev, pin, flags); + if (ret) { + LOG_ERR("595: error setting pin direction (%d)", ret); + } + + if ((flags & GPIO_OUTPUT_INIT_LOW) != 0) { + return reg_595_port_clear_bits_raw(dev, BIT(pin)); + } else if ((flags & GPIO_OUTPUT_INIT_HIGH) != 0) { + return reg_595_port_set_bits_raw(dev, BIT(pin)); + } + + return ret; +} + static const struct gpio_driver_api api_table = { .pin_configure = reg_595_pin_config, .port_get_raw = reg_595_port_get_raw, |