Skip to content

Commit

Permalink
hw/mcu/nordic: Fix GPIO read bug
Browse files Browse the repository at this point in the history
hal_gpio_read was always returning state of IN register
even if GPIO pin was configured as output pin
  • Loading branch information
m-gorecki committed Jul 22, 2024
1 parent 0b2a79c commit dae4341
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hw/mcu/nordic/nrf_common/src/hal_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ hal_gpio_write(int pin, int val)
int
hal_gpio_read(int pin)
{
return nrf_gpio_pin_read(pin);
if (nrf_gpio_pin_dir_get(pin) == NRF_GPIO_PIN_DIR_OUTPUT) {
return nrf_gpio_pin_out_read(pin);
} else {
return nrf_gpio_pin_read(pin);
}
}

/**
Expand All @@ -157,7 +161,7 @@ int
hal_gpio_toggle(int pin)
{
nrf_gpio_pin_toggle(pin);
return nrf_gpio_pin_read(pin);
return hal_gpio_read(pin);
}

/*
Expand Down

0 comments on commit dae4341

Please sign in to comment.