Skip to content

Commit c1e5c0b

Browse files
mpolojarstevew817
authored andcommitted
SiLabs: GPIO interrupts disabled/enabled incorrectly
GPIO_IntEnable/Disable was called with incorrect params due to missing parens. Operator precedence of & vs << caused the call to be blank if the port (MSB) nibble of pin was not zero.
1 parent ee329e5 commit c1e5c0b

File tree

1 file changed

+3
-3
lines changed
  • libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32

1 file changed

+3
-3
lines changed

libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/gpio_irq_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
147147
bool was_disabled = false;
148148
if(GPIO->IEN == 0) was_disabled = true;
149149

150-
GPIO_IntConfig((GPIO_Port_TypeDef)(obj->pin >> 4 & 0xF), obj->pin &0xF, obj->risingEdge, obj->fallingEdge, obj->risingEdge || obj->fallingEdge);
150+
GPIO_IntConfig((GPIO_Port_TypeDef)((obj->pin >> 4) & 0xF), obj->pin &0xF, obj->risingEdge, obj->fallingEdge, obj->risingEdge || obj->fallingEdge);
151151
if ((GPIO->IEN != 0) && (obj->risingEdge || obj->fallingEdge) && was_disabled) {
152152
blockSleepMode(GPIO_LEAST_ACTIVE_SLEEPMODE);
153153
}
@@ -156,12 +156,12 @@ void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
156156
inline void gpio_irq_enable(gpio_irq_t *obj)
157157
{
158158
if(GPIO->IEN == 0) blockSleepMode(GPIO_LEAST_ACTIVE_SLEEPMODE);
159-
GPIO_IntEnable(1 << obj->pin & 0xF); // pin mask for pins to enable
159+
GPIO_IntEnable(1 << (obj->pin & 0xF)); // pin mask for pins to enable
160160
}
161161

162162
inline void gpio_irq_disable(gpio_irq_t *obj)
163163
{
164-
GPIO_IntDisable(1 << obj->pin & 0xF); // pin mask for pins to disable
164+
GPIO_IntDisable(1 << (obj->pin & 0xF)); // pin mask for pins to disable
165165
if(GPIO->IEN == 0) unblockSleepMode(GPIO_LEAST_ACTIVE_SLEEPMODE);
166166
}
167167

0 commit comments

Comments
 (0)