Skip to content

File syn_iolink.h

FileList > proto > syn_iolink.h

Go to the source code of this file

IO-Link (IEC 61131-9) Single-Drop Digital Point-to-Point Master & Device Protocol Engine. More...

  • #include "../common/syn_defs.h"
  • #include "../net/syn_transport.h"
  • #include "../pt/syn_pt.h"
  • #include "../sched/syn_sched.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_IOLink_Device
IO-Link Device instance context.
struct SYN_IOLink_DeviceConfig
Device configuration descriptor.
struct SYN_IOLink_DirectParams
Direct Parameter Page 1 structure.
struct SYN_IOLink_Master
IO-Link Master instance context.
struct SYN_IOLink_MasterConfig
Master configuration descriptor.

Public Types

Type Name
enum SYN_IOLink_Baud
IO-Link transmission speed baud rate.
typedef SYN_Status(* SYN_IOLink_ISDU_ReadCb
Callback for dynamic ISDU parameter read.
typedef SYN_Status(* SYN_IOLink_ISDU_WriteCb
Callback for dynamic ISDU parameter write.
enum SYN_IOLink_MSeqType
M-Sequence message type.
enum SYN_IOLink_PortState
Port operational state.

Public Functions

Type Name
uint8_t syn_iolink_calc_checksum (const uint8_t * data, size_t len)
Calculate standard IO-Link 6-bit CRC with parity.
SYN_Status syn_iolink_device_get_pd_out (const SYN_IOLink_Device * dev, uint8_t * out_buf, size_t max_len, size_t * out_len)
Get the device's latest actuator output process data written by master.
SYN_Status syn_iolink_device_init (SYN_IOLink_Device * dev, const SYN_IOLink_DeviceConfig * cfg)
Initialize IO-Link Device.
SYN_Status syn_iolink_device_process_frame (SYN_IOLink_Device * dev, const uint8_t * rx, size_t rx_len, uint8_t * tx, size_t max_tx, size_t * out_len)
Process an inbound M-Sequence master frame and generate the device response frame.
SYN_Status syn_iolink_device_set_pd_in (SYN_IOLink_Device * dev, const uint8_t * data, size_t len)
Set the device's sensor input process data.
SYN_Status syn_iolink_master_exchange_pd (SYN_IOLink_Master * master, const uint8_t * pd_out, size_t out_len, uint8_t * pd_in, size_t * in_len)
Perform a cyclic Process Data exchange with connected device.
SYN_Status syn_iolink_master_init (SYN_IOLink_Master * master, const SYN_IOLink_MasterConfig * cfg)
Initialize IO-Link Master.
SYN_PT_Status syn_iolink_master_pt (SYN_PT * pt, SYN_Task * task)
Protothread continuation function for syn_sched .
SYN_Status syn_iolink_master_read_isdu (SYN_IOLink_Master * master, uint16_t index, uint8_t subindex, uint8_t * data, size_t max_len, size_t * out_len)
Read an acyclic ISDU parameter from device.
SYN_Status syn_iolink_master_start (SYN_IOLink_Master * master)
Trigger master startup handshake sequence on connected port.
SYN_Status syn_iolink_master_step (SYN_IOLink_Master * master, uint32_t now_ms)
Step the IO-Link master state machine and cyclic communication loop.
SYN_Status syn_iolink_master_write_isdu (SYN_IOLink_Master * master, uint16_t index, uint8_t subindex, const uint8_t * data, size_t len)
Write an acyclic ISDU parameter to device.

Macros

Type Name
define SYN_IOLINK_MAX_ISDU_LEN 64U
define SYN_IOLINK_MAX_PD_LEN 32U
define SYN_IOLINK_PAGE_DEVICE_ID_1 0x08U
define SYN_IOLINK_PAGE_DEVICE_ID_2 0x09U
define SYN_IOLINK_PAGE_DEVICE_ID_3 0x0AU
define SYN_IOLINK_PAGE_MASTER_CYCLE_TIME 0x00U
define SYN_IOLINK_PAGE_MIN_CYCLE_TIME 0x01U
define SYN_IOLINK_PAGE_MSEQ_CAPABILITY 0x02U
define SYN_IOLINK_PAGE_PD_IN_LEN 0x04U
define SYN_IOLINK_PAGE_PD_OUT_LEN 0x05U
define SYN_IOLINK_PAGE_REVISION_ID 0x03U
define SYN_IOLINK_PAGE_VENDOR_ID_1 0x06U
define SYN_IOLINK_PAGE_VENDOR_ID_2 0x07U
define SYN_IOLINK_REV_1_0 0x10U
define SYN_IOLINK_REV_1_1 0x11U

Detailed Description

Implements a zero-heap, deterministic IO-Link protocol engine: * Physical transmission rate configuration (COM1: 4.8k, COM2: 38.4k, COM3: 230.4k baud). * M-Sequence frame encoding & parsing (Type 0, Type 1_1, Type 1_2, Type 2_1, Type 2_2, Type 2_V) with 6-bit CRC. * Direct Parameter Page 1 handling (Vendor ID, Device ID, Min Cycle Time, Revision ID, IO-Link profile). * Acyclic ISDU (Indexed Service Data Unit) parameter read/write transactions. * Non-blocking master polling step and cooperative protothread runner.

Public Types Documentation

IO-Link transmission speed baud rate.

enum SYN_IOLink_Baud {
    SYN_IOLINK_BAUD_COM1 = 0,
    SYN_IOLINK_BAUD_COM2 = 1,
    SYN_IOLINK_BAUD_COM3 = 2
};


Callback for dynamic ISDU parameter read.

typedef SYN_Status(* SYN_IOLink_ISDU_ReadCb) (uint16_t index, uint8_t subindex, uint8_t *out_data, size_t max_len, size_t *out_len, void *user_data);


Callback for dynamic ISDU parameter write.

typedef SYN_Status(* SYN_IOLink_ISDU_WriteCb) (uint16_t index, uint8_t subindex, const uint8_t *data, size_t len, void *user_data);


M-Sequence message type.

enum SYN_IOLink_MSeqType {
    SYN_IOLINK_TYPE_0 = 0,
    SYN_IOLINK_TYPE_1_1 = 1,
    SYN_IOLINK_TYPE_1_2 = 2,
    SYN_IOLINK_TYPE_2_1 = 3,
    SYN_IOLINK_TYPE_2_2 = 4,
    SYN_IOLINK_TYPE_2_V = 5
};


Port operational state.

enum SYN_IOLink_PortState {
    SYN_IOLINK_PORT_INACTIVE = 0,
    SYN_IOLINK_PORT_SIO,
    SYN_IOLINK_PORT_STARTUP,
    SYN_IOLINK_PORT_OPERATE,
    SYN_IOLINK_PORT_FAULT
};


Public Functions Documentation

Calculate standard IO-Link 6-bit CRC with parity.

uint8_t syn_iolink_calc_checksum (
    const uint8_t * data,
    size_t len
) 

Parameters:

  • data Data buffer to calculate checksum over.
  • len Data length in bytes.

Returns:

8-bit Checksum byte (6-bit CRC in bits 0..5, parity in bits 6..7).


Get the device's latest actuator output process data written by master.

SYN_Status syn_iolink_device_get_pd_out (
    const SYN_IOLink_Device * dev,
    uint8_t * out_buf,
    size_t max_len,
    size_t * out_len
) 

Parameters:

  • dev Device instance.
  • out_buf Buffer receiving process data.
  • max_len Capacity of output buffer.
  • out_len Pointer receiving length.

Returns:

SYN_OK on success.


Initialize IO-Link Device.

SYN_Status syn_iolink_device_init (
    SYN_IOLink_Device * dev,
    const SYN_IOLink_DeviceConfig * cfg
) 

Parameters:

  • dev Device instance to initialize.
  • cfg Configuration parameters and parameter page values.

Returns:

SYN_OK on success.


Process an inbound M-Sequence master frame and generate the device response frame.

SYN_Status syn_iolink_device_process_frame (
    SYN_IOLink_Device * dev,
    const uint8_t * rx,
    size_t rx_len,
    uint8_t * tx,
    size_t max_tx,
    size_t * out_len
) 

Parameters:

  • dev Device instance.
  • rx Master frame payload.
  • rx_len Master frame length.
  • tx Buffer receiving device response frame.
  • max_tx Capacity of response buffer.
  • out_len Pointer receiving response length.

Returns:

SYN_OK on success.


Set the device's sensor input process data.

SYN_Status syn_iolink_device_set_pd_in (
    SYN_IOLink_Device * dev,
    const uint8_t * data,
    size_t len
) 

Parameters:

  • dev Device instance.
  • data Input process data payload.
  • len Length of process data.

Returns:

SYN_OK on success.


Perform a cyclic Process Data exchange with connected device.

SYN_Status syn_iolink_master_exchange_pd (
    SYN_IOLink_Master * master,
    const uint8_t * pd_out,
    size_t out_len,
    uint8_t * pd_in,
    size_t * in_len
) 

Parameters:

  • master Master instance.
  • pd_out Output process data to send to device (actuator command).
  • out_len Length of output process data.
  • pd_in Buffer receiving input process data from device (sensor measurement).
  • in_len Pointer receiving length of input process data.

Returns:

SYN_OK on success.


Initialize IO-Link Master.

SYN_Status syn_iolink_master_init (
    SYN_IOLink_Master * master,
    const SYN_IOLink_MasterConfig * cfg
) 

Parameters:

  • master Master instance to initialize.
  • cfg Configuration parameters.

Returns:

SYN_OK on success, SYN_INVALID_PARAM on invalid argument.


Protothread continuation function for syn_sched .

SYN_PT_Status syn_iolink_master_pt (
    SYN_PT * pt,
    SYN_Task * task
) 

Parameters:

  • pt Protothread continuation structure.
  • task Task handle containing SYN_IOLink_Master in user_data.

Returns:

SYN_PT_Status continuation status.


Read an acyclic ISDU parameter from device.

SYN_Status syn_iolink_master_read_isdu (
    SYN_IOLink_Master * master,
    uint16_t index,
    uint8_t subindex,
    uint8_t * data,
    size_t max_len,
    size_t * out_len
) 

Parameters:

  • master Master instance.
  • index 16-bit ISDU Index.
  • subindex 8-bit ISDU Subindex.
  • data Buffer receiving parameter data.
  • max_len Capacity of parameter buffer.
  • out_len Pointer receiving parameter data length.

Returns:

SYN_OK on success.


Trigger master startup handshake sequence on connected port.

SYN_Status syn_iolink_master_start (
    SYN_IOLink_Master * master
) 

Parameters:

  • master Master instance.

Returns:

SYN_OK on success.


Step the IO-Link master state machine and cyclic communication loop.

SYN_Status syn_iolink_master_step (
    SYN_IOLink_Master * master,
    uint32_t now_ms
) 

Parameters:

  • master Master instance.
  • now_ms Current timestamp in milliseconds.

Returns:

SYN_OK on success.


Write an acyclic ISDU parameter to device.

SYN_Status syn_iolink_master_write_isdu (
    SYN_IOLink_Master * master,
    uint16_t index,
    uint8_t subindex,
    const uint8_t * data,
    size_t len
) 

Parameters:

  • master Master instance.
  • index 16-bit ISDU Index.
  • subindex 8-bit ISDU Subindex.
  • data Parameter data to write.
  • len Parameter data length.

Returns:

SYN_OK on success.


Macro Definition Documentation

#define SYN_IOLINK_MAX_ISDU_LEN `64U`

Max ISDU payload length


#define SYN_IOLINK_MAX_PD_LEN `32U`

Max Process Data length in bytes


#define SYN_IOLINK_PAGE_DEVICE_ID_1 `0x08U`

Device ID MSB


#define SYN_IOLINK_PAGE_DEVICE_ID_2 `0x09U`

Device ID Mid


#define SYN_IOLINK_PAGE_DEVICE_ID_3 `0x0AU`

Device ID LSB


#define SYN_IOLINK_PAGE_MASTER_CYCLE_TIME `0x00U`

Master cycle time address


#define SYN_IOLINK_PAGE_MIN_CYCLE_TIME `0x01U`

Min cycle time address


#define SYN_IOLINK_PAGE_MSEQ_CAPABILITY `0x02U`

M-Sequence capability


#define SYN_IOLINK_PAGE_PD_IN_LEN `0x04U`

Process data in length


#define SYN_IOLINK_PAGE_PD_OUT_LEN `0x05U`

Process data out length


#define SYN_IOLINK_PAGE_REVISION_ID `0x03U`

Protocol revision ID (0x11 = v1.1)


#define SYN_IOLINK_PAGE_VENDOR_ID_1 `0x06U`

Vendor ID MSB


#define SYN_IOLINK_PAGE_VENDOR_ID_2 `0x07U`

Vendor ID LSB


#define SYN_IOLINK_REV_1_0 `0x10U`

IO-Link v1.0


#define SYN_IOLINK_REV_1_1 `0x11U`

IO-Link v1.1



The documentation for this class was generated from the following file src/syntropic/proto/syn_iolink.h