Skip to content

Commit 5010c17

Browse files
diamant3Rbb666
authored andcommitted
move GPIO_InitStruct variable inside to PIN_IRQ_ENABLE. thanks to @mysterywolf
1 parent df36d18 commit 5010c17

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bsp/stm32/libraries/HAL_Drivers/drivers/drv_gpio.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,6 @@ static rt_err_t stm32_pin_irq_enable(struct rt_device *device, rt_base_t pin,
394394
const struct pin_irq_map *irqmap;
395395
rt_base_t level;
396396
rt_int32_t irqindex = -1;
397-
GPIO_InitTypeDef GPIO_InitStruct;
398-
HAL_GPIO_Init(PIN_STPORT(pin), &GPIO_InitStruct);
399397

400398
if (PIN_PORT(pin) >= PIN_STPORT_MAX)
401399
{
@@ -419,6 +417,7 @@ static rt_err_t stm32_pin_irq_enable(struct rt_device *device, rt_base_t pin,
419417
}
420418

421419
irqmap = &pin_irq_map[irqindex];
420+
GPIO_InitTypeDef GPIO_InitStruct;
422421

423422
/* Configure GPIO_InitStructure */
424423
GPIO_InitStruct.Pin = PIN_STPIN(pin);
@@ -438,6 +437,7 @@ static rt_err_t stm32_pin_irq_enable(struct rt_device *device, rt_base_t pin,
438437
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
439438
break;
440439
}
440+
HAL_GPIO_Init(PIN_STPORT(pin), &GPIO_InitStruct);
441441

442442
HAL_NVIC_SetPriority(irqmap->irqno, 5, 0);
443443
HAL_NVIC_EnableIRQ(irqmap->irqno);

0 commit comments

Comments
 (0)