Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop a87a31d71 -> 72c74e5b1


MYNEWT-390: NRF hal_gpio_read does not return 1 when pin high

This API is supposed to return 1 but was returning 1 << pin. This
has now been fixed so if the pin is high, 1 is returned.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/72c74e5b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/72c74e5b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/72c74e5b

Branch: refs/heads/develop
Commit: 72c74e5b138f272c466d35bdd399330ec9de4c1f
Parents: a87a31d
Author: William San Filippo <wi...@runtime.io>
Authored: Wed Sep 21 21:53:07 2016 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Wed Sep 21 21:53:07 2016 -0700

----------------------------------------------------------------------
 hw/mcu/nordic/nrf51xxx/src/hal_gpio.c | 2 +-
 hw/mcu/nordic/nrf52xxx/src/hal_gpio.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/72c74e5b/hw/mcu/nordic/nrf51xxx/src/hal_gpio.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_gpio.c 
b/hw/mcu/nordic/nrf51xxx/src/hal_gpio.c
index e37851d..58e6fac 100644
--- a/hw/mcu/nordic/nrf51xxx/src/hal_gpio.c
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_gpio.c
@@ -414,7 +414,7 @@ void hal_gpio_write(int pin, int val)
  */
 int hal_gpio_read(int pin)
 {
-    return (NRF_GPIO->IN & GPIO_MASK(pin));
+    return ((NRF_GPIO->IN & GPIO_MASK(pin)) != 0);
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/72c74e5b/hw/mcu/nordic/nrf52xxx/src/hal_gpio.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_gpio.c 
b/hw/mcu/nordic/nrf52xxx/src/hal_gpio.c
index a9536f3..ec5e31e 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_gpio.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_gpio.c
@@ -160,7 +160,7 @@ void hal_gpio_write(int pin, int val)
  */
 int hal_gpio_read(int pin)
 {
-    return (NRF_P0->IN & HAL_GPIO_MASK(pin));
+    return ((NRF_P0->IN & HAL_GPIO_MASK(pin)) != 0);
 }
 
 /**

Reply via email to