From 7cd4ffcc2c6fd9b4ec2e03204f199c8839c01bf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Duda?= Date: Mon, 4 Nov 2019 15:47:02 +0100 Subject: [PATCH] [nrf528xx] add support for reading state of an output pin (#4302) --- examples/platforms/nrf528xx/src/diag.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/platforms/nrf528xx/src/diag.c b/examples/platforms/nrf528xx/src/diag.c index e76aa1c6a..a792aba1c 100644 --- a/examples/platforms/nrf528xx/src/diag.c +++ b/examples/platforms/nrf528xx/src/diag.c @@ -256,12 +256,22 @@ static void processGpio(otInstance *aInstance, int argc, char *argv[], char *aOu if (argc == 1) { - uint32_t value; + uint32_t value; + nrf_gpio_pin_dir_t pindir; error = parseLong(argv[0], &pinnum); otEXPECT(error == OT_ERROR_NONE); - value = nrf_gpio_pin_read(pinnum); + pindir = nrf_gpio_pin_dir_get(pinnum); + + if (pindir == NRF_GPIO_PIN_DIR_INPUT) + { + value = nrf_gpio_pin_read(pinnum); + } + else + { + value = nrf_gpio_pin_out_read(pinnum); + } snprintf(aOutput, aOutputMaxLen, "gpio %d = %d\r\n", (uint8_t)pinnum, (uint8_t)value); }