6 years ago.

Thread on mbed-os

Hello everyone, you can help me make this program work. Thank you

#include "mbed.h"

Thread t1;

DigitalOut led1(LED1);

// Blink function toggles the led in a long running loop
void blink(DigitalOut *led, int temp) {
    while (1) {
        *led = !*led;
        wait(temp);
    }
}

int main() {
    t1.start(callback(blink, &led1, 5));
}

this is the error that I find: Error: No instance of overloaded function "callback" matches the argument list in "main.cpp", Line: 19, Col: 15

P.S. this is an online translation

1 Answer

6 years ago.

Hi there,

Check out the following example on Thread's API Documentation page: https://os.mbed.com/docs/v5.8/reference/thread.html#thread-example-with-callbacks - essentially, using just the callback constructor, you can only send one argument to your callback function blink().

Here's a documentation page discussing how you can successfully send multiple arguments in a struct to your callback function: https://os.mbed.com/docs/v5.8/reference/platform.html#callbacks (scroll down the page and look for "If you need to pass multiple arguments to a callback...")

Please let me know if you have any questions!

- Jenny, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!

Accepted Answer