move `GPIO_InitStruct` variable inside to `PIN_IRQ_ENABLE`. thanks to @mysterywolf
This commit is contained in:
parent
df36d1806c
commit
5010c17539
|
@ -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;
|
const struct pin_irq_map *irqmap;
|
||||||
rt_base_t level;
|
rt_base_t level;
|
||||||
rt_int32_t irqindex = -1;
|
rt_int32_t irqindex = -1;
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
|
||||||
HAL_GPIO_Init(PIN_STPORT(pin), &GPIO_InitStruct);
|
|
||||||
|
|
||||||
if (PIN_PORT(pin) >= PIN_STPORT_MAX)
|
if (PIN_PORT(pin) >= PIN_STPORT_MAX)
|
||||||
{
|
{
|
||||||
|
@ -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];
|
irqmap = &pin_irq_map[irqindex];
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
|
|
||||||
/* Configure GPIO_InitStructure */
|
/* Configure GPIO_InitStructure */
|
||||||
GPIO_InitStruct.Pin = PIN_STPIN(pin);
|
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,
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
HAL_GPIO_Init(PIN_STPORT(pin), &GPIO_InitStruct);
|
||||||
|
|
||||||
HAL_NVIC_SetPriority(irqmap->irqno, 5, 0);
|
HAL_NVIC_SetPriority(irqmap->irqno, 5, 0);
|
||||||
HAL_NVIC_EnableIRQ(irqmap->irqno);
|
HAL_NVIC_EnableIRQ(irqmap->irqno);
|
||||||
|
|
Loading…
Reference in New Issue