From 17ed9e9777b328810ca891e0cafd11528a6bab6a Mon Sep 17 00:00:00 2001 From: Radhika Date: Wed, 19 Oct 2016 09:52:12 +0530 Subject: [PATCH] Reverting Clock GPIO code to previous implementation of the gpio_api.c and gpio_irq_api.c --- .../TARGET_ONSEMI/TARGET_NCS36510/gpio_api.c | 18 ++++------ .../TARGET_NCS36510/gpio_irq_api.c | 36 +++++++------------ 2 files changed, 18 insertions(+), 36 deletions(-) diff --git a/targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_api.c b/targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_api.c index 12b948ca4f..45d759e166 100644 --- a/targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_api.c +++ b/targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_api.c @@ -139,10 +139,8 @@ void gpio_mode(gpio_t *obj, PinMode mode) */ void gpio_dir(gpio_t *obj, PinDirection direction) { - /* Enable the GPIO clock */ - if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) { - CLOCK_ENABLE(CLOCK_GPIO); - } + /* Enable the GPIO clock which may have been switched off by other drivers */ + CLOCK_ENABLE(CLOCK_GPIO); if (direction == PIN_INPUT) { obj->GPIOMEMBASE->W_IN = obj->gpioMask; @@ -160,10 +158,8 @@ void gpio_dir(gpio_t *obj, PinDirection direction) void gpio_write(gpio_t *obj, int value) { - /* Enable the GPIO clock */ - if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) { - CLOCK_ENABLE(CLOCK_GPIO); - } + /* Enable the GPIO clock which may have been switched off by other drivers */ + CLOCK_ENABLE(CLOCK_GPIO); /* Set the GPIO based on value */ if (value) { @@ -183,10 +179,8 @@ int gpio_read(gpio_t *obj) { int ret; - /* Enable the GPIO clock */ - if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) { - CLOCK_ENABLE(CLOCK_GPIO); - } + /* Enable the GPIO clock which may have been switched off by other drivers */ + CLOCK_ENABLE(CLOCK_GPIO); ret = (obj->GPIOMEMBASE->R_STATE_W_SET & obj->gpioMask) ? 1: 0; diff --git a/targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_irq_api.c b/targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_irq_api.c index 2bddb42fbe..b2c37de5f0 100644 --- a/targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_irq_api.c +++ b/targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_irq_api.c @@ -89,10 +89,8 @@ void fGpioHandler(void) gpio_irq_event event = IRQ_NONE; GpioReg_pt gpioBase; - /* Enable the GPIO clock */ - if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) { - CLOCK_ENABLE(CLOCK_GPIO); - } + /* Enable the GPIO clock which may have been switched off by other drivers */ + CLOCK_ENABLE(CLOCK_GPIO); gpioBase = GPIOREG; @@ -144,10 +142,8 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32 /* Store the ID, this is required by registered handler function */ gpioIds[pin] = id; - /* Enable the GPIO clock */ - if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) { - CLOCK_ENABLE(CLOCK_GPIO); - } + /* Enable the GPIO clock which may have been switched off by other drivers */ + CLOCK_ENABLE(CLOCK_GPIO); /* Initialize the GPIO membase */ obj->GPIOMEMBASE = GPIOREG; @@ -173,10 +169,8 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32 */ void gpio_irq_free(gpio_irq_t *obj) { - /* Enable the GPIO clock */ - if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) { - CLOCK_ENABLE(CLOCK_GPIO); - } + /* Enable the GPIO clock which may have been switched off by other drivers */ + CLOCK_ENABLE(CLOCK_GPIO); /* Disable IRQs to indicate that it is now free */ obj->GPIOMEMBASE->IRQ_ENABLE_CLEAR = obj->pinMask; @@ -191,10 +185,8 @@ void gpio_irq_free(gpio_irq_t *obj) */ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) { - /* Enable the GPIO clock */ - if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) { - CLOCK_ENABLE(CLOCK_GPIO); - } + /* Enable the GPIO clock which may have been switched off by other drivers */ + CLOCK_ENABLE(CLOCK_GPIO); switch(event) { case IRQ_RISE: @@ -243,10 +235,8 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable) */ void gpio_irq_enable(gpio_irq_t *obj) { - /* Enable the GPIO clock */ - if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) { - CLOCK_ENABLE(CLOCK_GPIO); - } + /* Enable the GPIO clock which may have been switched off by other drivers */ + CLOCK_ENABLE(CLOCK_GPIO); obj->GPIOMEMBASE->IRQ_ENABLE_SET = obj->pinMask; } @@ -259,10 +249,8 @@ void gpio_irq_enable(gpio_irq_t *obj) void gpio_irq_disable(gpio_irq_t *obj) { - /* Enable the GPIO clock */ - if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) { - CLOCK_ENABLE(CLOCK_GPIO); - } + /* Enable the GPIO clock which may have been switched off by other drivers */ + CLOCK_ENABLE(CLOCK_GPIO); obj->GPIOMEMBASE->IRQ_ENABLE_CLEAR = obj->pinMask; }