From fd68691ce30e5e7bbde63f929be59827c350d7b3 Mon Sep 17 00:00:00 2001 From: Kevin Bracey Date: Mon, 29 Apr 2019 18:08:59 +0300 Subject: [PATCH] ARM SSG/FM: Cope correctly with NC GPIO --- targets/TARGET_ARM_FM/TARGET_FVP_MPS2/gpio_api.c | 2 +- targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/gpio_api.c | 7 +++++++ targets/TARGET_ARM_SSG/TARGET_IOTSS/gpio_api.c | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_ARM_FM/TARGET_FVP_MPS2/gpio_api.c b/targets/TARGET_ARM_FM/TARGET_FVP_MPS2/gpio_api.c index 2da2b84e53..5cfdd573c7 100644 --- a/targets/TARGET_ARM_FM/TARGET_FVP_MPS2/gpio_api.c +++ b/targets/TARGET_ARM_FM/TARGET_FVP_MPS2/gpio_api.c @@ -27,11 +27,11 @@ uint32_t gpio_set(PinName pin) // with the object created for the pin void gpio_init(gpio_t *obj, PinName pin) { + obj->pin = pin; if (pin == NC) { return; } else { int pin_value = 0; - obj->pin = pin; if (pin <= 15) { pin_value = pin; } else if (pin >= 16 && pin <= 31) { diff --git a/targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/gpio_api.c b/targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/gpio_api.c index 46a95c4abf..2458569ae7 100644 --- a/targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/gpio_api.c +++ b/targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/gpio_api.c @@ -101,6 +101,13 @@ void gpio_init(gpio_t *obj, PinName pin) { struct arm_gpio_dev_t *gpio_dev; + if (pin == NC) { + obj->pin_number = NC; + obj->gpio_dev = NULL; + obj->mps2_io_dev = NULL; + return; + } + if (pin >= EXP0 && pin <= EXP51) { /* GPIO pins */ switch (GPIO_DEV_NUMBER(pin)) { diff --git a/targets/TARGET_ARM_SSG/TARGET_IOTSS/gpio_api.c b/targets/TARGET_ARM_SSG/TARGET_IOTSS/gpio_api.c index b80fcbacd1..2a87bb2dda 100644 --- a/targets/TARGET_ARM_SSG/TARGET_IOTSS/gpio_api.c +++ b/targets/TARGET_ARM_SSG/TARGET_IOTSS/gpio_api.c @@ -25,10 +25,10 @@ uint32_t gpio_set(PinName pin) { // this links the board control bits for each pin // with the object created for the pin void gpio_init(gpio_t *obj, PinName pin) { + obj->pin = pin; if(pin == NC){ return;} else { int pin_value = 0; - obj->pin = pin; if(pin <=15){ pin_value = pin; }else if (pin >= 16 && pin <= 31){