Skip to content

Commit 17ed9e9

Browse files
Reverting Clock GPIO code to previous implementation of the gpio_api.c and gpio_irq_api.c
1 parent a3bccfd commit 17ed9e9

File tree

2 files changed

+18
-36
lines changed

2 files changed

+18
-36
lines changed

targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_api.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ void gpio_mode(gpio_t *obj, PinMode mode)
139139
*/
140140
void gpio_dir(gpio_t *obj, PinDirection direction)
141141
{
142-
/* Enable the GPIO clock */
143-
if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) {
144-
CLOCK_ENABLE(CLOCK_GPIO);
145-
}
142+
/* Enable the GPIO clock which may have been switched off by other drivers */
143+
CLOCK_ENABLE(CLOCK_GPIO);
146144

147145
if (direction == PIN_INPUT) {
148146
obj->GPIOMEMBASE->W_IN = obj->gpioMask;
@@ -160,10 +158,8 @@ void gpio_dir(gpio_t *obj, PinDirection direction)
160158
void gpio_write(gpio_t *obj, int value)
161159
{
162160

163-
/* Enable the GPIO clock */
164-
if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) {
165-
CLOCK_ENABLE(CLOCK_GPIO);
166-
}
161+
/* Enable the GPIO clock which may have been switched off by other drivers */
162+
CLOCK_ENABLE(CLOCK_GPIO);
167163

168164
/* Set the GPIO based on value */
169165
if (value) {
@@ -183,10 +179,8 @@ int gpio_read(gpio_t *obj)
183179
{
184180
int ret;
185181

186-
/* Enable the GPIO clock */
187-
if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) {
188-
CLOCK_ENABLE(CLOCK_GPIO);
189-
}
182+
/* Enable the GPIO clock which may have been switched off by other drivers */
183+
CLOCK_ENABLE(CLOCK_GPIO);
190184

191185
ret = (obj->GPIOMEMBASE->R_STATE_W_SET & obj->gpioMask) ? 1: 0;
192186

targets/TARGET_ONSEMI/TARGET_NCS36510/gpio_irq_api.c

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,8 @@ void fGpioHandler(void)
8989
gpio_irq_event event = IRQ_NONE;
9090
GpioReg_pt gpioBase;
9191

92-
/* Enable the GPIO clock */
93-
if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) {
94-
CLOCK_ENABLE(CLOCK_GPIO);
95-
}
92+
/* Enable the GPIO clock which may have been switched off by other drivers */
93+
CLOCK_ENABLE(CLOCK_GPIO);
9694

9795
gpioBase = GPIOREG;
9896

@@ -144,10 +142,8 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
144142
/* Store the ID, this is required by registered handler function */
145143
gpioIds[pin] = id;
146144

147-
/* Enable the GPIO clock */
148-
if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) {
149-
CLOCK_ENABLE(CLOCK_GPIO);
150-
}
145+
/* Enable the GPIO clock which may have been switched off by other drivers */
146+
CLOCK_ENABLE(CLOCK_GPIO);
151147

152148
/* Initialize the GPIO membase */
153149
obj->GPIOMEMBASE = GPIOREG;
@@ -173,10 +169,8 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
173169
*/
174170
void gpio_irq_free(gpio_irq_t *obj)
175171
{
176-
/* Enable the GPIO clock */
177-
if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) {
178-
CLOCK_ENABLE(CLOCK_GPIO);
179-
}
172+
/* Enable the GPIO clock which may have been switched off by other drivers */
173+
CLOCK_ENABLE(CLOCK_GPIO);
180174

181175
/* Disable IRQs to indicate that it is now free */
182176
obj->GPIOMEMBASE->IRQ_ENABLE_CLEAR = obj->pinMask;
@@ -191,10 +185,8 @@ void gpio_irq_free(gpio_irq_t *obj)
191185
*/
192186
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
193187
{
194-
/* Enable the GPIO clock */
195-
if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) {
196-
CLOCK_ENABLE(CLOCK_GPIO);
197-
}
188+
/* Enable the GPIO clock which may have been switched off by other drivers */
189+
CLOCK_ENABLE(CLOCK_GPIO);
198190

199191
switch(event) {
200192
case IRQ_RISE:
@@ -243,10 +235,8 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
243235
*/
244236
void gpio_irq_enable(gpio_irq_t *obj)
245237
{
246-
/* Enable the GPIO clock */
247-
if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) {
248-
CLOCK_ENABLE(CLOCK_GPIO);
249-
}
238+
/* Enable the GPIO clock which may have been switched off by other drivers */
239+
CLOCK_ENABLE(CLOCK_GPIO);
250240

251241
obj->GPIOMEMBASE->IRQ_ENABLE_SET = obj->pinMask;
252242
}
@@ -259,10 +249,8 @@ void gpio_irq_enable(gpio_irq_t *obj)
259249
void gpio_irq_disable(gpio_irq_t *obj)
260250
{
261251

262-
/* Enable the GPIO clock */
263-
if(!CLOCK_IS_ENABLED(CLOCK_GPIO)) {
264-
CLOCK_ENABLE(CLOCK_GPIO);
265-
}
252+
/* Enable the GPIO clock which may have been switched off by other drivers */
253+
CLOCK_ENABLE(CLOCK_GPIO);
266254

267255
obj->GPIOMEMBASE->IRQ_ENABLE_CLEAR = obj->pinMask;
268256
}

0 commit comments

Comments
 (0)