[Ethercat Master]
描述
Register Event Callback Function.
語法
void attachEventCallback(void (*callback)(uint32_t));
參數
[in] void (*callback)(uint32_t)
The event callback function to be registered, which only has one parameter, a 32-bit event code.
回傳值
無
備註
This function must be called before EthercatMaster::begin() or after EthercatMaster::end().
範例
#include "Ethercat.h"
EthercatMaster master;
EthercatDevice_Generic slave;
uint32_t EventCode = 0;
void EventCallback(uint32_t eventcode) {
EventCode = eventcode;
}
void setup() {
Serial.begin(115200);
master.attachEventCallback(EventCallback); // EventCallback Function.
master.begin();
slave.attach(0, master);
master.start(1000000, ECAT_SYNC); // 1000000 ns = 1 ms
}
void loop() {
/* Event Code */
uint32_t event = EventCode;
EventCode = 0;
if (event) {
Serial.print("EventCode:");
Serial.println(event);
}
}Please see the EtherCAT Library User Manual for more QEC EtherCAT instructions and API usage.