# gschorcht/i2c-ch341-usb architecture

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

- Interactive diagram: https://gitdiagram.com/gschorcht/i2c-ch341-usb
- Repository: https://github.com/gschorcht/i2c-ch341-usb

## Overview

This is a single-file Linux kernel driver that turns a CH341A USB adapter into Linux I2C and GPIO interfaces. The principal workflow is device connection, driver initialization, then host I2C/GPIO operations over USB; GPIO input changes can also produce software or configured rising-edge hardware interrupts. The README documents the user-visible capabilities and constraints. Source excerpts confirm I2C adapter setup, USB transfers, GPIO registration, and IRQ handling; omitted source limits verification of some internal call paths.

Main entry points: [`i2c-ch341-usb.c`](https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c) (Device probe)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_usb["USB device"]
  node_probe["Device probe<br/>[i2c-ch341-usb.c]"]
  node_usb_transfer["USB transfer<br/>[i2c-ch341-usb.c]"]
end

subgraph group_i2c["I2C interface"]
  node_i2c_adapter["I2C adapter<br/>[i2c-ch341-usb.c]"]
  node_i2c_transfer["I2C transfer<br/>[i2c-ch341-usb.c]"]
end

subgraph group_gpio["GPIO and IRQ"]
  node_board_config["Board configuration<br/>[i2c-ch341-usb.c]"]
  node_gpio_chip["GPIO chip<br/>[i2c-ch341-usb.c]"]
  node_gpio_poll["Input polling<br/>[i2c-ch341-usb.c]"]
  node_irq_layer["IRQ handling<br/>[i2c-ch341-usb.c]"]
end

node_linux(("Linux host"))
node_adapter["CH341A adapter"]
node_peripherals["I2C devices"]

node_adapter -->|"connects"| node_probe
node_probe -->|"configures"| node_board_config
node_probe -->|"registers"| node_i2c_adapter
node_linux -->|"uses"| node_i2c_adapter
node_i2c_adapter -.->|"dispatches"| node_i2c_transfer
node_i2c_transfer -.->|"transfers"| node_usb_transfer
node_usb_transfer -.->|"exchanges data"| node_adapter
node_i2c_transfer -->|"reads and writes"| node_peripherals
node_probe -->|"registers"| node_gpio_chip
node_linux -->|"uses"| node_gpio_chip
node_gpio_poll -->|"detects changes"| node_irq_layer
node_irq_layer -->|"signals interrupts"| node_linux
node_gpio_chip -.->|"controls pins"| node_adapter

click node_probe "https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c"
click node_usb_transfer "https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c"
click node_board_config "https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c"
click node_i2c_adapter "https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c"
click node_i2c_transfer "https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c"
click node_gpio_chip "https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c"
click node_gpio_poll "https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c"
click node_irq_layer "https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c"

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_probe,node_usb_transfer toneBlue
class node_i2c_adapter,node_i2c_transfer toneAmber
class node_board_config,node_gpio_chip,node_gpio_poll,node_irq_layer toneMint
class node_linux,node_adapter,node_peripherals toneIndigo
```

## Components

### USB device

- [Device probe](https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c): `i2c-ch341-usb.c`
- [USB transfer](https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c): `i2c-ch341-usb.c`

### I2C interface

- [I2C adapter](https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c): `i2c-ch341-usb.c`
- [I2C transfer](https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c): `i2c-ch341-usb.c`

### GPIO and IRQ

- [Board configuration](https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c): `i2c-ch341-usb.c`
- [GPIO chip](https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c): `i2c-ch341-usb.c`
- [Input polling](https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c): `i2c-ch341-usb.c`
- [IRQ handling](https://github.com/gschorcht/i2c-ch341-usb/blob/master/i2c-ch341-usb.c): `i2c-ch341-usb.c`

### Other components

- **Linux host**
- **CH341A adapter**
- **I2C devices**

## Connections

- CH341A adapter → Device probe: connects (evidence: `README.md`)
- Device probe → Board configuration: configures (evidence: `i2c-ch341-usb.c`)
- Device probe → I2C adapter: registers (evidence: `i2c-ch341-usb.c`)
- Linux host → I2C adapter: uses (evidence: `README.md`)
- I2C adapter → I2C transfer: dispatches (evidence: `i2c-ch341-usb.c`)
- I2C transfer → USB transfer: transfers (evidence: `i2c-ch341-usb.c`)
- USB transfer → CH341A adapter: exchanges data
- I2C transfer → I2C devices: reads and writes (evidence: `README.md`)
- Device probe → GPIO chip: registers (evidence: `README.md`)
- Linux host → GPIO chip: uses (evidence: `README.md`)
- Input polling → IRQ handling: detects changes (evidence: `README.md`)
- IRQ handling → Linux host: signals interrupts (evidence: `README.md`)
- GPIO chip → CH341A adapter: controls pins
