# opiopan/simhid-g1000 architecture

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

- Interactive diagram: https://gitdiagram.com/opiopan/simhid-g1000
- Repository: https://github.com/opiopan/simhid-g1000

## Overview

SimHID G1000 is firmware for a physical flight-simulator control panel: its switches and encoders are scanned, represented as named controls, and exposed to a PC over USB virtual serial using SimHID protocol; fsmapper interprets that protocol and manages PFD/MFD switching. The sampled startup calls `runApp`, while source-index references show the application’s scanner and protocol modules. The USB CDC-to-application wiring is not shown in the excerpts, so that relationship is marked unverified rather than asserted as a confirmed call.

Main entry points: [`firmware/src/scanner.c`](https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/scanner.c) (Input scanner), [`firmware/src/appmain.h`](https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/appmain.h) (Application entry), [`firmware/src/hostprotocol.c`](https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/hostprotocol.c) (SimHID protocol), [`firmware/USB_DEVICE/App/usbd_cdc_if.c`](https://github.com/opiopan/simhid-g1000/blob/main/firmware/USB_DEVICE/App/usbd_cdc_if.c) (CDC application interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Firmware startup"]
  node_firmware_main["Board startup<br/>[main.c]"]
  node_board_pins["Pin definitions<br/>[main.h]"]
  node_app_entry["Application entry<br/>[appmain.h]"]
end

subgraph group_controls["Physical controls"]
  node_input_scanner["Input scanner<br/>[scanner.c]"]
  node_switch_state["Switch state<br/>[switch.c]"]
  node_switch_groups["Switch groups<br/>[switchgroup.c]"]
end

subgraph group_protocol["Host protocol"]
  node_command_parser["Command executor<br/>[command.c]"]
  node_host_protocol["SimHID protocol<br/>[hostprotocol.c]"]
end

subgraph group_usb["USB transport"]
  node_usb_app["CDC application interface<br/>[usbd_cdc_if.c]"]
  node_usb_cdc["USB CDC class<br/>[usbd_cdc.c]"]
  node_usb_core["USB device core<br/>[usbd_core.h]"]
  node_usb_board["USB board support<br/>[usbd_conf.c]"]
end

node_panel_user(("Panel operator"))
node_pc_host(("Windows host"))
node_fsmapper["fsmapper"]

node_panel_user -.->|"operates controls"| node_input_scanner
node_firmware_main -->|"starts runApp"| node_app_entry
node_app_entry -->|"includes scanner API"| node_input_scanner
node_app_entry -->|"includes protocol API"| node_host_protocol
node_input_scanner -->|"uses switch state"| node_switch_state
node_input_scanner -->|"uses switch groups"| node_switch_groups
node_command_parser -->|"queries scanner"| node_input_scanner
node_pc_host -->|"serial connection"| node_usb_app
node_usb_app -.->|"passes protocol data"| node_host_protocol
node_usb_cdc -->|"uses device core"| node_usb_core
node_usb_board -->|"dispatches USB events"| node_usb_core
node_pc_host -->|"runs host software"| node_fsmapper
node_fsmapper -->|"interprets protocol"| node_host_protocol

click node_firmware_main "https://github.com/opiopan/simhid-g1000/blob/main/firmware/Core/Src/main.c"
click node_board_pins "https://github.com/opiopan/simhid-g1000/blob/main/firmware/Core/Inc/main.h"
click node_app_entry "https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/appmain.h"
click node_input_scanner "https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/scanner.c"
click node_switch_state "https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/switch.c"
click node_switch_groups "https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/switchgroup.c"
click node_command_parser "https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/command.c"
click node_host_protocol "https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/hostprotocol.c"
click node_usb_app "https://github.com/opiopan/simhid-g1000/blob/main/firmware/USB_DEVICE/App/usbd_cdc_if.c"
click node_usb_cdc "https://github.com/opiopan/simhid-g1000/blob/main/firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c"
click node_usb_core "https://github.com/opiopan/simhid-g1000/blob/main/firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h"
click node_usb_board "https://github.com/opiopan/simhid-g1000/blob/main/firmware/USB_DEVICE/Target/usbd_conf.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_firmware_main,node_board_pins,node_app_entry toneBlue
class node_input_scanner,node_switch_state,node_switch_groups toneAmber
class node_command_parser,node_host_protocol toneMint
class node_usb_app,node_usb_cdc,node_usb_core,node_usb_board toneRose
class node_panel_user,node_pc_host,node_fsmapper toneIndigo
```

## Components

### Firmware startup

- [Board startup](https://github.com/opiopan/simhid-g1000/blob/main/firmware/Core/Src/main.c): `firmware/Core/Src/main.c`
- [Pin definitions](https://github.com/opiopan/simhid-g1000/blob/main/firmware/Core/Inc/main.h): `firmware/Core/Inc/main.h`
- [Application entry](https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/appmain.h): `firmware/src/appmain.h`

### Physical controls

- [Input scanner](https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/scanner.c): `firmware/src/scanner.c`
- [Switch state](https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/switch.c): `firmware/src/switch.c`
- [Switch groups](https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/switchgroup.c): `firmware/src/switchgroup.c`

### Host protocol

- [Command executor](https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/command.c): `firmware/src/command.c`
- [SimHID protocol](https://github.com/opiopan/simhid-g1000/blob/main/firmware/src/hostprotocol.c): `firmware/src/hostprotocol.c`

### USB transport

- [CDC application interface](https://github.com/opiopan/simhid-g1000/blob/main/firmware/USB_DEVICE/App/usbd_cdc_if.c): `firmware/USB_DEVICE/App/usbd_cdc_if.c`
- [USB CDC class](https://github.com/opiopan/simhid-g1000/blob/main/firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c): `firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c`
- [USB device core](https://github.com/opiopan/simhid-g1000/blob/main/firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h): `firmware/Middlewares/ST/STM32_USB_Device_Library/Core/Inc/usbd_core.h`
- [USB board support](https://github.com/opiopan/simhid-g1000/blob/main/firmware/USB_DEVICE/Target/usbd_conf.c): `firmware/USB_DEVICE/Target/usbd_conf.c`

### Other components

- **Panel operator**
- **Windows host**
- **fsmapper**

## Connections

- Panel operator → Input scanner: operates controls
- Board startup → Application entry: starts runApp (evidence: `firmware/Core/Src/main.c`)
- Application entry → Input scanner: includes scanner API (evidence: `firmware/src/appmain.h`)
- Application entry → SimHID protocol: includes protocol API (evidence: `firmware/src/appmain.h`)
- Input scanner → Switch state: uses switch state (evidence: `firmware/src/scanner.c`)
- Input scanner → Switch groups: uses switch groups (evidence: `firmware/src/scanner.c`)
- Command executor → Input scanner: queries scanner (evidence: `firmware/src/command.c`)
- Windows host → CDC application interface: serial connection
- CDC application interface → SimHID protocol: passes protocol data
- USB CDC class → USB device core: uses device core (evidence: `firmware/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c`)
- USB board support → USB device core: dispatches USB events (evidence: `firmware/USB_DEVICE/Target/usbd_conf.c`)
- Windows host → fsmapper: runs host software
- fsmapper → SimHID protocol: interprets protocol
