# tudsat-rocket/io_board_firmware architecture

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

- Interactive diagram: https://gitdiagram.com/tudsat-rocket/io_board_firmware
- Repository: https://github.com/tudsat-rocket/io_board_firmware

## Overview

This repository is firmware for configurable CAN-connected I/O nodes, with valve, heating, sensor, and safety behavior. The principal workflow is a CAN master changing or commanding node state; firmware stores that intent, samples sensors and rail values, computes safe output targets, drives hardware, and reports state over CAN. The graph includes the documented configuration, protocol, sensing, and control domains. Evidence is limited to the supplied excerpts and SOURCE INDEX; links without direct relationship evidence are omitted.

Main entry points: [`src/control.rs`](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/control.rs) (Control task), [`src/store.rs`](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/store.rs) (Shared state), [`src/sensors/mod.rs`](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/sensors/mod.rs) (Sensor sampling), [`src/can/mod.rs`](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/can/mod.rs) (CAN transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["CAN protocol"]
  node_can["CAN transport<br/>[mod.rs]"]
  node_sdo["SDO server<br/>[sdo.rs]"]
  node_tpdo["TPDO publisher<br/>[tpdo.rs]"]
  node_dictionary["Object dictionary<br/>[od.rs]"]
  node_wirevalve["Valve wire format<br/>[valve.rs]"]
end

subgraph group_configuration["Configuration state"]
  node_store[("Shared state<br/>[store.rs]")]
  node_config["Runtime config<br/>[mod.rs]"]
  node_persist["Config persistence<br/>[persist.rs]"]
  node_defaults["Node defaults<br/>[mod.rs]"]
end

subgraph group_sensing["Sensing"]
  node_sensors["Sensor sampling<br/>[mod.rs]"]
  node_extadc["External ADC<br/>[ext_adc.rs]"]
  node_rail["Rail sensing<br/>[rail_sense.rs]"]
end

subgraph group_control["Control"]
  node_control["Control task<br/>[control.rs]"]
  node_valves["Valve control<br/>[valves.rs]"]
  node_heating["Heating control<br/>[heating.rs]"]
  node_relief["Pressure relief<br/>[relief.rs]"]
  node_safety["Safety logic<br/>[safety.rs]"]
  node_cpu["CPU monitoring<br/>[cpu.rs]"]
  node_errors["Error counters<br/>[errors.rs]"]
end

subgraph group_hardware["Board hardware"]
  node_hco["High-current outputs<br/>[hco.rs]"]
  node_outputs["Output drivers<br/>[outputs.rs]"]
  node_board["Board support<br/>[mod.rs]"]
end

node_master(("CAN master"))

node_master -->|"sends frames"| node_can
node_can -->|"fans out"| node_sdo
node_can -->|"transports frames"| node_tpdo
node_sdo -->|"parks requests"| node_store
node_tpdo -->|"reads state"| node_store
node_sdo -->|"serves objects"| node_dictionary
node_dictionary -->|"defines encoding"| node_wirevalve
node_control -->|"reads intent"| node_store
node_control -->|"writes observations"| node_store
node_control -->|"applies relief"| node_relief
node_control -->|"reads rails"| node_rail
node_sensors -->|"uses calibration"| node_config
node_sensors -->|"publishes readings"| node_store
node_sensors -->|"samples devices"| node_extadc
node_config -->|"loads and saves"| node_persist
node_config -->|"falls back to"| node_defaults
node_control -->|"drives outputs"| node_hco
node_hco -->|"uses drivers"| node_outputs
node_board -->|"initializes"| node_hco
node_board -->|"provides I2C"| node_sensors
node_control -.->|"coordinates heating"| node_heating
node_control -.->|"coordinates valves"| node_valves
node_control -.->|"checks safety"| node_safety
node_control -.->|"records faults"| node_errors
node_control -.->|"publishes utilization"| node_cpu

click node_can "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/can/mod.rs"
click node_sdo "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/can/sdo.rs"
click node_tpdo "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/can/tpdo.rs"
click node_dictionary "https://github.com/tudsat-rocket/io_board_firmware/blob/main/iocan-proto/src/od.rs"
click node_wirevalve "https://github.com/tudsat-rocket/io_board_firmware/blob/main/iocan-proto/src/valve.rs"
click node_store "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/store.rs"
click node_config "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/config/mod.rs"
click node_persist "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/config/persist.rs"
click node_defaults "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/zenith_mapping/mod.rs"
click node_sensors "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/sensors/mod.rs"
click node_extadc "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/sensors/ext_adc.rs"
click node_rail "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/rail_sense.rs"
click node_control "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/control.rs"
click node_valves "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/valves.rs"
click node_heating "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/heating.rs"
click node_relief "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/relief.rs"
click node_safety "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/safety.rs"
click node_hco "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/hco.rs"
click node_outputs "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/outputs.rs"
click node_board "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/board/mod.rs"
click node_cpu "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/cpu.rs"
click node_errors "https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/errors.rs"

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_can,node_sdo,node_tpdo,node_dictionary,node_wirevalve toneBlue
class node_store,node_config,node_persist,node_defaults toneAmber
class node_sensors,node_extadc,node_rail toneMint
class node_control,node_valves,node_heating,node_relief,node_safety,node_cpu,node_errors toneRose
class node_hco,node_outputs,node_board,node_master toneIndigo
```

## Components

### CAN protocol

- [CAN transport](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/can/mod.rs): `src/can/mod.rs`
- [SDO server](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/can/sdo.rs): `src/can/sdo.rs`
- [TPDO publisher](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/can/tpdo.rs): `src/can/tpdo.rs`
- [Object dictionary](https://github.com/tudsat-rocket/io_board_firmware/blob/main/iocan-proto/src/od.rs): `iocan-proto/src/od.rs`
- [Valve wire format](https://github.com/tudsat-rocket/io_board_firmware/blob/main/iocan-proto/src/valve.rs): `iocan-proto/src/valve.rs`

### Configuration state

- [Shared state](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/store.rs): `src/store.rs`
- [Runtime config](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/config/mod.rs): `src/config/mod.rs`
- [Config persistence](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/config/persist.rs): `src/config/persist.rs`
- [Node defaults](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/zenith_mapping/mod.rs): `src/zenith_mapping/mod.rs`

### Sensing

- [Sensor sampling](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/sensors/mod.rs): `src/sensors/mod.rs`
- [External ADC](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/sensors/ext_adc.rs): `src/sensors/ext_adc.rs`
- [Rail sensing](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/rail_sense.rs): `src/rail_sense.rs`

### Control

- [Control task](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/control.rs): `src/control.rs`
- [Valve control](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/valves.rs): `src/valves.rs`
- [Heating control](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/heating.rs): `src/heating.rs`
- [Pressure relief](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/relief.rs): `src/relief.rs`
- [Safety logic](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/safety.rs): `src/safety.rs`
- [CPU monitoring](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/cpu.rs): `src/cpu.rs`
- [Error counters](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/errors.rs): `src/errors.rs`

### Board hardware

- [High-current outputs](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/hco.rs): `src/hco.rs`
- [Output drivers](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/outputs.rs): `src/outputs.rs`
- [Board support](https://github.com/tudsat-rocket/io_board_firmware/blob/main/src/board/mod.rs): `src/board/mod.rs`

### Other components

- **CAN master**

## Connections

- CAN master → CAN transport: sends frames (evidence: `src/can/mod.rs`)
- CAN transport → SDO server: fans out (evidence: `src/can/mod.rs`)
- CAN transport → TPDO publisher: transports frames (evidence: `src/can/mod.rs`)
- SDO server → Shared state: parks requests (evidence: `src/store.rs`)
- TPDO publisher → Shared state: reads state (evidence: `src/can/tpdo.rs`)
- SDO server → Object dictionary: serves objects (evidence: `iocan-proto/src/od.rs`)
- Object dictionary → Valve wire format: defines encoding (evidence: `iocan-proto/src/od.rs`)
- Control task → Shared state: reads intent (evidence: `src/control.rs`)
- Control task → Shared state: writes observations (evidence: `src/control.rs`)
- Control task → Pressure relief: applies relief (evidence: `src/relief.rs`)
- Control task → Rail sensing: reads rails (evidence: `src/control.rs`)
- Sensor sampling → Runtime config: uses calibration (evidence: `src/sensors/mod.rs`)
- Sensor sampling → Shared state: publishes readings (evidence: `src/sensors/mod.rs`)
- Sensor sampling → External ADC: samples devices (evidence: `src/sensors/mod.rs`)
- Runtime config → Config persistence: loads and saves (evidence: `src/config/mod.rs`)
- Runtime config → Node defaults: falls back to (evidence: `src/zenith_mapping/mod.rs`)
- Control task → High-current outputs: drives outputs (evidence: `src/hco.rs`)
- High-current outputs → Output drivers: uses drivers (evidence: `src/hco.rs`)
- Board support → High-current outputs: initializes (evidence: `src/board/mod.rs`)
- Board support → Sensor sampling: provides I2C (evidence: `src/board/mod.rs`)
- Control task → Heating control: coordinates heating (evidence: `src/control.rs`)
- Control task → Valve control: coordinates valves (evidence: `src/control.rs`)
- Control task → Safety logic: checks safety (evidence: `src/control.rs`)
- Control task → Error counters: records faults (evidence: `src/control.rs`)
- Control task → CPU monitoring: publishes utilization (evidence: `src/control.rs`)
