platformio / platform-raspberrypi

Raspberry Pi: development platform for PlatformIO
https://registry.platformio.org/platforms/platformio/raspberrypi
Apache License 2.0
72 stars 94 forks source link

undefined reference to `alarm_pool_get_default' #51

Open pedrorovi opened 1 year ago

pedrorovi commented 1 year ago

I can't use the timer irq with the rp2040 and the arduino framework. Some help or recommendations?

#define PICO_TIME_DEFAULT_ALARM_POOL_DISABLED 0

#include <string.h>
#include "unity.h"

#include <stdio.h>
#include "pico/stdlib.h"
extern "C" {
#include <hardware/timer.h>
#include <hardware/watchdog.h>
#include "pico/multicore.h"
};
#include "pio_tx_controller.h"

#include "gpio.h"
#include "pico/time.h"

#include "test_utils.h"
// Implements
#include "tests.h"

void setUp(){};

void tearDown(){};

bool led_state{false};

bool led_callback(repeating_timer_t* rt) {
    Pio_tx_controller::get()->write("Hey Jude!\r\n");
    gpio_put(PICO_DEFAULT_LED_PIN, led_state);
    led_state = !led_state;
    return true;
}

void test_timer_irq() {
    _gpio_init(PICO_DEFAULT_LED_PIN);
    gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);

    struct repeating_timer timer;
    bool ok = add_repeating_timer_ms(1000, led_callback, NULL, &timer);

    while (true)
        tight_loop_contents();
};
Tykyo commented 9 months ago

That's because the Arduino framework use MBED library precompiled with #define PICO_TIME_DEFAULT_ALARM_POOL_DISABLED=1 So the function doesn't exist in the library and you can't link it.