# zhoucan01/wireless_power architecture

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

- Interactive diagram: https://gitdiagram.com/zhoucan01/wireless_power
- Repository: https://github.com/zhoucan01/wireless_power

## Overview

This is embedded firmware for a supercapacitor power controller. Startup initializes the STM32 peripherals, then enters the capacitor application, which configures operation and runs its control and status logic; measurements are converted to electrical values, while CAN provides a communications interface and HRTIM/TIM drive power conversion. The source excerpts establish startup calls and some application behavior, but do not expose all control-loop or interrupt call paths, so uncertain relationships are omitted.

Main entry points: [`Core/Src/main.c`](https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/main.c) (Firmware startup), [`MDK-ARM/Super_Cap.c`](https://github.com/zhoucan01/wireless_power/blob/main/MDK-ARM/Super_Cap.c) (Capacitor application), [`MDK-ARM/power_loop.c`](https://github.com/zhoucan01/wireless_power/blob/main/MDK-ARM/power_loop.c) (Power loops), [`bsp_can.c`](https://github.com/zhoucan01/wireless_power/blob/main/bsp_can.c) (CAN protocol)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and peripherals"]
  node_entry["Firmware startup<br/>[main.c]"]
  node_adc_hw["ADC setup<br/>[adc.c]"]
  node_can_hw["CAN setup<br/>[can.c]"]
  node_hrtim_hw["HRTIM setup<br/>[hrtim.c]"]
  node_timer_hw["Timer setup<br/>[tim.c]"]
  node_gpio_dma["GPIO and DMA<br/>[gpio.c]"]
end

subgraph group_application["Capacitor application"]
  node_cap_app["Capacitor application<br/>[Super_Cap.c]"]
  node_measure["ADC conversion<br/>[Adc_calc.c]"]
end

subgraph group_control["Power control"]
  node_power_loop["Power loops<br/>[power_loop.c]"]
  node_pid["PID controller<br/>[bsp_pid.c]"]
end

subgraph group_communications["CAN communications"]
  node_can_bsp["CAN protocol<br/>[bsp_can.c]"]
end

node_operator(("Operator"))
node_can_peer(("CAN peer"))
node_power_stage{{"Power stage"}}

node_operator -.->|"starts"| node_entry
node_entry -->|"initializes"| node_adc_hw
node_entry -->|"initializes"| node_can_hw
node_entry -->|"initializes"| node_hrtim_hw
node_entry -->|"initializes"| node_timer_hw
node_entry -->|"initializes"| node_gpio_dma
node_entry -->|"calls cap_main"| node_cap_app
node_cap_app -->|"initializes CAN"| node_can_bsp
node_cap_app -->|"converts samples"| node_measure
node_cap_app -.->|"uses control"| node_power_loop
node_power_loop -.->|"uses PID"| node_pid
node_cap_app -->|"starts PWM"| node_hrtim_hw
node_cap_app -->|"starts timer"| node_timer_hw
node_can_bsp -.->|"exchanges frames"| node_can_peer
node_power_loop -.->|"controls conversion"| node_power_stage

click node_entry "https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/main.c"
click node_adc_hw "https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/adc.c"
click node_can_hw "https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/can.c"
click node_hrtim_hw "https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/hrtim.c"
click node_timer_hw "https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/tim.c"
click node_gpio_dma "https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/gpio.c"
click node_cap_app "https://github.com/zhoucan01/wireless_power/blob/main/MDK-ARM/Super_Cap.c"
click node_measure "https://github.com/zhoucan01/wireless_power/blob/main/MDK-ARM/Adc_calc.c"
click node_power_loop "https://github.com/zhoucan01/wireless_power/blob/main/MDK-ARM/power_loop.c"
click node_pid "https://github.com/zhoucan01/wireless_power/blob/main/bsp_pid.c"
click node_can_bsp "https://github.com/zhoucan01/wireless_power/blob/main/bsp_can.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_entry,node_adc_hw,node_can_hw,node_hrtim_hw,node_timer_hw,node_gpio_dma toneBlue
class node_cap_app,node_measure toneAmber
class node_power_loop,node_pid toneMint
class node_can_bsp toneRose
class node_operator,node_can_peer,node_power_stage toneIndigo
```

## Components

### Startup and peripherals

- [Firmware startup](https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/main.c): `Core/Src/main.c`
- [ADC setup](https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/adc.c): `Core/Src/adc.c`
- [CAN setup](https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/can.c): `Core/Src/can.c`
- [HRTIM setup](https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/hrtim.c): `Core/Src/hrtim.c`
- [Timer setup](https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/tim.c): `Core/Src/tim.c`
- [GPIO and DMA](https://github.com/zhoucan01/wireless_power/blob/main/Core/Src/gpio.c): `Core/Src/gpio.c`

### Capacitor application

- [Capacitor application](https://github.com/zhoucan01/wireless_power/blob/main/MDK-ARM/Super_Cap.c): `MDK-ARM/Super_Cap.c`
- [ADC conversion](https://github.com/zhoucan01/wireless_power/blob/main/MDK-ARM/Adc_calc.c): `MDK-ARM/Adc_calc.c`

### Power control

- [Power loops](https://github.com/zhoucan01/wireless_power/blob/main/MDK-ARM/power_loop.c): `MDK-ARM/power_loop.c`
- [PID controller](https://github.com/zhoucan01/wireless_power/blob/main/bsp_pid.c): `bsp_pid.c`

### CAN communications

- [CAN protocol](https://github.com/zhoucan01/wireless_power/blob/main/bsp_can.c): `bsp_can.c`

### Other components

- **Operator**
- **CAN peer**
- **Power stage**

## Connections

- Operator → Firmware startup: starts
- Firmware startup → ADC setup: initializes (evidence: `Core/Src/main.c`)
- Firmware startup → CAN setup: initializes (evidence: `Core/Src/main.c`)
- Firmware startup → HRTIM setup: initializes (evidence: `Core/Src/main.c`)
- Firmware startup → Timer setup: initializes (evidence: `Core/Src/main.c`)
- Firmware startup → GPIO and DMA: initializes (evidence: `Core/Src/main.c`)
- Firmware startup → Capacitor application: calls cap_main (evidence: `Core/Src/main.c`)
- Capacitor application → CAN protocol: initializes CAN (evidence: `MDK-ARM/Super_Cap.c`)
- Capacitor application → ADC conversion: converts samples (evidence: `MDK-ARM/Super_Cap.c`)
- Capacitor application → Power loops: uses control
- Power loops → PID controller: uses PID
- Capacitor application → HRTIM setup: starts PWM (evidence: `MDK-ARM/Super_Cap.c`)
- Capacitor application → Timer setup: starts timer (evidence: `MDK-ARM/Super_Cap.c`)
- CAN protocol → CAN peer: exchanges frames
- Power loops → Power stage: controls conversion
