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. |
| void | syn_ecat_init (SYN_EcatNode * node, uint16_t station_addr, SYN_CANOpenNode * od) Initialize an EtherCAT Node instance. |
| 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) |
| void | store16_le (uint8_t * p, uint16_t val) |
| void | store32_le (uint8_t * p, uint32_t val) |
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_init¶
Initialize an EtherCAT Node instance.
Parameters:
nodeEtherCAT node instance.station_addrConfigured station address.odOptional CANopen Object Dictionary binding for CoE.
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¶
function store16_le¶
function store32_le¶
The documentation for this class was generated from the following file src/syntropic/proto/syn_ethercat.c