File syn_ethercat.h¶
FileList > proto > syn_ethercat.h
Go to the source code of this file
EtherCAT (IEEE 802.3 EtherType 0x88A4) Bare-Metal Protocol Stack. More...
#include "../common/syn_defs.h"#include "../pt/syn_pt.h"#include "syn_canopen.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include "../sched/syn_task.h"
Classes¶
| Type | Name |
|---|---|
| struct | SYN_EcatCoEHeader CoE (CANoverEtherCAT) Mailbox Header. |
| struct | SYN_EcatDatagram EtherCAT Datagram Header (10 bytes header + 2 bytes WKC = 12 bytes overhead) |
| struct | SYN_EcatDatagramResult Parsed datagram item from frame iteration. |
| struct | SYN_EcatFMMUConfig EtherCAT FMMU Configuration. |
| struct | SYN_EcatHeader Raw EtherCAT Header (2 bytes) |
| struct | SYN_EcatMaster EtherCAT Master Instance Context (Zero-Heap). |
| struct | SYN_EcatNode EtherCAT Node Descriptor. |
| struct | SYN_EcatSMConfig EtherCAT SyncManager Configuration. |
| struct | SYN_EcatSlaveInfo EtherCAT Slave Information Entry. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_EcatCmd |
| enum | SYN_EcatCoEType |
| enum | SYN_EcatState |
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. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_ECAT_MAX_SLAVES 16U |
| define | SYN_ESC_REG_AL_CONTROL 0x0120U |
| define | SYN_ESC_REG_AL_STATUS 0x0130U |
| define | SYN_ESC_REG_AL_STATUS_CODE 0x0134U |
| define | SYN_ESC_REG_DC_SYNC0_CYCLE 0x09A0U |
| define | SYN_ESC_REG_DC_SYSTEM_OFFSET 0x0920U |
| define | SYN_ESC_REG_DC_SYSTEM_TIME 0x0900U |
| define | SYN_ESC_REG_FMMU0 0x0600U |
| define | SYN_ESC_REG_PDI_CONTROL 0x0140U |
| define | SYN_ESC_REG_SII_EEPROM_CTRL 0x0502U |
| define | SYN_ESC_REG_SM0 0x0800U |
| define | SYN_ESC_REG_STATION_ADDR 0x0010U |
| define | SYN_ESC_REG_STATION_ALIAS 0x0012U |
| define | SYN_ESC_REG_TYPE 0x0000U |
| define | SYN_ETHERCAT_ETHERTYPE 0x88A4EtherCAT IEEE 802.3 Ethernet Frame Type. |
| define | SYN_ETHERCAT_TYPE_DATAGRAM 1EtherCAT Header Type (1 = EtherCAT Datagrams) |
Detailed Description¶
Implements EtherCAT Frame packing, Datagram commands (APRD, APWR, APRW, FPRD, FPWR, FPRW, BRD, BWR, LRD, LWR, LRW), Working Counter (WKC) accounting, EtherCAT State Machine (ESM: INIT, PREOP, BOOT, SAFEOP, OP), and CoE (CAN application protocol over EtherCAT) Mailbox SDO & PDO handling.
Designed for zero heap allocation and direct L2 raw Ethernet frame processing.
Public Types Documentation¶
enum SYN_EcatCmd¶
enum SYN_EcatCmd {
SYN_ECAT_CMD_NOP = 0,
SYN_ECAT_CMD_APRD = 1,
SYN_ECAT_CMD_APWR = 2,
SYN_ECAT_CMD_APRW = 3,
SYN_ECAT_CMD_FPRD = 4,
SYN_ECAT_CMD_FPWR = 5,
SYN_ECAT_CMD_FPRW = 6,
SYN_ECAT_CMD_BRD = 7,
SYN_ECAT_CMD_BWR = 8,
SYN_ECAT_CMD_BRW = 9,
SYN_ECAT_CMD_LRD = 10,
SYN_ECAT_CMD_LWR = 11,
SYN_ECAT_CMD_LRW = 12,
SYN_ECAT_CMD_ARMW = 13,
SYN_ECAT_CMD_FRMW = 14
};
EtherCAT Datagram Commands Enum.
enum SYN_EcatCoEType¶
enum SYN_EcatCoEType {
SYN_ECAT_COE_TYPE_EMERGENCY = 1,
SYN_ECAT_COE_TYPE_SDO_REQ = 2,
SYN_ECAT_COE_TYPE_SDO_RESP = 3,
SYN_ECAT_COE_TYPE_RXPDO = 4,
SYN_ECAT_COE_TYPE_TXPDO = 5,
SYN_ECAT_COE_TYPE_SDO_INFO = 6
};
CAN Application Protocol over EtherCAT (CoE) Service Types.
enum SYN_EcatState¶
enum SYN_EcatState {
SYN_ECAT_STATE_NONE = 0x00,
SYN_ECAT_STATE_INIT = 0x01,
SYN_ECAT_STATE_PREOP = 0x02,
SYN_ECAT_STATE_BOOT = 0x03,
SYN_ECAT_STATE_SAFEOP = 0x04,
SYN_ECAT_STATE_OP = 0x08
};
EtherCAT State Machine (ESM) States.
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.
Macro Definition Documentation¶
define SYN_ECAT_MAX_SLAVES¶
Maximum connected EtherCAT slaves supported
define SYN_ESC_REG_AL_CONTROL¶
Application Layer Control
define SYN_ESC_REG_AL_STATUS¶
Application Layer Status
define SYN_ESC_REG_AL_STATUS_CODE¶
Application Layer Status Code
define SYN_ESC_REG_DC_SYNC0_CYCLE¶
DC SYNC0 Cycle Time
define SYN_ESC_REG_DC_SYSTEM_OFFSET¶
DC System Time Offset
define SYN_ESC_REG_DC_SYSTEM_TIME¶
DC System Time (64-bit)
define SYN_ESC_REG_FMMU0¶
FMMU 0 Base (16 bytes per FMMU)
define SYN_ESC_REG_PDI_CONTROL¶
Process Data Interface Control
define SYN_ESC_REG_SII_EEPROM_CTRL¶
SII EEPROM Control/Status
define SYN_ESC_REG_SM0¶
SyncManager 0 Base (8 bytes per SM)
define SYN_ESC_REG_STATION_ADDR¶
Configured Station Address
define SYN_ESC_REG_STATION_ALIAS¶
Configured Station Alias
define SYN_ESC_REG_TYPE¶
ESC Type/Build
define SYN_ETHERCAT_ETHERTYPE¶
EtherCAT IEEE 802.3 Ethernet Frame Type.
define SYN_ETHERCAT_TYPE_DATAGRAM¶
EtherCAT Header Type (1 = EtherCAT Datagrams)
The documentation for this class was generated from the following file src/syntropic/proto/syn_ethercat.h