# souvik-dev31/automotive-ecu-simulator_freertos architecture

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

- Interactive diagram: https://gitdiagram.com/souvik-dev31/automotive-ecu-simulator_freertos
- Repository: https://github.com/souvik-dev31/automotive-ecu-simulator_freertos

## Overview

This repository is an automotive ECU simulator with two implementations: a FreeRTOS Windows host simulation and an STM32F446 target. In both, simulated engine telemetry is queued for fuel-injection calculation and CAN-frame serialization, then consumed by an actuator task; a watchdog checks task liveness. The target sends and receives through the physical CAN peripheral and reports over UART. The target’s HAL, interrupt, clock, and runtime-support files are included as supporting layers. Relationships for runtime features not visible in excerpts are based on the README; unsampled details are not inferred.

Main entry points: [`STM32 Target/main.c`](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c) (Target startup), [`Host Simulator/main_blinky.c`](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c) (Host startup), [`STM32 Target/stm32f4xx_hal_timebase_tim.c`](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/stm32f4xx_hal_timebase_tim.c) (HAL timebase), [`STM32 Target/stm32f4xx_it.c`](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/stm32f4xx_it.c) (Interrupt handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host Simulator"]
  node_host_boot["Host startup<br/>[main_blinky.c]"]
  node_host_sensor["Sensor task<br/>[main_blinky.c]"]
  node_host_core["ECU processing<br/>[main_blinky.c]"]
  node_host_actuator["CAN actuator<br/>[main_blinky.c]"]
  node_host_watchdog["Watchdog<br/>[main_blinky.c]"]
end

subgraph group_ecu["ECU Runtime"]
  node_target_boot["Target startup<br/>[main.c]"]
  node_target_sensor["Sensor task<br/>[main.c]"]
  node_target_core["ECU processing<br/>[main.c]"]
  node_target_actuator["CAN actuator<br/>[main.c]"]
  node_target_watchdog["Watchdog<br/>[main.c]"]
end

subgraph group_platform["STM32 Platform"]
  node_hal_msp["Peripheral setup"]
  node_hal_tick["HAL timebase"]
  node_interrupts["Interrupt handlers<br/>[stm32f4xx_it.c]"]
  node_clock["System clock<br/>[system_stm32f4xx.c]"]
  node_rtos_support["RTOS support<br/>[freertos.c]"]
  node_syscalls["Newlib syscalls<br/>[syscalls.c]"]
  node_heap["Heap allocator<br/>[sysmem.c]"]
end

node_can_bus(("CAN bus"))
node_terminal(("UART terminal"))

node_host_boot -->|"starts"| node_host_sensor
node_host_boot -->|"starts"| node_host_core
node_host_boot -->|"starts"| node_host_actuator
node_host_boot -->|"starts"| node_host_watchdog
node_host_sensor -->|"queues telemetry"| node_host_core
node_host_core -->|"queues CAN frame"| node_host_actuator
node_host_sensor -->|"sets alive bit"| node_host_watchdog
node_host_core -->|"sets alive bit"| node_host_watchdog
node_host_actuator -->|"sets alive bit"| node_host_watchdog
node_target_boot -->|"starts"| node_target_sensor
node_target_boot -->|"starts"| node_target_core
node_target_boot -->|"starts"| node_target_actuator
node_target_boot -->|"starts"| node_target_watchdog
node_target_sensor -->|"queues telemetry"| node_target_core
node_target_core -->|"transmits frame"| node_can_bus
node_can_bus -.->|"provides frame"| node_target_actuator
node_target_sensor -->|"sets alive bit"| node_target_watchdog
node_target_core -->|"sets alive bit"| node_target_watchdog
node_target_actuator -->|"sets alive bit"| node_target_watchdog
node_target_watchdog -->|"resets MCU"| node_target_boot
node_target_boot -->|"prints over UART"| node_terminal
node_target_boot -.->|"configures peripherals"| node_hal_msp
node_target_boot -.->|"uses HAL tick"| node_hal_tick
node_interrupts -->|"handles timer IRQ"| node_hal_tick
node_target_boot -.->|"configures clock"| node_clock
node_target_boot -.->|"uses RTOS support"| node_rtos_support

click node_host_boot "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c"
click node_host_sensor "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c"
click node_host_core "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c"
click node_host_actuator "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c"
click node_host_watchdog "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c"
click node_target_boot "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c"
click node_target_sensor "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c"
click node_target_core "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c"
click node_target_actuator "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c"
click node_target_watchdog "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c"
click node_hal_msp "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/stm32f4xx_hal_msp.c"
click node_hal_tick "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/stm32f4xx_hal_timebase_tim.c"
click node_interrupts "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/stm32f4xx_it.c"
click node_clock "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/system_stm32f4xx.c"
click node_rtos_support "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/freertos.c"
click node_syscalls "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/syscalls.c"
click node_heap "https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/sysmem.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_host_boot,node_host_sensor,node_host_core,node_host_actuator,node_host_watchdog toneBlue
class node_target_boot,node_target_sensor,node_target_core,node_target_actuator,node_target_watchdog toneAmber
class node_hal_msp,node_hal_tick,node_interrupts,node_clock,node_rtos_support,node_syscalls,node_heap toneMint
class node_can_bus,node_terminal toneIndigo
```

## Components

### Host Simulator

- [Host startup](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c): `Host Simulator/main_blinky.c`
- [Sensor task](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c): `Host Simulator/main_blinky.c`
- [ECU processing](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c): `Host Simulator/main_blinky.c`
- [CAN actuator](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c): `Host Simulator/main_blinky.c`
- [Watchdog](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/Host%20Simulator/main_blinky.c): `Host Simulator/main_blinky.c`

### ECU Runtime

- [Target startup](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c): `STM32 Target/main.c`
- [Sensor task](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c): `STM32 Target/main.c`
- [ECU processing](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c): `STM32 Target/main.c`
- [CAN actuator](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c): `STM32 Target/main.c`
- [Watchdog](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/main.c): `STM32 Target/main.c`

### STM32 Platform

- [Peripheral setup](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/stm32f4xx_hal_msp.c): `STM32 Target/stm32f4xx_hal_msp.c`
- [HAL timebase](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/stm32f4xx_hal_timebase_tim.c): `STM32 Target/stm32f4xx_hal_timebase_tim.c`
- [Interrupt handlers](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/stm32f4xx_it.c): `STM32 Target/stm32f4xx_it.c`
- [System clock](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/system_stm32f4xx.c): `STM32 Target/system_stm32f4xx.c`
- [RTOS support](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/freertos.c): `STM32 Target/freertos.c`
- [Newlib syscalls](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/syscalls.c): `STM32 Target/syscalls.c`
- [Heap allocator](https://github.com/souvik-dev31/automotive-ecu-simulator_freertos/blob/main/STM32%20Target/sysmem.c): `STM32 Target/sysmem.c`

### Other components

- **CAN bus**
- **UART terminal**

## Connections

- Host startup → Sensor task: starts (evidence: `Host Simulator/main_blinky.c`)
- Host startup → ECU processing: starts (evidence: `Host Simulator/main_blinky.c`)
- Host startup → CAN actuator: starts (evidence: `Host Simulator/main_blinky.c`)
- Host startup → Watchdog: starts (evidence: `Host Simulator/main_blinky.c`)
- Sensor task → ECU processing: queues telemetry (evidence: `Host Simulator/main_blinky.c`)
- ECU processing → CAN actuator: queues CAN frame (evidence: `Host Simulator/main_blinky.c`)
- Sensor task → Watchdog: sets alive bit (evidence: `Host Simulator/main_blinky.c`)
- ECU processing → Watchdog: sets alive bit (evidence: `Host Simulator/main_blinky.c`)
- CAN actuator → Watchdog: sets alive bit (evidence: `Host Simulator/main_blinky.c`)
- Target startup → Sensor task: starts (evidence: `STM32 Target/main.c`)
- Target startup → ECU processing: starts (evidence: `STM32 Target/main.c`)
- Target startup → CAN actuator: starts (evidence: `STM32 Target/main.c`)
- Target startup → Watchdog: starts (evidence: `STM32 Target/main.c`)
- Sensor task → ECU processing: queues telemetry (evidence: `STM32 Target/main.c`)
- ECU processing → CAN bus: transmits frame (evidence: `STM32 Target/main.c`)
- CAN bus → CAN actuator: provides frame (evidence: `README.md`)
- Sensor task → Watchdog: sets alive bit (evidence: `README.md`)
- ECU processing → Watchdog: sets alive bit (evidence: `README.md`)
- CAN actuator → Watchdog: sets alive bit (evidence: `README.md`)
- Watchdog → Target startup: resets MCU (evidence: `STM32 Target/main.c`)
- Target startup → UART terminal: prints over UART (evidence: `STM32 Target/main.c`)
- Target startup → Peripheral setup: configures peripherals
- Target startup → HAL timebase: uses HAL tick
- Interrupt handlers → HAL timebase: handles timer IRQ (evidence: `STM32 Target/stm32f4xx_it.c`)
- Target startup → System clock: configures clock
- Target startup → RTOS support: uses RTOS support
