This is an automated email from the ASF dual-hosted git repository.

mgorecki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new a66144eb7 hw/mcu/nordic: Fix GPIO read bug
a66144eb7 is described below

commit a66144eb7151e160768c0c7f8d27cffc14d48878
Author: Michal Gorecki <[email protected]>
AuthorDate: Wed Jul 17 13:55:08 2024 +0200

    hw/mcu/nordic: Fix GPIO read bug
    
    hal_gpio_read was always returning state of IN register
    even if GPIO pin was configured as output pin
---
 hw/mcu/nordic/nrf_common/src/hal_gpio.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/mcu/nordic/nrf_common/src/hal_gpio.c 
b/hw/mcu/nordic/nrf_common/src/hal_gpio.c
index 6edd378f7..dc4f6acf3 100644
--- a/hw/mcu/nordic/nrf_common/src/hal_gpio.c
+++ b/hw/mcu/nordic/nrf_common/src/hal_gpio.c
@@ -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);
+    }
 }
 
 /**
@@ -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);
 }
 
 /*

Reply via email to