Skip to content

Commit

Permalink
move GPIO_InitStruct variable inside to PIN_IRQ_ENABLE. thanks to @…
Browse files Browse the repository at this point in the history
  • Loading branch information
diamant3 authored and Rbb666 committed Oct 12, 2024
1 parent df36d18 commit 5010c17
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions bsp/stm32/libraries/HAL_Drivers/drivers/drv_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ static rt_err_t stm32_pin_irq_enable(struct rt_device *device, rt_base_t pin,
const struct pin_irq_map *irqmap;
rt_base_t level;
rt_int32_t irqindex = -1;
GPIO_InitTypeDef GPIO_InitStruct;
HAL_GPIO_Init(PIN_STPORT(pin), &GPIO_InitStruct);

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

irqmap = &pin_irq_map[irqindex];
GPIO_InitTypeDef GPIO_InitStruct;

/* Configure GPIO_InitStructure */
GPIO_InitStruct.Pin = PIN_STPIN(pin);
Expand All @@ -438,6 +437,7 @@ static rt_err_t stm32_pin_irq_enable(struct rt_device *device, rt_base_t pin,
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
break;
}
HAL_GPIO_Init(PIN_STPORT(pin), &GPIO_InitStruct);

HAL_NVIC_SetPriority(irqmap->irqno, 5, 0);
HAL_NVIC_EnableIRQ(irqmap->irqno);
Expand Down

0 comments on commit 5010c17

Please sign in to comment.