# w1ne/iolinki architecture

> Architecture diagram of the GitHub repository w1ne/iolinki, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/w1ne/iolinki
- Repository: https://github.com/w1ne/iolinki

## Overview

iolinki is an IO-Link V1.1.5 device stack for embedded targets. An application supplies callbacks and binds a PHY; the device stack handles communication state, process data and on-request traffic, including ISDU operations, events and parameter backup/restore. Separate PHY and platform implementations support hardware-specific and portable timing needs. The repository also provides a virtual master for protocol evaluation and IODD generation tools. Edges reflect explicit README claims or shown calls and SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`src/dll.c`](https://github.com/w1ne/iolinki/blob/develop/src/dll.c) (Link state machine), [`src/isdu.c`](https://github.com/w1ne/iolinki/blob/develop/src/isdu.c) (ISDU services), [`src/device.c`](https://github.com/w1ne/iolinki/blob/develop/src/device.c) (Device lifecycle), [`tools/virtual_master/virtual_master/master.py`](https://github.com/w1ne/iolinki/blob/develop/tools/virtual_master/virtual_master/master.py) (Virtual master)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device_stack["Device stack"]
  node_application["Application callbacks<br/>[application.h]"]
  node_device["Device lifecycle<br/>[device.c]"]
  node_dll["Link state machine<br/>[dll.c]"]
end

subgraph group_protocol_features["Protocol features"]
  node_isdu["ISDU services<br/>[isdu.c]"]
  node_params["Parameter management<br/>[params.c]"]
  node_data_storage["Parameter backup<br/>[data_storage.c]"]
  node_events["Event diagnostics<br/>[events.c]"]
  node_device_info["Device identity<br/>[device_info.c]"]
  node_protocol_defs["Protocol definitions<br/>[protocol.h]"]
  node_crc["CRC checks<br/>[crc.c]"]
  node_frame["Frame handling<br/>[frame.c]"]
end

subgraph group_hardware_platform["Hardware and platform"]
  node_phy_api["PHY abstraction<br/>[phy.h]"]
  node_phy_drivers["PHY drivers<br/>[phy_generic.c]"]
  node_uart_phy["Zephyr UART PHY<br/>[phy_uart.c]"]
  node_platform["Platform services<br/>[platform.c]"]
  node_time_utils["Timing utilities<br/>[time_utils.h]"]
end

subgraph group_evaluation["Virtual evaluation"]
  node_master["Virtual master<br/>[master.py]"]
  node_master_protocol["Master framing<br/>[protocol.py]"]
  node_master_uart["Master UART<br/>[uart.py]"]
end

subgraph group_iodd_tools["IODD tools"]
  node_iodd_cli["IODD command line<br/>[iodd_cli.py]"]
  node_iodd_generator["IODD generation<br/>[iodd_gen.py]"]
end

node_application_actor(("Device application"))
node_io_link_master(("IO-Link master"))

node_application_actor -->|"provides callbacks"| node_application
node_device -->|"uses link layer"| node_dll
node_device -->|"uses services"| node_platform
node_device -->|"uses timing"| node_time_utils
node_dll -->|"uses PHY"| node_phy_api
node_phy_drivers -->|"implements interface"| node_phy_api
node_uart_phy -->|"implements interface"| node_phy_api
node_dll -->|"initializes"| node_events
node_dll -->|"initializes"| node_isdu
node_dll -->|"initializes"| node_data_storage
node_dll -->|"dispatches channel"| node_isdu
node_isdu -->|"accesses parameters"| node_params
node_isdu -->|"uses diagnostics"| node_events
node_isdu -->|"uses backup"| node_data_storage
node_data_storage -->|"reads and writes"| node_params
node_isdu -->|"reads identity"| node_device_info
node_dll -->|"uses constants"| node_protocol_defs
node_isdu -->|"uses constants"| node_protocol_defs
node_master -->|"generates frames"| node_master_protocol
node_master -->|"sends and receives"| node_master_uart
node_io_link_master -.->|"simulated by"| node_master
node_iodd_cli -->|"invokes generator"| node_iodd_generator
node_application_actor -.->|"requests IODD"| node_iodd_cli

click node_application "https://github.com/w1ne/iolinki/blob/develop/include/iolinki/application.h"
click node_device "https://github.com/w1ne/iolinki/blob/develop/src/device.c"
click node_dll "https://github.com/w1ne/iolinki/blob/develop/src/dll.c"
click node_phy_api "https://github.com/w1ne/iolinki/blob/develop/include/iolinki/phy.h"
click node_phy_drivers "https://github.com/w1ne/iolinki/blob/develop/src/phy_generic.c"
click node_uart_phy "https://github.com/w1ne/iolinki/blob/develop/src/platform/zephyr/phy_uart.c"
click node_platform "https://github.com/w1ne/iolinki/blob/develop/src/platform.c"
click node_time_utils "https://github.com/w1ne/iolinki/blob/develop/include/iolinki/time_utils.h"
click node_isdu "https://github.com/w1ne/iolinki/blob/develop/src/isdu.c"
click node_params "https://github.com/w1ne/iolinki/blob/develop/src/params.c"
click node_data_storage "https://github.com/w1ne/iolinki/blob/develop/src/data_storage.c"
click node_events "https://github.com/w1ne/iolinki/blob/develop/src/events.c"
click node_device_info "https://github.com/w1ne/iolinki/blob/develop/src/device_info.c"
click node_protocol_defs "https://github.com/w1ne/iolinki/blob/develop/include/iolinki/protocol.h"
click node_crc "https://github.com/w1ne/iolinki/blob/develop/src/crc.c"
click node_frame "https://github.com/w1ne/iolinki/blob/develop/src/frame.c"
click node_master "https://github.com/w1ne/iolinki/blob/develop/tools/virtual_master/virtual_master/master.py"
click node_master_protocol "https://github.com/w1ne/iolinki/blob/develop/tools/virtual_master/virtual_master/protocol.py"
click node_master_uart "https://github.com/w1ne/iolinki/blob/develop/tools/virtual_master/virtual_master/uart.py"
click node_iodd_cli "https://github.com/w1ne/iolinki/blob/develop/tools/iodd_cli.py"
click node_iodd_generator "https://github.com/w1ne/iolinki/blob/develop/tools/iodd_gen.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_application,node_device,node_dll toneBlue
class node_isdu,node_params,node_data_storage,node_events,node_device_info,node_protocol_defs,node_crc,node_frame toneAmber
class node_phy_api,node_phy_drivers,node_uart_phy,node_platform,node_time_utils toneMint
class node_master,node_master_protocol,node_master_uart toneRose
class node_iodd_cli,node_iodd_generator,node_application_actor,node_io_link_master toneIndigo
```

## Components

### Device stack

- [Application callbacks](https://github.com/w1ne/iolinki/blob/develop/include/iolinki/application.h): `include/iolinki/application.h`
- [Device lifecycle](https://github.com/w1ne/iolinki/blob/develop/src/device.c): `src/device.c`
- [Link state machine](https://github.com/w1ne/iolinki/blob/develop/src/dll.c): `src/dll.c`

### Protocol features

- [ISDU services](https://github.com/w1ne/iolinki/blob/develop/src/isdu.c): `src/isdu.c`
- [Parameter management](https://github.com/w1ne/iolinki/blob/develop/src/params.c): `src/params.c`
- [Parameter backup](https://github.com/w1ne/iolinki/blob/develop/src/data_storage.c): `src/data_storage.c`
- [Event diagnostics](https://github.com/w1ne/iolinki/blob/develop/src/events.c): `src/events.c`
- [Device identity](https://github.com/w1ne/iolinki/blob/develop/src/device_info.c): `src/device_info.c`
- [Protocol definitions](https://github.com/w1ne/iolinki/blob/develop/include/iolinki/protocol.h): `include/iolinki/protocol.h`
- [CRC checks](https://github.com/w1ne/iolinki/blob/develop/src/crc.c): `src/crc.c`
- [Frame handling](https://github.com/w1ne/iolinki/blob/develop/src/frame.c): `src/frame.c`

### Hardware and platform

- [PHY abstraction](https://github.com/w1ne/iolinki/blob/develop/include/iolinki/phy.h): `include/iolinki/phy.h`
- [PHY drivers](https://github.com/w1ne/iolinki/blob/develop/src/phy_generic.c): `src/phy_generic.c`
- [Zephyr UART PHY](https://github.com/w1ne/iolinki/blob/develop/src/platform/zephyr/phy_uart.c): `src/platform/zephyr/phy_uart.c`
- [Platform services](https://github.com/w1ne/iolinki/blob/develop/src/platform.c): `src/platform.c`
- [Timing utilities](https://github.com/w1ne/iolinki/blob/develop/include/iolinki/time_utils.h): `include/iolinki/time_utils.h`

### Virtual evaluation

- [Virtual master](https://github.com/w1ne/iolinki/blob/develop/tools/virtual_master/virtual_master/master.py): `tools/virtual_master/virtual_master/master.py`
- [Master framing](https://github.com/w1ne/iolinki/blob/develop/tools/virtual_master/virtual_master/protocol.py): `tools/virtual_master/virtual_master/protocol.py`
- [Master UART](https://github.com/w1ne/iolinki/blob/develop/tools/virtual_master/virtual_master/uart.py): `tools/virtual_master/virtual_master/uart.py`

### IODD tools

- [IODD command line](https://github.com/w1ne/iolinki/blob/develop/tools/iodd_cli.py): `tools/iodd_cli.py`
- [IODD generation](https://github.com/w1ne/iolinki/blob/develop/tools/iodd_gen.py): `tools/iodd_gen.py`

### Other components

- **Device application**
- **IO-Link master**

## Connections

- Device application → Application callbacks: provides callbacks (evidence: `include/iolinki/application.h`)
- Device lifecycle → Link state machine: uses link layer
- Device lifecycle → Platform services: uses services (evidence: `src/device.c`)
- Device lifecycle → Timing utilities: uses timing (evidence: `src/device.c`)
- Link state machine → PHY abstraction: uses PHY
- PHY drivers → PHY abstraction: implements interface (evidence: `include/iolinki/phy.h`)
- Zephyr UART PHY → PHY abstraction: implements interface
- Link state machine → Event diagnostics: initializes (evidence: `src/dll.c`)
- Link state machine → ISDU services: initializes (evidence: `src/dll.c`)
- Link state machine → Parameter backup: initializes (evidence: `src/dll.c`)
- Link state machine → ISDU services: dispatches channel (evidence: `src/dll.c`)
- ISDU services → Parameter management: accesses parameters (evidence: `src/isdu.c`)
- ISDU services → Event diagnostics: uses diagnostics (evidence: `src/isdu.c`)
- ISDU services → Parameter backup: uses backup (evidence: `src/isdu.c`)
- Parameter backup → Parameter management: reads and writes (evidence: `src/data_storage.c`)
- ISDU services → Device identity: reads identity (evidence: `src/isdu.c`)
- Link state machine → Protocol definitions: uses constants (evidence: `src/dll.c`)
- ISDU services → Protocol definitions: uses constants (evidence: `src/isdu.c`)
- Virtual master → Master framing: generates frames (evidence: `tools/virtual_master/virtual_master/master.py`)
- Virtual master → Master UART: sends and receives (evidence: `tools/virtual_master/virtual_master/master.py`)
- IO-Link master → Virtual master: simulated by (evidence: `README.md`)
- IODD command line → IODD generation: invokes generator (evidence: `tools/iodd_cli.py`)
- Device application → IODD command line: requests IODD (evidence: `README.md`)
