# vamoirid/battery-management-system-stm32-software architecture

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

- Interactive diagram: https://gitdiagram.com/vamoirid/battery-management-system-stm32-software
- Repository: https://github.com/vamoirid/battery-management-system-stm32-software

## Overview

This repository contains STM32 master firmware for two battery-monitoring designs: one using LTC6811 and one using LTC6803, as documented in the README. The principal workflow is firmware initialization, communicating with the monitor ICs over SPI, and processing measurements and BMS state. The excerpts show the LTC6811 application’s temperature conversion and over-temperature checks, and the LTC6803 application’s configuration and conversion loop. Driver internals and some application logic are only partially sampled, so uncertain links are omitted.

Main entry points: [`BMS_Code/Src/main.c`](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/main.c) (LTC6811 firmware), [`BMS_Code/Src/LT_SPI.c`](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/LT_SPI.c) (SPI transport), [`BMS_Code/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h`](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h) (STM32 HAL), [`BMS_LTC6803/Src/main.c`](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_LTC6803/Src/main.c) (LTC6803 firmware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["BMS applications"]
  node_app6811["LTC6811 firmware<br/>[main.c]"]
  node_app6803["LTC6803 firmware<br/>[main.c]"]
  node_measurements["Measurement and state logic<br/>[main.c]"]
end

subgraph group_monitor["Monitor IC drivers"]
  node_driver6811["LTC681x protocol<br/>[LTC681x.c]"]
  node_api6811["LTC6811 interface<br/>[LTC6811.h]"]
  node_driver6803["LTC6803 protocol<br/>[LTC6803.c]"]
end

subgraph group_hardware["STM32 hardware access"]
  node_spi["SPI transport<br/>[LT_SPI.c]"]
  node_hal["STM32 HAL<br/>[stm32f4xx_hal.h]"]
  node_halconfig["HAL configuration"]
end

node_operator(("Battery system"))
node_stm32{{"STM32F446RE"}}
node_ltc6811{{"LTC6811 monitor"}}
node_ltc6803{{"LTC6803 monitor"}}

node_operator -->|"runs firmware"| node_app6811
node_operator -->|"runs firmware"| node_app6803
node_app6811 -->|"uses protocol"| node_driver6811
node_app6811 -->|"uses interface"| node_api6811
node_app6811 -->|"uses SPI"| node_spi
node_app6811 -->|"processes readings"| node_measurements
node_driver6811 -->|"implements API"| node_api6811
node_app6803 -->|"calls driver"| node_driver6803
node_app6803 -->|"uses SPI"| node_spi
node_driver6803 -->|"uses transport"| node_spi
node_app6811 -->|"initializes peripherals"| node_hal
node_app6803 -->|"initializes MCU"| node_hal
node_spi -.->|"uses HAL"| node_hal
node_halconfig -->|"configures"| node_hal
node_hal -.->|"controls peripherals"| node_stm32
node_spi -.->|"communicates"| node_ltc6811
node_spi -.->|"communicates"| node_ltc6803

click node_app6811 "https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/main.c"
click node_app6803 "https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_LTC6803/Src/main.c"
click node_measurements "https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/main.c"
click node_driver6811 "https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/LTC681x.c"
click node_api6811 "https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Inc/LTC6811.h"
click node_driver6803 "https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_LTC6803/LTC6803_src/LTC6803.c"
click node_spi "https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/LT_SPI.c"
click node_hal "https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h"
click node_halconfig "https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Inc/stm32f4xx_hal_conf.h"

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_app6811,node_app6803,node_measurements toneBlue
class node_driver6811,node_api6811,node_driver6803 toneAmber
class node_spi,node_hal,node_halconfig toneMint
class node_operator,node_stm32,node_ltc6811,node_ltc6803 toneIndigo
```

## Components

### BMS applications

- [LTC6811 firmware](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/main.c): `BMS_Code/Src/main.c`
- [LTC6803 firmware](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_LTC6803/Src/main.c): `BMS_LTC6803/Src/main.c`
- [Measurement and state logic](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/main.c): `BMS_Code/Src/main.c`

### Monitor IC drivers

- [LTC681x protocol](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/LTC681x.c): `BMS_Code/Src/LTC681x.c`
- [LTC6811 interface](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Inc/LTC6811.h): `BMS_Code/Inc/LTC6811.h`
- [LTC6803 protocol](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_LTC6803/LTC6803_src/LTC6803.c): `BMS_LTC6803/LTC6803_src/LTC6803.c`

### STM32 hardware access

- [SPI transport](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Src/LT_SPI.c): `BMS_Code/Src/LT_SPI.c`
- [STM32 HAL](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h): `BMS_Code/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h`
- [HAL configuration](https://github.com/vamoirid/battery-management-system-stm32-software/blob/master/BMS_Code/Inc/stm32f4xx_hal_conf.h): `BMS_Code/Inc/stm32f4xx_hal_conf.h`

### Other components

- **Battery system**
- **STM32F446RE**
- **LTC6811 monitor**
- **LTC6803 monitor**

## Connections

- Battery system → LTC6811 firmware: runs firmware
- Battery system → LTC6803 firmware: runs firmware
- LTC6811 firmware → LTC681x protocol: uses protocol (evidence: `BMS_Code/Src/main.c`)
- LTC6811 firmware → LTC6811 interface: uses interface (evidence: `BMS_Code/Src/main.c`)
- LTC6811 firmware → SPI transport: uses SPI (evidence: `BMS_Code/Src/main.c`)
- LTC6811 firmware → Measurement and state logic: processes readings (evidence: `BMS_Code/Src/main.c`)
- LTC681x protocol → LTC6811 interface: implements API (evidence: `BMS_Code/Src/LTC681x.c`)
- LTC6803 firmware → LTC6803 protocol: calls driver (evidence: `BMS_LTC6803/Src/main.c`)
- LTC6803 firmware → SPI transport: uses SPI (evidence: `BMS_LTC6803/Src/main.c`)
- LTC6803 protocol → SPI transport: uses transport (evidence: `BMS_LTC6803/LTC6803_src/LTC6803.c`)
- LTC6811 firmware → STM32 HAL: initializes peripherals (evidence: `BMS_Code/Src/main.c`)
- LTC6803 firmware → STM32 HAL: initializes MCU (evidence: `BMS_LTC6803/Src/main.c`)
- SPI transport → STM32 HAL: uses HAL
- HAL configuration → STM32 HAL: configures (evidence: `BMS_Code/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h`)
- STM32 HAL → STM32F446RE: controls peripherals
- SPI transport → LTC6811 monitor: communicates
- SPI transport → LTC6803 monitor: communicates
