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 17, 2024
1 parent 0b2a79c commit 883f823
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 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,9 @@ hal_gpio_write(int pin, int val)
int
hal_gpio_read(int pin)
{
return nrf_gpio_pin_read(pin);
return (nrf_gpio_pin_dir_get(pin) == NRF_GPIO_PIN_DIR_OUTPUT) ?
nrf_gpio_pin_out_read(pin) :
nrf_gpio_pin_read(pin);
}

/**
Expand All @@ -157,7 +159,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 883f823

Please sign in to comment.