错误:没有重载函数“mbed :: Ticker :: attach”的实例与参数列表匹配

问题描述 投票:0回答:1

我在这里设置了自动收报机:

Ticker readSample;


uint16_t* sample() {
    samples[sCount]=sensor.read_u16(); 
    sCount++; 
    if(sCount == 159) {
        sCount = 0;
    }
    return samples; 
}

并在主函数中调用它:

int main() {
readSample.attach(&sample, 0.0125);

我得到错误代码304,不知道如何克服这一点。找不到可以转移到我工作中的直接答案。

错误:没有重载函数“mbed :: Ticker :: attach”的实例匹配“main.cpp”中的参数列表,行:142,Col:17

第一次海报,编码的业余爱好者,任何和所有帮助/建议都非常受欢迎。

c++ overloading interrupt mbed ticker
1个回答
2
投票

附加函数的返回类型必须是无效的。你不能返回uint16_t *。这是函数声明。

attach (Callback< void()> func, float t)

您可以在此处了解有关Ticker课程的更多信息。 https://os.mbed.com/docs/mbed-os/v5.11/apis/ticker.html

© www.soinside.com 2019 - 2024. All rights reserved.