Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions bsp/Infineon/libraries/HAL_Drivers/drv_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2022-07-1 Rbb666 first version
* 2025-04-24 Passionate0424 fix ifx_pin_irq_enable
*/

#include "drv_gpio.h"
Expand Down Expand Up @@ -320,7 +321,7 @@ static rt_err_t ifx_pin_irq_enable(struct rt_device *device, rt_base_t pin,
irqmap = &pin_irq_map[gpio_port];

#if !defined(COMPONENT_CAT1C)
IRQn_Type irqn = (IRQn_Type)(irqmap->irqno + PORT_GET(irqmap->port));
IRQn_Type irqn = irqmap->irqno;
irq_cb_data[irqn].callback = irq_callback;
irq_cb_data[irqn].callback_arg = (rt_uint16_t *)&pin_irq_map[gpio_port].port;
Copy link

Copilot AI Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminating the addition of PORT_GET (irqmap->port) ensures that the correct IRQ number is used during IRQ initialization.

Suggested change
irq_cb_data[irqn].callback_arg = (rt_uint16_t *)&pin_irq_map[gpio_port].port;
irq_cb_data[irqn].callback_arg = (rt_uint16_t *)&irqmap->port; // Directly use irqmap->port

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不必要修改

cyhal_gpio_register_callback(gpio_pin, &irq_cb_data[irqn]);
Expand Down Expand Up @@ -353,10 +354,15 @@ static rt_err_t ifx_pin_irq_enable(struct rt_device *device, rt_base_t pin,
{
level = rt_hw_interrupt_disable();

Cy_GPIO_Port_Deinit(CYHAL_GET_PORTADDR(gpio_pin));
irqmap = &pin_irq_map[gpio_port];

#if !defined(COMPONENT_CAT1C)
IRQn_Type irqn = (IRQn_Type)(irqmap->irqno + PORT_GET(irqmap->port));
IRQn_Type irqn = irqmap->irqno;
if (irqn < 0 || irqn >= PIN_IFXPORT_MAX)
{
rt_hw_interrupt_enable(level);
return -RT_EINVAL;
}
_cyhal_irq_disable(irqn);
#endif
rt_hw_interrupt_enable(level);
Expand Down