diff --git a/app/module/drivers/gpio/gpio_595.c b/app/module/drivers/gpio/gpio_595.c index 3d3858449c5f..81efe267e0bc 100644 --- a/app/module/drivers/gpio/gpio_595.c +++ b/app/module/drivers/gpio/gpio_595.c @@ -89,6 +89,14 @@ static int setup_pin_dir(const struct device *dev, uint32_t pin, int flags) { return 0; } +static int reg_595_port_set_bits_raw(const struct device *dev, uint32_t mask) { + return reg_595_port_set_masked_raw(dev, mask, mask); +} + +static int reg_595_port_clear_bits_raw(const struct device *dev, uint32_t mask) { + return reg_595_port_set_masked_raw(dev, mask, 0); +} + static int reg_595_pin_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) { int ret; @@ -106,6 +114,12 @@ static int reg_595_pin_config(const struct device *dev, gpio_pin_t pin, gpio_fla 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; } @@ -132,14 +146,6 @@ static int reg_595_port_set_masked_raw(const struct device *dev, uint32_t mask, return ret; } -static int reg_595_port_set_bits_raw(const struct device *dev, uint32_t mask) { - return reg_595_port_set_masked_raw(dev, mask, mask); -} - -static int reg_595_port_clear_bits_raw(const struct device *dev, uint32_t mask) { - return reg_595_port_set_masked_raw(dev, mask, 0); -} - static int reg_595_port_toggle_bits(const struct device *dev, uint32_t mask) { struct reg_595_drv_data *const drv_data = (struct reg_595_drv_data *const)dev->data; uint32_t buf;