# adam97-1/colorsortercpp architecture

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

- Interactive diagram: https://gitdiagram.com/adam97-1/colorsortercpp
- Repository: https://github.com/adam97-1/colorsortercpp

## Overview

This is STM32F446 embedded firmware with motor-control and sensor-oriented application modules. Startup configures hardware, then enters the Run application; the declared application components include task management, IR/color detection, and motor control. The motor abstraction combines encoder feedback and PID regulators, while peripheral interfaces have STM32F446-specific implementations. Source excerpts support startup and several hardware layers, but sensor, task, and application implementation details are unsampled, so their internal runtime links are not asserted.

Main entry points: [`Src/Run.cpp`](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Run.cpp) (Application runner), [`Src/Motor.cpp`](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Motor.cpp) (Motor control), [`Src/main.cpp`](https://github.com/adam97-1/colorsortercpp/blob/master/Src/main.cpp) (Firmware entry), [`Device/ST/STM32F4xx/Include/stm32f446xx.h`](https://github.com/adam97-1/colorsortercpp/blob/master/Device/ST/STM32F4xx/Include/stm32f446xx.h) (STM32F446 definitions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main["Firmware entry<br/>[main.cpp]"]
  node_config["Hardware configuration<br/>[Config.cpp]"]
  node_run["Application runner<br/>[Run.cpp]"]
  node_tasks["Task manager<br/>[TaskMenager.cpp]"]
  node_task["Task base<br/>[Task.cpp]"]
  node_color["Color detector<br/>[ColorDetector.cpp]"]
  node_ir["IR detector<br/>[IrDetector.cpp]"]
end

subgraph group_control["Motion Control"]
  node_motor["Motor control<br/>[Motor.cpp]"]
  node_encoder["Encoder feedback<br/>[Encoder.cpp]"]
  node_pid["PID regulator<br/>[PidRegulator.cpp]"]
end

subgraph group_hal["Peripheral Drivers"]
  node_clock["Clock abstraction<br/>[Clock.cpp]"]
  node_clockf["F446 clock driver<br/>[ClockSTMF446.cpp]"]
  node_gpio["GPIO abstraction<br/>[Gpio.cpp]"]
  node_gpiof["F446 GPIO driver<br/>[GpioF446.cpp]"]
  node_timer["Timer abstraction<br/>[Timer.cpp]"]
  node_timerf["F446 timer driver<br/>[TimerF446.cpp]"]
  node_flash["Flash abstraction<br/>[Flash.cpp]"]
  node_flashf["F446 flash driver<br/>[FlashF446.cpp]"]
  node_systick["System tick<br/>[SysTickClass.cpp]"]
end

subgraph group_platform["MCU Platform"]
  node_device["STM32F446 definitions<br/>[stm32f446xx.h]"]
  node_system["STM32 system setup<br/>[system_stm32f4xx.c]"]
  node_cmsis["CMSIS core support"]
end

node_user(("Firmware startup"))

node_user -->|"starts"| node_main
node_main -->|"configures"| node_config
node_main -->|"executes"| node_run
node_run -->|"uses"| node_tasks
node_run -->|"uses"| node_color
node_run -->|"uses"| node_ir
node_run -->|"uses"| node_motor
node_motor -->|"extends"| node_task
node_motor -->|"uses"| node_encoder
node_motor -->|"uses"| node_pid
node_encoder -->|"extends"| node_task
node_clock -.->|"delegates"| node_clockf
node_gpio -.->|"delegates"| node_gpiof
node_timer -.->|"delegates"| node_timerf
node_clockf -->|"accesses registers"| node_device
node_timerf -->|"accesses registers"| node_device
node_system -->|"uses definitions"| node_device
node_config -->|"references setup"| node_system

click node_main "https://github.com/adam97-1/colorsortercpp/blob/master/Src/main.cpp"
click node_config "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Config/Config.cpp"
click node_run "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Run.cpp"
click node_tasks "https://github.com/adam97-1/colorsortercpp/blob/master/Src/TaskMenager.cpp"
click node_task "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Task.cpp"
click node_color "https://github.com/adam97-1/colorsortercpp/blob/master/Src/ColorDetector.cpp"
click node_ir "https://github.com/adam97-1/colorsortercpp/blob/master/Src/IrDetector.cpp"
click node_motor "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Motor.cpp"
click node_encoder "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Encoder.cpp"
click node_pid "https://github.com/adam97-1/colorsortercpp/blob/master/Src/PidRegulator.cpp"
click node_clock "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Clock/Clock.cpp"
click node_clockf "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Clock/ClockSTMF446.cpp"
click node_gpio "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Gpio/Gpio.cpp"
click node_gpiof "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Gpio/GpioF446.cpp"
click node_timer "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Timer/Timer.cpp"
click node_timerf "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Timer/TimerF446.cpp"
click node_flash "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Flash/Flash.cpp"
click node_flashf "https://github.com/adam97-1/colorsortercpp/blob/master/Src/Flash/FlashF446.cpp"
click node_systick "https://github.com/adam97-1/colorsortercpp/blob/master/Src/SysTickClass.cpp"
click node_device "https://github.com/adam97-1/colorsortercpp/blob/master/Device/ST/STM32F4xx/Include/stm32f446xx.h"
click node_system "https://github.com/adam97-1/colorsortercpp/blob/master/Src/system_stm32f4xx.c"
click node_cmsis "https://github.com/adam97-1/colorsortercpp/tree/master/Core/Include"

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_main,node_config,node_run,node_tasks,node_task,node_color,node_ir toneBlue
class node_motor,node_encoder,node_pid toneAmber
class node_clock,node_clockf,node_gpio,node_gpiof,node_timer,node_timerf,node_flash,node_flashf,node_systick toneMint
class node_device,node_system,node_cmsis toneRose
class node_user toneIndigo
```

## Components

### Application

- [Firmware entry](https://github.com/adam97-1/colorsortercpp/blob/master/Src/main.cpp): `Src/main.cpp`
- [Hardware configuration](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Config/Config.cpp): `Src/Config/Config.cpp`
- [Application runner](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Run.cpp): `Src/Run.cpp`
- [Task manager](https://github.com/adam97-1/colorsortercpp/blob/master/Src/TaskMenager.cpp): `Src/TaskMenager.cpp`
- [Task base](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Task.cpp): `Src/Task.cpp`
- [Color detector](https://github.com/adam97-1/colorsortercpp/blob/master/Src/ColorDetector.cpp): `Src/ColorDetector.cpp`
- [IR detector](https://github.com/adam97-1/colorsortercpp/blob/master/Src/IrDetector.cpp): `Src/IrDetector.cpp`

### Motion Control

- [Motor control](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Motor.cpp): `Src/Motor.cpp`
- [Encoder feedback](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Encoder.cpp): `Src/Encoder.cpp`
- [PID regulator](https://github.com/adam97-1/colorsortercpp/blob/master/Src/PidRegulator.cpp): `Src/PidRegulator.cpp`

### Peripheral Drivers

- [Clock abstraction](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Clock/Clock.cpp): `Src/Clock/Clock.cpp`
- [F446 clock driver](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Clock/ClockSTMF446.cpp): `Src/Clock/ClockSTMF446.cpp`
- [GPIO abstraction](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Gpio/Gpio.cpp): `Src/Gpio/Gpio.cpp`
- [F446 GPIO driver](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Gpio/GpioF446.cpp): `Src/Gpio/GpioF446.cpp`
- [Timer abstraction](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Timer/Timer.cpp): `Src/Timer/Timer.cpp`
- [F446 timer driver](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Timer/TimerF446.cpp): `Src/Timer/TimerF446.cpp`
- [Flash abstraction](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Flash/Flash.cpp): `Src/Flash/Flash.cpp`
- [F446 flash driver](https://github.com/adam97-1/colorsortercpp/blob/master/Src/Flash/FlashF446.cpp): `Src/Flash/FlashF446.cpp`
- [System tick](https://github.com/adam97-1/colorsortercpp/blob/master/Src/SysTickClass.cpp): `Src/SysTickClass.cpp`

### MCU Platform

- [STM32F446 definitions](https://github.com/adam97-1/colorsortercpp/blob/master/Device/ST/STM32F4xx/Include/stm32f446xx.h): `Device/ST/STM32F4xx/Include/stm32f446xx.h`
- [STM32 system setup](https://github.com/adam97-1/colorsortercpp/blob/master/Src/system_stm32f4xx.c): `Src/system_stm32f4xx.c`
- [CMSIS core support](https://github.com/adam97-1/colorsortercpp/tree/master/Core/Include): `Core/Include`

### Other components

- **Firmware startup**

## Connections

- Firmware startup → Firmware entry: starts (evidence: `Src/main.cpp`)
- Firmware entry → Hardware configuration: configures (evidence: `Src/main.cpp`)
- Firmware entry → Application runner: executes (evidence: `Src/main.cpp`)
- Application runner → Task manager: uses
- Application runner → Color detector: uses
- Application runner → IR detector: uses
- Application runner → Motor control: uses
- Motor control → Task base: extends
- Motor control → Encoder feedback: uses
- Motor control → PID regulator: uses
- Encoder feedback → Task base: extends
- Clock abstraction → F446 clock driver: delegates
- GPIO abstraction → F446 GPIO driver: delegates
- Timer abstraction → F446 timer driver: delegates
- F446 clock driver → STM32F446 definitions: accesses registers (evidence: `Src/Clock/ClockSTMF446.cpp`)
- F446 timer driver → STM32F446 definitions: accesses registers (evidence: `Src/Timer/TimerF446.cpp`)
- STM32 system setup → STM32F446 definitions: uses definitions (evidence: `Src/system_stm32f4xx.c`)
- Hardware configuration → STM32 system setup: references setup (evidence: `Src/Config/Config.cpp`)
