File syn_ethercat.c¶
FileList > proto > syn_ethercat.c
Go to the source code of this file
Bare-metal EtherCAT Protocol Engine implementation.
#include "../util/syn_assert.h"#include "syn_ethercat.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| size_t | syn_ecat_build_datagram_frame (uint8_t * buf, size_t buf_len, const SYN_EcatDatagram * datagram, const uint8_t * data, uint16_t data_len) Build an EtherCAT Frame containing one or more datagrams. |
| size_t | syn_ecat_coe_encode_sdo_download (uint8_t * buf, size_t buf_len, uint16_t index, uint8_t subindex, const void * data, size_t data_len) Encode a CoE SDO Download (Write) request into a mailbox buffer. |
| size_t | syn_ecat_coe_encode_sdo_upload (uint8_t * buf, size_t buf_len, uint16_t index, uint8_t subindex) Encode a CoE SDO Upload (Read) request into a mailbox buffer. |
| SYN_Status | syn_ecat_decode_coe_sdo_response (SYN_EcatMaster * m, size_t rx_len, void * out_data, size_t max_len, size_t * out_len) Decode SDO Upload response payload from rx_buf. |
| SYN_Status | syn_ecat_decode_cyclic (SYN_EcatMaster * m, size_t rx_len) Parse LRW cyclic process exchange response from rx_buf and copy inputs to input_image. |
| SYN_Status | syn_ecat_decode_read_al_status (SYN_EcatMaster * m, size_t rx_len, SYN_EcatState * state, uint16_t * status_code) Decode Application Layer (AL) Status and Status Code from response. |
| SYN_Status | syn_ecat_decode_read_reg (SYN_EcatMaster * m, size_t rx_len, void * out_data, uint16_t len) Decode FPRD response datagram for register read. |
| SYN_Status | syn_ecat_decode_read_sii (SYN_EcatMaster * m, size_t rx_len, uint32_t * out_val) Decode 32-bit word from SII EEPROM read response. |
| uint8_t | syn_ecat_decode_scan_bus (SYN_EcatMaster * m, size_t rx_len) Decode slave count from scan_bus response frame in rx_buf. |
| size_t | syn_ecat_encode_assign_addr (SYN_EcatMaster * m, uint16_t position, uint16_t station_addr) Encode Auto-Increment Write (APWR) to assign station address. |
| size_t | syn_ecat_encode_coe_sdo_read (SYN_EcatMaster * m, uint16_t station_addr, uint16_t index, uint8_t subindex) Encode a complete Mailbox-wrapped CoE SDO Upload request frame into tx_buf. |
| size_t | syn_ecat_encode_coe_sdo_write (SYN_EcatMaster * m, uint16_t station_addr, uint16_t index, uint8_t subindex, const void * data, size_t data_len) Encode a complete Mailbox-wrapped CoE SDO Download request frame into tx_buf. |
| size_t | syn_ecat_encode_cyclic (SYN_EcatMaster * m) Encode LRW (Logical Read Write) cyclic process exchange frame into tx_buf. |
| size_t | syn_ecat_encode_dc_configure (SYN_EcatMaster * m, uint16_t station_addr, uint32_t sync0_cycle_ns, int32_t sync0_shift_ns) Encode FPWR to configure DC SYNC0 cycle time and shift for a slave. |
| size_t | syn_ecat_encode_dc_read_system_time (SYN_EcatMaster * m) Encode Auto-Increment Read Multiple Write (ARMW) for DC System Time propagation. |
| size_t | syn_ecat_encode_read_al_status (SYN_EcatMaster * m, uint16_t station_addr) Encode Configured Read (FPRD) to read slave Application Layer (AL) Status. |
| size_t | syn_ecat_encode_read_reg (SYN_EcatMaster * m, uint16_t station_addr, uint16_t reg_addr, uint16_t len) Encode FPRD to read register reg_addr from slavestation_addr . |
| size_t | syn_ecat_encode_read_sii (SYN_EcatMaster * m, uint16_t station_addr, uint16_t word_offset) Encode Configured Read (FPRD) to read SII EEPROM word. |
| size_t | syn_ecat_encode_scan_bus (SYN_EcatMaster * m) Encode Broadcast Read (BRD) to scan bus slave count into master tx_buf. |
| size_t | syn_ecat_encode_set_al_control (SYN_EcatMaster * m, uint16_t station_addr, SYN_EcatState state) Encode Configured Write (FPWR) to set slave Application Layer (AL) Control register. |
| size_t | syn_ecat_encode_write_fmmu (SYN_EcatMaster * m, uint16_t station_addr, uint8_t fmmu_index, const SYN_EcatFMMUConfig * cfg) Encode Configured Write (FPWR) to configure an FMMU register block. |
| size_t | syn_ecat_encode_write_reg (SYN_EcatMaster * m, uint16_t station_addr, uint16_t reg_addr, const void * data, uint16_t len) Encode FPWR to write register reg_addr to slavestation_addr . |
| size_t | syn_ecat_encode_write_sm (SYN_EcatMaster * m, uint16_t station_addr, uint8_t sm_index, const SYN_EcatSMConfig * cfg) Encode Configured Write (FPWR) to configure a SyncManager register block. |
| size_t | syn_ecat_frame_add_datagram (uint8_t * buf, size_t buf_size, SYN_EcatCmd cmd, uint8_t idx, uint32_t addr, const uint8_t * data, uint16_t data_len, bool circ) Add a datagram payload to an in-progress EtherCAT frame. |
| void | syn_ecat_frame_begin (uint8_t * buf, size_t buf_size) Initialize an EtherCAT frame buffer header. |
| size_t | syn_ecat_frame_finalize (uint8_t * buf) Finalize EtherCAT frame header length field. |
| bool | syn_ecat_frame_parse_next (const uint8_t * frame, size_t frame_len, size_t * offset, SYN_EcatDatagramResult * out) Parse the next datagram from an EtherCAT frame buffer. |
| void | syn_ecat_init (SYN_EcatNode * node, uint16_t station_addr, SYN_CANOpenNode * od) Initialize an EtherCAT Node instance. |
| SYN_PT_Status | syn_ecat_master_cyclic_task (SYN_PT * pt, SYN_EcatMaster * m) Protothread Task: Execute single cyclic process exchange cycle. |
| SYN_PT_Status | syn_ecat_master_discover_pdo_mapping_task (SYN_PT * pt, SYN_EcatMaster * m, uint16_t station_addr, uint16_t * out_rx_bytes, uint16_t * out_tx_bytes) Protothread Task: Read CoE Object Dictionary 0x1C12/0x1C13 to calculate slave Rx/Tx PDO byte lengths. |
| SYN_Status | syn_ecat_master_init (SYN_EcatMaster * m, uint8_t * tx_buf, uint16_t tx_buf_size, uint8_t * rx_buf, uint16_t rx_buf_size, uint8_t * output_image, uint16_t output_size, uint8_t * input_image, uint16_t input_size) Initialize EtherCAT Master instance context. |
| bool | syn_ecat_master_pop_tx_frame (SYN_EcatMaster * m, const uint8_t ** out_frame, size_t * out_len) Pop pending transmit frame for Ethernet PHY driver. |
| SYN_PT_Status | syn_ecat_master_read_sii_task (SYN_PT * pt, SYN_EcatMaster * m, uint16_t station_addr, uint16_t word_offset, uint32_t * out_data) Protothread Task: Read 32-bit word from slave SII EEPROM via hardware status polling. |
| SYN_PT_Status | syn_ecat_master_scan_task (SYN_PT * pt, SYN_EcatMaster * m) Protothread Task: Scan EtherCAT bus and assign station addresses. |
| SYN_PT_Status | syn_ecat_master_sdo_read_task (SYN_PT * pt, SYN_EcatMaster * m, uint16_t station_addr, uint16_t index, uint8_t subindex, void * out_data, size_t max_len, size_t * out_len) Protothread Task: CoE SDO read from slave Object Dictionary with SM1 polling. |
| SYN_Status | syn_ecat_master_set_rx_frame (SYN_EcatMaster * m, const uint8_t * frame, size_t len) Feed received Ethernet frame into Master context. |
| SYN_PT_Status | syn_ecat_master_transition_task (SYN_PT * pt, SYN_EcatMaster * m, SYN_EcatState target_state) Protothread Task: Drive EtherCAT slaves through state transition. |
| SYN_Status | syn_ecat_parse_frame (SYN_EcatNode * node, const uint8_t * frame, size_t len, uint16_t * wkc) Parse and process a received raw EtherCAT frame. |
| SYN_Status | syn_ecat_set_state (SYN_EcatNode * node, SYN_EcatState new_state) Request an EtherCAT State Machine (ESM) state transition. |
| void | syn_ecat_update (SYN_EcatNode * node) Run ESM state machine step. |
Public Static Functions¶
| Type | Name |
|---|---|
| uint16_t | load16_le (const uint8_t * p) Load 16-bit unsigned integer from little-endian byte order. |
| uint32_t | load32_le (const uint8_t * p) Load 32-bit unsigned integer from little-endian byte order. |
| void | store16_le (uint8_t * p, uint16_t val) Store 16-bit unsigned integer in little-endian byte order. |
| void | store32_le (uint8_t * p, uint32_t val) Store 32-bit unsigned integer in little-endian byte order. |
| uint16_t | syn_ecat_get_slave_station_addr (const SYN_EcatMaster * m, uint8_t idx) Get configured station address for slave index. |
Public Functions Documentation¶
function syn_ecat_build_datagram_frame¶
Build an EtherCAT Frame containing one or more datagrams.
size_t syn_ecat_build_datagram_frame (
uint8_t * buf,
size_t buf_len,
const SYN_EcatDatagram * datagram,
const uint8_t * data,
uint16_t data_len
)
Parameters:
bufOutput frame buffer (must include Ethernet header space if needed).buf_lenCapacity of output buffer.datagramDatagram header descriptor.dataPayload bytes to write into datagram.data_lenPayload length.
Returns:
Total EtherCAT frame length in bytes, or 0 on error.
function syn_ecat_coe_encode_sdo_download¶
Encode a CoE SDO Download (Write) request into a mailbox buffer.
size_t syn_ecat_coe_encode_sdo_download (
uint8_t * buf,
size_t buf_len,
uint16_t index,
uint8_t subindex,
const void * data,
size_t data_len
)
Parameters:
bufOutput buffer.buf_lenCapacity of output buffer.indexObject Dictionary Index (0x0000 - 0xFFFF).subindexSubindex (0x00 - 0xFF).dataData bytes to write.data_lenData length (1-4 bytes for expedited SDO).
Returns:
Encoded CoE Mailbox packet length in bytes, or 0 on error.
function syn_ecat_coe_encode_sdo_upload¶
Encode a CoE SDO Upload (Read) request into a mailbox buffer.
size_t syn_ecat_coe_encode_sdo_upload (
uint8_t * buf,
size_t buf_len,
uint16_t index,
uint8_t subindex
)
Parameters:
bufOutput buffer.buf_lenCapacity of output buffer.indexObject Dictionary Index (0x0000 - 0xFFFF).subindexSubindex (0x00 - 0xFF).
Returns:
Encoded CoE Mailbox packet length in bytes, or 0 on error.
function syn_ecat_decode_coe_sdo_response¶
Decode SDO Upload response payload from rx_buf.
SYN_Status syn_ecat_decode_coe_sdo_response (
SYN_EcatMaster * m,
size_t rx_len,
void * out_data,
size_t max_len,
size_t * out_len
)
Parameters:
mPointer to master handle.rx_lenReceived frame length.out_dataOutput destination buffer.max_lenMaximum output buffer capacity.out_lenPointer to receive read byte count.
Returns:
SYN_OK on success.
function syn_ecat_decode_cyclic¶
Parse LRW cyclic process exchange response from rx_buf and copy inputs to input_image.
Parameters:
mPointer to master handle.rx_lenReceived frame byte length.
Returns:
SYN_OK if WKC >= wkc_expected, SYN_ERROR on WKC mismatch or parsing error.
function syn_ecat_decode_read_al_status¶
Decode Application Layer (AL) Status and Status Code from response.
SYN_Status syn_ecat_decode_read_al_status (
SYN_EcatMaster * m,
size_t rx_len,
SYN_EcatState * state,
uint16_t * status_code
)
Parameters:
mPointer to master handle.rx_lenReceived frame length.state[out] Output location for current ESM state.status_code[out] Output location for AL status error code.
Returns:
SYN_OK on success.
function syn_ecat_decode_read_reg¶
Decode FPRD response datagram for register read.
SYN_Status syn_ecat_decode_read_reg (
SYN_EcatMaster * m,
size_t rx_len,
void * out_data,
uint16_t len
)
Parameters:
mPointer to master handle.rx_lenReceived Ethernet frame length.out_dataDestination buffer for register data.lenExpected byte length.
Returns:
SYN_OK on success, error code otherwise.
function syn_ecat_decode_read_sii¶
Decode 32-bit word from SII EEPROM read response.
Parameters:
mPointer to master handle.rx_lenReceived frame length.out_valPointer to receive parsed 32-bit SII value.
Returns:
SYN_OK on success.
function syn_ecat_decode_scan_bus¶
Decode slave count from scan_bus response frame in rx_buf.
Parameters:
mPointer to master handle.rx_lenReceived frame byte length.
Returns:
Discovered slave count.
function syn_ecat_encode_assign_addr¶
Encode Auto-Increment Write (APWR) to assign station address.
Parameters:
mPointer to master handle.positionRing position index (0..slave_count-1).station_addrConfigured station address to set (e.g. 0x1001).
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_encode_coe_sdo_read¶
Encode a complete Mailbox-wrapped CoE SDO Upload request frame into tx_buf.
size_t syn_ecat_encode_coe_sdo_read (
SYN_EcatMaster * m,
uint16_t station_addr,
uint16_t index,
uint8_t subindex
)
Parameters:
mPointer to master handle.station_addrTarget slave station address.indexObject Dictionary Index.subindexSubindex.
Returns:
Transmit frame byte length, or 0 on error.
function syn_ecat_encode_coe_sdo_write¶
Encode a complete Mailbox-wrapped CoE SDO Download request frame into tx_buf.
size_t syn_ecat_encode_coe_sdo_write (
SYN_EcatMaster * m,
uint16_t station_addr,
uint16_t index,
uint8_t subindex,
const void * data,
size_t data_len
)
Parameters:
mPointer to master handle.station_addrTarget slave station address.indexObject Dictionary Index.subindexSubindex.dataPointer to payload bytes (<=4 bytes for expedited SDO).data_lenPayload byte length.
Returns:
Transmit frame byte length, or 0 on error.
function syn_ecat_encode_cyclic¶
Encode LRW (Logical Read Write) cyclic process exchange frame into tx_buf.
Parameters:
mPointer to master handle.
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_encode_dc_configure¶
Encode FPWR to configure DC SYNC0 cycle time and shift for a slave.
size_t syn_ecat_encode_dc_configure (
SYN_EcatMaster * m,
uint16_t station_addr,
uint32_t sync0_cycle_ns,
int32_t sync0_shift_ns
)
Parameters:
mPointer to master handle.station_addrTarget slave station address.sync0_cycle_nsSYNC0 cycle time in nanoseconds.sync0_shift_nsSYNC0 shift time in nanoseconds.
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_encode_dc_read_system_time¶
Encode Auto-Increment Read Multiple Write (ARMW) for DC System Time propagation.
Parameters:
mPointer to master handle.
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_encode_read_al_status¶
Encode Configured Read (FPRD) to read slave Application Layer (AL) Status.
Parameters:
mPointer to master handle.station_addrTarget slave station address.
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_encode_read_reg¶
Encode FPRD to read register reg_addr from slavestation_addr .
size_t syn_ecat_encode_read_reg (
SYN_EcatMaster * m,
uint16_t station_addr,
uint16_t reg_addr,
uint16_t len
)
Parameters:
mPointer to master handle.station_addrConfigured station address of slave.reg_addrRegister address to read.lenNumber of bytes to read.
Returns:
Encoded Ethernet frame length.
function syn_ecat_encode_read_sii¶
Encode Configured Read (FPRD) to read SII EEPROM word.
Parameters:
mPointer to master handle.station_addrTarget slave station address.word_offsetSII EEPROM word offset.
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_encode_scan_bus¶
Encode Broadcast Read (BRD) to scan bus slave count into master tx_buf.
Parameters:
mPointer to master handle.
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_encode_set_al_control¶
Encode Configured Write (FPWR) to set slave Application Layer (AL) Control register.
size_t syn_ecat_encode_set_al_control (
SYN_EcatMaster * m,
uint16_t station_addr,
SYN_EcatState state
)
Parameters:
mPointer to master handle.station_addrTarget slave station address.stateRequested ESM State (INIT, PREOP, SAFEOP, OP).
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_encode_write_fmmu¶
Encode Configured Write (FPWR) to configure an FMMU register block.
size_t syn_ecat_encode_write_fmmu (
SYN_EcatMaster * m,
uint16_t station_addr,
uint8_t fmmu_index,
const SYN_EcatFMMUConfig * cfg
)
Parameters:
mPointer to master handle.station_addrTarget slave station address.fmmu_indexFMMU index (0..3).cfgPointer to FMMU configuration settings.
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_encode_write_reg¶
Encode FPWR to write register reg_addr to slavestation_addr .
size_t syn_ecat_encode_write_reg (
SYN_EcatMaster * m,
uint16_t station_addr,
uint16_t reg_addr,
const void * data,
uint16_t len
)
Parameters:
mPointer to master handle.station_addrConfigured station address of slave.reg_addrRegister address to write.dataPointer to data bytes to write.lenNumber of bytes to write.
Returns:
Encoded Ethernet frame length.
function syn_ecat_encode_write_sm¶
Encode Configured Write (FPWR) to configure a SyncManager register block.
size_t syn_ecat_encode_write_sm (
SYN_EcatMaster * m,
uint16_t station_addr,
uint8_t sm_index,
const SYN_EcatSMConfig * cfg
)
Parameters:
mPointer to master handle.station_addrTarget slave station address.sm_indexSyncManager index (0..3).cfgPointer to SyncManager configuration settings.
Returns:
Transmit frame length in bytes, or 0 on error.
function syn_ecat_frame_add_datagram¶
Add a datagram payload to an in-progress EtherCAT frame.
size_t syn_ecat_frame_add_datagram (
uint8_t * buf,
size_t buf_size,
SYN_EcatCmd cmd,
uint8_t idx,
uint32_t addr,
const uint8_t * data,
uint16_t data_len,
bool circ
)
Parameters:
bufTarget output buffer.buf_sizeTotal capacity of output buffer.cmdDatagram command type.idxDatagram index.addr32-bit address field.dataPayload data bytes (or NULL if data_len is 0).data_lenPayload data length in bytes.circTrue if circulating datagram flag set.
Returns:
Output byte offset after added datagram, or 0 on error / insufficient space.
function syn_ecat_frame_begin¶
Initialize an EtherCAT frame buffer header.
Parameters:
bufTarget output buffer.buf_sizeTotal capacity of output buffer.
function syn_ecat_frame_finalize¶
Finalize EtherCAT frame header length field.
Parameters:
bufTarget output buffer.
Returns:
Total frame size in bytes (including 2-byte EtherCAT header).
function syn_ecat_frame_parse_next¶
Parse the next datagram from an EtherCAT frame buffer.
bool syn_ecat_frame_parse_next (
const uint8_t * frame,
size_t frame_len,
size_t * offset,
SYN_EcatDatagramResult * out
)
Parameters:
framePointer to raw EtherCAT frame bytes (starts with 2-byte EtherCAT header).frame_lenTotal byte length of frame buffer.offsetIn/out byte offset into frame buffer. Set *offset = 2 to start.out[out] Result struct to receive parsed datagram details.
Returns:
true if datagram parsed successfully, false if no more datagrams or malformed.
function syn_ecat_init¶
Initialize an EtherCAT Node instance.
Parameters:
nodeEtherCAT node instance.station_addrConfigured station address.odOptional CANopen Object Dictionary binding for CoE.
function syn_ecat_master_cyclic_task¶
Protothread Task: Execute single cyclic process exchange cycle.
Parameters:
ptProtothread state handle.mPointer to master handle.
Returns:
PT_WAITING if waiting for frames, PT_ENDED when cycle complete.
function syn_ecat_master_discover_pdo_mapping_task¶
Protothread Task: Read CoE Object Dictionary 0x1C12/0x1C13 to calculate slave Rx/Tx PDO byte lengths.
SYN_PT_Status syn_ecat_master_discover_pdo_mapping_task (
SYN_PT * pt,
SYN_EcatMaster * m,
uint16_t station_addr,
uint16_t * out_rx_bytes,
uint16_t * out_tx_bytes
)
Parameters:
ptProtothread context pointer.mPointer to master handle.station_addrConfigured station address of slave.out_rx_bytesDestination pointer for Rx PDO byte size.out_tx_bytesDestination pointer for Tx PDO byte size.
Returns:
PT_WAITING if waiting, PT_ENDED when complete.
function syn_ecat_master_init¶
Initialize EtherCAT Master instance context.
SYN_Status syn_ecat_master_init (
SYN_EcatMaster * m,
uint8_t * tx_buf,
uint16_t tx_buf_size,
uint8_t * rx_buf,
uint16_t rx_buf_size,
uint8_t * output_image,
uint16_t output_size,
uint8_t * input_image,
uint16_t input_size
)
Parameters:
mPointer to master handle.tx_bufPointer to static transmit frame buffer.tx_buf_sizeCapacity of transmit frame buffer.rx_bufPointer to static receive frame buffer.rx_buf_sizeCapacity of receive frame buffer.output_imageOutput process image buffer pointer.output_sizeOutput process image byte size.input_imageInput process image buffer pointer.input_sizeInput process image byte size.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if parameters null/invalid.
function syn_ecat_master_pop_tx_frame¶
Pop pending transmit frame for Ethernet PHY driver.
bool syn_ecat_master_pop_tx_frame (
SYN_EcatMaster * m,
const uint8_t ** out_frame,
size_t * out_len
)
Parameters:
mPointer to master handle.out_frame[out] Pointer to receive frame location.out_len[out] Pointer to receive frame length.
Returns:
true if frame was popped, false if no frame pending.
function syn_ecat_master_read_sii_task¶
Protothread Task: Read 32-bit word from slave SII EEPROM via hardware status polling.
SYN_PT_Status syn_ecat_master_read_sii_task (
SYN_PT * pt,
SYN_EcatMaster * m,
uint16_t station_addr,
uint16_t word_offset,
uint32_t * out_data
)
Parameters:
ptProtothread context pointer.mPointer to master handle.station_addrConfigured station address of slave.word_offset16-bit word offset in SII EEPROM.out_dataDestination pointer for 32-bit word.
Returns:
PT_WAITING if waiting, PT_ENDED when complete.
function syn_ecat_master_scan_task¶
Protothread Task: Scan EtherCAT bus and assign station addresses.
Parameters:
ptProtothread state handle.mPointer to master handle.
Returns:
PT_WAITING if waiting for frames, PT_ENDED when scan complete.
function syn_ecat_master_sdo_read_task¶
Protothread Task: CoE SDO read from slave Object Dictionary with SM1 polling.
SYN_PT_Status syn_ecat_master_sdo_read_task (
SYN_PT * pt,
SYN_EcatMaster * m,
uint16_t station_addr,
uint16_t index,
uint8_t subindex,
void * out_data,
size_t max_len,
size_t * out_len
)
Parameters:
ptProtothread context pointer.mPointer to master handle.station_addrConfigured station address of slave.index16-bit Object Dictionary index.subindex8-bit sub-index.out_dataDestination buffer for SDO payload.max_lenCapacity of destination buffer.out_lenDestination pointer for actual payload length.
Returns:
PT_WAITING if waiting, PT_ENDED when complete.
function syn_ecat_master_set_rx_frame¶
Feed received Ethernet frame into Master context.
Parameters:
mPointer to master handle.framePointer to raw frame payload bytes.lenFrame length in bytes.
Returns:
SYN_OK on success.
function syn_ecat_master_transition_task¶
Protothread Task: Drive EtherCAT slaves through state transition.
SYN_PT_Status syn_ecat_master_transition_task (
SYN_PT * pt,
SYN_EcatMaster * m,
SYN_EcatState target_state
)
Parameters:
ptProtothread state handle.mPointer to master handle.target_stateTarget ESM state (INIT, PREOP, SAFEOP, OP).
Returns:
PT_WAITING if waiting for frames, PT_ENDED when transition complete.
function syn_ecat_parse_frame¶
Parse and process a received raw EtherCAT frame.
SYN_Status syn_ecat_parse_frame (
SYN_EcatNode * node,
const uint8_t * frame,
size_t len,
uint16_t * wkc
)
Parameters:
nodeEtherCAT node instance.frameRaw received frame bytes (after Ethernet header).lenFrame length in bytes.wkc[out] Extracted Working Counter sum.
Returns:
SYN_OK on successful parsing and WKC validation.
function syn_ecat_set_state¶
Request an EtherCAT State Machine (ESM) state transition.
Parameters:
nodeEtherCAT node instance.new_stateRequested state (INIT, PREOP, BOOT, SAFEOP, OP).
Returns:
SYN_OK if state transition request is valid.
function syn_ecat_update¶
Run ESM state machine step.
Parameters:
nodeEtherCAT node instance.
Public Static Functions Documentation¶
function load16_le¶
Load 16-bit unsigned integer from little-endian byte order.
Parameters:
pPointer to input buffer.
Returns:
16-bit integer value.
function load32_le¶
Load 32-bit unsigned integer from little-endian byte order.
Parameters:
pPointer to input buffer.
Returns:
32-bit integer value.
function store16_le¶
Store 16-bit unsigned integer in little-endian byte order.
Parameters:
pPointer to output buffer.val16-bit integer value.
function store32_le¶
Store 32-bit unsigned integer in little-endian byte order.
Parameters:
pPointer to output buffer.val32-bit integer value.
function syn_ecat_get_slave_station_addr¶
Get configured station address for slave index.
Parameters:
mPointer to EtherCAT Master instance.idxSlave index in master slave table.
Returns:
Station address.
The documentation for this class was generated from the following file src/syntropic/proto/syn_ethercat.c