Skip to content

Commit 728a018

Browse files
benson0715kartben
authored andcommitted
drivers: gpio: Fix GPIO initial status
The current procedure to initialize the GPIO is: If the GPIO is configured as GPIO_OUTPUT and also has the GPIO_OUTPUT_INIT_HIGH flag, set it to output high; otherwise, set it to output low. This may fail if the GPIO is simply configured as GPIO_OUTPUT without specifying either INIT_HIGH or INIT_LOW, which means it is intended to preserve the previous status. But in this case, we are currently setting it to output low. Fix this by explicitly initializing the GPIO to high or low according to the configuration: If the GPIO is configured as GPIO_OUTPUT and also with the GPIO_OUTPUT_INIT_HIGH flag, set it to output high. If the GPIO is configured as GPIO_OUTPUT and also with the GPIO_OUTPUT_INIT_LOW flag, set it to output low. If the GPIO is configured as GPIO_OUTPUT only, do not set the output value. Signed-off-by: Benson Huang <benson7633769@gmail.com>
1 parent 9cf6d66 commit 728a018

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpio/gpio_rts5912.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static int gpio_rts5912_configuration(const struct device *port, gpio_pin_t pin,
180180
if (flags & GPIO_OUTPUT) {
181181
if (flags & GPIO_OUTPUT_INIT_HIGH) {
182182
pin_output_high(port, pin);
183-
} else {
183+
} else if (flags & GPIO_OUTPUT_INIT_LOW) {
184184
pin_output_low(port, pin);
185185
}
186186
}

0 commit comments

Comments
 (0)