@@ -89,10 +89,8 @@ void fGpioHandler(void)
89
89
gpio_irq_event event = IRQ_NONE ;
90
90
GpioReg_pt gpioBase ;
91
91
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 );
96
94
97
95
gpioBase = GPIOREG ;
98
96
@@ -144,10 +142,8 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
144
142
/* Store the ID, this is required by registered handler function */
145
143
gpioIds [pin ] = id ;
146
144
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 );
151
147
152
148
/* Initialize the GPIO membase */
153
149
obj -> GPIOMEMBASE = GPIOREG ;
@@ -173,10 +169,8 @@ int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32
173
169
*/
174
170
void gpio_irq_free (gpio_irq_t * obj )
175
171
{
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 );
180
174
181
175
/* Disable IRQs to indicate that it is now free */
182
176
obj -> GPIOMEMBASE -> IRQ_ENABLE_CLEAR = obj -> pinMask ;
@@ -191,10 +185,8 @@ void gpio_irq_free(gpio_irq_t *obj)
191
185
*/
192
186
void gpio_irq_set (gpio_irq_t * obj , gpio_irq_event event , uint32_t enable )
193
187
{
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 );
198
190
199
191
switch (event ) {
200
192
case IRQ_RISE :
@@ -243,10 +235,8 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
243
235
*/
244
236
void gpio_irq_enable (gpio_irq_t * obj )
245
237
{
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 );
250
240
251
241
obj -> GPIOMEMBASE -> IRQ_ENABLE_SET = obj -> pinMask ;
252
242
}
@@ -259,10 +249,8 @@ void gpio_irq_enable(gpio_irq_t *obj)
259
249
void gpio_irq_disable (gpio_irq_t * obj )
260
250
{
261
251
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 );
266
254
267
255
obj -> GPIOMEMBASE -> IRQ_ENABLE_CLEAR = obj -> pinMask ;
268
256
}
0 commit comments