You need to do this something like this:
program gpio_irq_test;
{$MODE OBJFPC}
{$H+}
uses
pico_gpio_c, pico_irq_c;
const
LED_PIN = 25;
IRQ_PIN = 15;
procedure irq_callback(gpio: byte; events: longword); cdecl;
begin
gpio_put(LED_PIN, not gpio_get(LED_PIN)); // Toggle LED on IRQ
end;
begin
stdio_init_all;
gpio_init(LED_PIN);
gpio_set_dir(LED_PIN, GPIO_OUT);
gpio_init(IRQ_PIN);
gpio_set_dir(IRQ_PIN, GPIO_IN);
gpio_pull_up(IRQ_PIN);
gpio_set_irq_enabled_with_callback(
IRQ_PIN,
GPIO_IRQ_EDGE_FALL,
true,
@irq_callback
);
while true do
// Main loop
end;
end.
And make sure you do this:
Link with pico_multicore, pico_stdlib, and hardware_gpio.
But you did not give me the hardware you want to control. So your milage may vary.
The above is very simple - for IoT fanatics like you and me, and should work.
Note everything is cdecl, but you know that.