# ubaldot/defrecs architecture

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

- Interactive diagram: https://gitdiagram.com/ubaldot/defrecs
- Repository: https://github.com/ubaldot/defrecs

## Overview

DEFRECS is a C framework and example set for real-time embedded control, organized around portable application components and platform-specific adapters. The clearest sampled workflow is the ADC_Readings firmware startup: board initialization calls application_setup(), then FreeRTOS starts and interrupt-triggered deferred tasks process events through the USART2 adapter. The README also documents publish/subscribe application components and platform portability. Source excerpts do not show the application component implementation or its data wiring, so those relationships are documented but not expanded into speculative component-level flows.

Main entry points: [`stm32f4x/ADC_Readings/Core/Src/main.c`](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/main.c) (ADC firmware entry), [`stm32f4x/ADC_Readings/application`](https://github.com/ubaldot/defrecs/tree/main/stm32f4x/ADC_Readings/application) (Control components), [`stm32f4x/Hello_World/Core/Src/main.c`](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/Hello_World/Core/Src/main.c) (Hello firmware entry), [`stm32f4x/ADC_Readings/application/application_setup.c`](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/application/application_setup.c) (Application setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Firmware startup"]
  node_adc_main["ADC firmware entry<br/>[main.c]"]
  node_rtos_tasks["FreeRTOS tasks<br/>[freertos.c]"]
  node_hello_entry["Hello firmware entry<br/>[main.c]"]
end

subgraph group_app["Application layer"]
  node_adc_setup["Application setup"]
  node_components["Control components"]
  node_float_format["Float conversion<br/>[ftoa.c]"]
  node_printf_util["Formatted output<br/>[printf-stdarg.c]"]
  node_hello_setup["Hello application setup"]
end

subgraph group_platform["Platform and events"]
  node_irq_bridge["Deferred event tasks"]
  node_serial_adapter["USART2 adapter<br/>[usart2.h]"]
  node_irq_handlers["Interrupt handlers<br/>[stm32f4xx_it.c]"]
  node_hello_bridge["Hello deferred tasks"]
end

subgraph group_drivers["Board services"]
  node_adc_driver["ADC peripheral<br/>[adc.c]"]
  node_dma_driver["DMA service<br/>[dma.c]"]
  node_uart_driver["USART service<br/>[usart.c]"]
  node_gpio_driver["GPIO service<br/>[gpio.c]"]
  node_cmsis_pid["CMSIS PID functions"]
  node_cmsis_pid_api["PID API and transforms"]
end

node_board_user(("Board user"))

node_board_user -->|"starts firmware"| node_adc_main
node_adc_main -->|"initializes GPIO"| node_gpio_driver
node_adc_main -->|"initializes DMA"| node_dma_driver
node_adc_main -->|"initializes UART"| node_uart_driver
node_adc_main -->|"initializes ADC"| node_adc_driver
node_adc_main -->|"calls setup"| node_adc_setup
node_adc_main -->|"starts scheduler"| node_rtos_tasks
node_irq_bridge -->|"dispatches event"| node_serial_adapter
node_irq_handlers -.->|"notifies tasks"| node_irq_bridge
node_adc_setup -.->|"configures"| node_components
node_components -.->|"may use"| node_cmsis_pid
node_cmsis_pid -.->|"implements"| node_cmsis_pid_api
node_board_user -->|"starts firmware"| node_hello_entry
node_hello_entry -->|"calls setup"| node_hello_setup
node_hello_entry -.->|"starts scheduler"| node_hello_bridge
node_hello_bridge -.->|"uses adapter"| node_serial_adapter
node_components -.->|"may use"| node_float_format
node_components -.->|"may use"| node_printf_util

click node_adc_main "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/main.c"
click node_adc_setup "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/application/application_setup.c"
click node_components "https://github.com/ubaldot/defrecs/tree/main/stm32f4x/ADC_Readings/application"
click node_adc_driver "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/adc.c"
click node_dma_driver "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/dma.c"
click node_uart_driver "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/usart.c"
click node_rtos_tasks "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/freertos.c"
click node_irq_bridge "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/platform/interrupts_to_tasks.c"
click node_serial_adapter "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/platform/usart2/usart2.h"
click node_irq_handlers "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/stm32f4xx_it.c"
click node_gpio_driver "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/gpio.c"
click node_float_format "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/utils/ftoa.c"
click node_printf_util "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/utils/printf-stdarg.c"
click node_hello_entry "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/Hello_World/Core/Src/main.c"
click node_hello_setup "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/Hello_World/application/application_setup.c"
click node_hello_bridge "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/Hello_World/platform/interrupts_to_tasks.c"
click node_cmsis_pid "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Drivers/CMSIS/DSP/Source/ControllerFunctions/ControllerFunctions.c"
click node_cmsis_pid_api "https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Drivers/CMSIS/DSP/Include/dsp/controller_functions.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_adc_main,node_rtos_tasks,node_hello_entry,node_board_user toneBlue
class node_adc_setup,node_components,node_float_format,node_printf_util,node_hello_setup toneAmber
class node_irq_bridge,node_serial_adapter,node_irq_handlers,node_hello_bridge toneMint
class node_adc_driver,node_dma_driver,node_uart_driver,node_gpio_driver,node_cmsis_pid,node_cmsis_pid_api toneRose
```

## Components

### Firmware startup

- [ADC firmware entry](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/main.c): `stm32f4x/ADC_Readings/Core/Src/main.c`
- [FreeRTOS tasks](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/freertos.c): `stm32f4x/ADC_Readings/Core/Src/freertos.c`
- [Hello firmware entry](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/Hello_World/Core/Src/main.c): `stm32f4x/Hello_World/Core/Src/main.c`

### Application layer

- [Application setup](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/application/application_setup.c): `stm32f4x/ADC_Readings/application/application_setup.c`
- [Control components](https://github.com/ubaldot/defrecs/tree/main/stm32f4x/ADC_Readings/application): `stm32f4x/ADC_Readings/application`
- [Float conversion](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/utils/ftoa.c): `stm32f4x/ADC_Readings/utils/ftoa.c`
- [Formatted output](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/utils/printf-stdarg.c): `stm32f4x/ADC_Readings/utils/printf-stdarg.c`
- [Hello application setup](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/Hello_World/application/application_setup.c): `stm32f4x/Hello_World/application/application_setup.c`

### Platform and events

- [Deferred event tasks](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/platform/interrupts_to_tasks.c): `stm32f4x/ADC_Readings/platform/interrupts_to_tasks.c`
- [USART2 adapter](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/platform/usart2/usart2.h): `stm32f4x/ADC_Readings/platform/usart2/usart2.h`
- [Interrupt handlers](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/stm32f4xx_it.c): `stm32f4x/ADC_Readings/Core/Src/stm32f4xx_it.c`
- [Hello deferred tasks](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/Hello_World/platform/interrupts_to_tasks.c): `stm32f4x/Hello_World/platform/interrupts_to_tasks.c`

### Board services

- [ADC peripheral](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/adc.c): `stm32f4x/ADC_Readings/Core/Src/adc.c`
- [DMA service](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/dma.c): `stm32f4x/ADC_Readings/Core/Src/dma.c`
- [USART service](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/usart.c): `stm32f4x/ADC_Readings/Core/Src/usart.c`
- [GPIO service](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Core/Src/gpio.c): `stm32f4x/ADC_Readings/Core/Src/gpio.c`
- [CMSIS PID functions](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Drivers/CMSIS/DSP/Source/ControllerFunctions/ControllerFunctions.c): `stm32f4x/ADC_Readings/Drivers/CMSIS/DSP/Source/ControllerFunctions/ControllerFunctions.c`
- [PID API and transforms](https://github.com/ubaldot/defrecs/blob/main/stm32f4x/ADC_Readings/Drivers/CMSIS/DSP/Include/dsp/controller_functions.h): `stm32f4x/ADC_Readings/Drivers/CMSIS/DSP/Include/dsp/controller_functions.h`

### Other components

- **Board user**

## Connections

- Board user → ADC firmware entry: starts firmware (evidence: `stm32f4x/ADC_Readings/Core/Src/main.c`)
- ADC firmware entry → GPIO service: initializes GPIO (evidence: `stm32f4x/ADC_Readings/Core/Src/main.c`)
- ADC firmware entry → DMA service: initializes DMA (evidence: `stm32f4x/ADC_Readings/Core/Src/main.c`)
- ADC firmware entry → USART service: initializes UART (evidence: `stm32f4x/ADC_Readings/Core/Src/main.c`)
- ADC firmware entry → ADC peripheral: initializes ADC (evidence: `stm32f4x/ADC_Readings/Core/Src/main.c`)
- ADC firmware entry → Application setup: calls setup (evidence: `stm32f4x/ADC_Readings/Core/Src/main.c`)
- ADC firmware entry → FreeRTOS tasks: starts scheduler (evidence: `stm32f4x/ADC_Readings/Core/Src/main.c`)
- Deferred event tasks → USART2 adapter: dispatches event (evidence: `stm32f4x/ADC_Readings/platform/interrupts_to_tasks.c`)
- Interrupt handlers → Deferred event tasks: notifies tasks
- Application setup → Control components: configures
- Control components → CMSIS PID functions: may use
- CMSIS PID functions → PID API and transforms: implements
- Board user → Hello firmware entry: starts firmware (evidence: `stm32f4x/Hello_World/Core/Src/main.c`)
- Hello firmware entry → Hello application setup: calls setup (evidence: `stm32f4x/Hello_World/Core/Src/main.c`)
- Hello firmware entry → Hello deferred tasks: starts scheduler
- Hello deferred tasks → USART2 adapter: uses adapter
- Control components → Float conversion: may use
- Control components → Formatted output: may use
