# oshe-github/ups architecture

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

- Interactive diagram: https://gitdiagram.com/oshe-github/ups
- Repository: https://github.com/oshe-github/ups

## Overview

This repository is an early STM32L1 firmware scaffold for a Raspberry Pi UPS hat, not a finished UPS controller. The visible workflow is MCU startup and peripheral configuration; the README does not describe battery monitoring, power-fail handling, or host communication, and the sampled application excerpt does not establish those behaviors. The map therefore focuses on the firmware entry point and its platform layers. Several platform components are represented by their existing source directories because their implementation files were not sampled; links are limited to relationships shown in the excerpts or source index.

Main entry points: [`STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Inc`](https://github.com/oshe-github/ups/tree/main/STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Inc) (HAL interfaces), [`STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h`](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h) (STM32L1 device), [`STM32CubeIDE/Core/Inc/main.h`](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Inc/main.h) (App definitions), [`STM32CubeIDE/Core/Src/main.c`](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/main.c) (Firmware entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application"]
  node_firmware["Firmware entry<br/>[main.c]"]
  node_app_header["App definitions<br/>[main.h]"]
end

subgraph group_platform["STM32 Platform"]
  node_hal_config["HAL configuration"]
  node_interrupts["Interrupt handlers<br/>[stm32l1xx_it.c]"]
  node_msp["Peripheral setup"]
  node_hal["HAL drivers"]
  node_hal_headers["HAL interfaces"]
  node_device["STM32L1 device<br/>[stm32l1xx.h]"]
  node_device_variant["L152 definitions<br/>[stm32l152xc.h]"]
  node_cmsis_core["CMSIS core support"]
  node_system_init["System initialization<br/>[system_stm32l1xx.c]"]
end

subgraph group_runtime["Runtime Support"]
  node_syscalls["C syscall stubs<br/>[syscalls.c]"]
  node_sysmem["Heap support<br/>[sysmem.c]"]
end

node_firmware -->|"includes"| node_app_header
node_firmware -->|"initializes peripherals"| node_hal
node_app_header -->|"includes HAL"| node_hal_headers
node_hal_config -->|"configures modules"| node_hal_headers
node_interrupts -->|"includes"| node_app_header
node_msp -->|"includes"| node_app_header
node_hal -->|"implements APIs"| node_hal_headers
node_hal_headers -->|"uses device layer"| node_device
node_device -->|"selects definitions"| node_device_variant
node_device -->|"included by HAL"| node_hal_headers
node_system_init -->|"uses device definitions"| node_device

click node_firmware "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/main.c"
click node_app_header "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Inc/main.h"
click node_hal_config "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Inc/stm32l1xx_hal_conf.h"
click node_interrupts "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/stm32l1xx_it.c"
click node_msp "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/stm32l1xx_hal_msp.c"
click node_hal "https://github.com/oshe-github/ups/tree/main/STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Src"
click node_hal_headers "https://github.com/oshe-github/ups/tree/main/STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Inc"
click node_device "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h"
click node_device_variant "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l152xc.h"
click node_cmsis_core "https://github.com/oshe-github/ups/tree/main/STM32CubeIDE/Drivers/CMSIS/Include"
click node_system_init "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/system_stm32l1xx.c"
click node_syscalls "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/syscalls.c"
click node_sysmem "https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/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_firmware,node_app_header toneBlue
class node_hal_config,node_interrupts,node_msp,node_hal,node_hal_headers,node_device,node_device_variant,node_cmsis_core,node_system_init toneAmber
class node_syscalls,node_sysmem toneMint
```

## Components

### Application

- [Firmware entry](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/main.c): `STM32CubeIDE/Core/Src/main.c`
- [App definitions](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Inc/main.h): `STM32CubeIDE/Core/Inc/main.h`

### STM32 Platform

- [HAL configuration](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Inc/stm32l1xx_hal_conf.h): `STM32CubeIDE/Core/Inc/stm32l1xx_hal_conf.h`
- [Interrupt handlers](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/stm32l1xx_it.c): `STM32CubeIDE/Core/Src/stm32l1xx_it.c`
- [Peripheral setup](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/stm32l1xx_hal_msp.c): `STM32CubeIDE/Core/Src/stm32l1xx_hal_msp.c`
- [HAL drivers](https://github.com/oshe-github/ups/tree/main/STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Src): `STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Src`
- [HAL interfaces](https://github.com/oshe-github/ups/tree/main/STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Inc): `STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Inc`
- [STM32L1 device](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h): `STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h`
- [L152 definitions](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l152xc.h): `STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l152xc.h`
- [CMSIS core support](https://github.com/oshe-github/ups/tree/main/STM32CubeIDE/Drivers/CMSIS/Include): `STM32CubeIDE/Drivers/CMSIS/Include`
- [System initialization](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/system_stm32l1xx.c): `STM32CubeIDE/Core/Src/system_stm32l1xx.c`

### Runtime Support

- [C syscall stubs](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/syscalls.c): `STM32CubeIDE/Core/Src/syscalls.c`
- [Heap support](https://github.com/oshe-github/ups/blob/main/STM32CubeIDE/Core/Src/sysmem.c): `STM32CubeIDE/Core/Src/sysmem.c`

## Connections

- Firmware entry → App definitions: includes (evidence: `STM32CubeIDE/Core/Src/main.c`)
- Firmware entry → HAL drivers: initializes peripherals (evidence: `STM32CubeIDE/Core/Src/main.c`)
- App definitions → HAL interfaces: includes HAL (evidence: `STM32CubeIDE/Core/Inc/main.h`)
- HAL configuration → HAL interfaces: configures modules (evidence: `STM32CubeIDE/Core/Inc/stm32l1xx_hal_conf.h`)
- Interrupt handlers → App definitions: includes (evidence: `STM32CubeIDE/Core/Src/stm32l1xx_it.c`)
- Peripheral setup → App definitions: includes (evidence: `STM32CubeIDE/Core/Src/stm32l1xx_hal_msp.c`)
- HAL drivers → HAL interfaces: implements APIs (evidence: `STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_i2c.c`)
- HAL interfaces → STM32L1 device: uses device layer (evidence: `STM32CubeIDE/Drivers/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_def.h`)
- STM32L1 device → L152 definitions: selects definitions (evidence: `STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h`)
- STM32L1 device → HAL interfaces: included by HAL (evidence: `STM32CubeIDE/Drivers/CMSIS/Device/ST/STM32L1xx/Include/stm32l1xx.h`)
- System initialization → STM32L1 device: uses device definitions (evidence: `STM32CubeIDE/Core/Src/system_stm32l1xx.c`)
