我想找...

搜尋

分享

目錄

EthercatMaster.attachCyclicCallback()

[Ethercat Master]

描述

Register Cyclic Callback Function.

語法

int attachCyclicCallback(void (*callback)(void));

參數

  • [in] void (*callback)(void)
    The cyclic callback function to be registered, which has no parameters and no return value.

回傳值

Return an error code. If the returned value is zero, it indicates a successful execution of this function.

備註

This function must be called after a successful execution of EthercatMaster::begin() and before EthercatMaster::start(), or after a successful execution of EthercatMaster::stop() and before EthercatMaster::end().

範例

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_Generic slave;

void CyclicCallback() {
    // put your cyclic Callback function here.
}

void setup() {
    master.begin();
    slave.attach(0, master);
    master.attachCyclicCallback(CyclicCallback);
    master.start(1000000, ECAT_SYNC);  // 1000000 ns = 1 ms
}

void loop() {

}

Please see the EtherCAT Library User Manual for more QEC EtherCAT instructions and API usage.

返回頂端