# hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft architecture

> Architecture diagram of the GitHub repository hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft
- Repository: https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft

## Overview

##### Project Type and Purpose
- This is a bare‑metal embedded firmware project targeting an STM32F103RB microcontroller (Cortex‑M3).
- The goal is to sample an analog signal, run a 128‑point FFT via the ARM CMSIS‑DSP library, and render the frequency spectrum in real time on an ALIENTEK MINISTM32 TFT.

##### File‑Structure Analysis
- Top‑level directories:
- CORE: CMSIS core startup and vector table (core_cm3.c/h, startup .s).
- HARDWARE: Board‑specific drivers (ADC, LCD, LED) plus the ST Standard Peripheral Library (STM32F10x_StdPeriph_Driver).
- STM32F10x_FWLib: Duplicate or reference of ST’s firmware library (inc and src).
- SYSTEM: Lightweight HAL for delay, system tick, USART (sys, delay, usart).
- USER: Application code—main(), FFT examples, startup, system config, interrupt handlers, project files (.uvprojx), debug configs, and build artifacts under OBJ.
- README points out use of CMSIS‑DSP v1.4.4 and the goal of displaying 128‑point FFT on the TFT.

##### Architectural Components
a. Microcontroller & Core
- Cortex‑M3 core (vector table, NVIC)
- System clock & SysTick (SYSTEM/sys)
b. Peripheral Abstraction Layers
- CMSIS core header (CORE/)
- ST StdPeriph drivers (HARDWARE/STM32F10x_StdPeriph_Driver)
- Simplified SYSTEM drivers (delay, usart)
c. Board‑Level Drivers
- ADC driver (HARDWARE/ADC)
- LCD driver and font (HARDWARE/LCD)
- LED driver for status indication (HARDWARE/LED)
d. DSP Processing
- CMSIS‑DSP library (ARM DSP routines linked into USER/arm_fft_*.c)
- FFT pipeline: sample acquisition → buffer → FFT transform → magnitude calculation
e. Application Layer
- main.c: initialization sequence, perpetual loop or timer/interrupt driven task
- Data flow: ADC ISR or DMA → FFT routine → render via LCD driver
- Optional USART output for debugging (SYSTEM/usart)
f. External Interfaces
- ALIENTEK TFT (parallel/SPI bus)
- Analog input (sensor) into ADC
- JTAG/SWD for debugging (USER/JLinkSettings.ini)

##### Relationships and Interactions
- ADC hardware → ADC driver → sample buffer
- Sample buffer → CMSIS‑DSP FFT function → frequency data
- Frequency data → LCD driver → TFT display
- SysTick → delay/SYSTEM services → timing control
- USART → debug console (optional)
- LED driver → status LED (heartbeat or error indicator)
- Interrupt or DMA paths if used (e.g., ADC conversion complete ISR triggering FFT).

##### Architectural Patterns & Principles
- Layered HAL approach:
- CMSIS core → StdPeriph or custom SYSTEM HAL → board drivers → application
- Modular separation:
- Hardware drivers in HARDWARE/…
- DSP algorithms in USER/arm_fft_*
- System utilities (delay, usart) in SYSTEM/…
- Single‑threaded, callback or interrupt‑driven design (no RTOS).

##### Technologies & Frameworks
- ARM CMSIS (CORE directory)
- ST Standard Peripheral Library (HARDWARE and STM32F10x_FWLib)
- CMSIS‑DSP v1.4.4 (USER/arm_fft_bin_example_f32.c, .h)
- Keil MDK‑ARM project files (.uvprojx, .uvoptx)

##### Essential Elements to Capture
- MCU core & vector table
- Clock and SysTick subsystem
- ADC acquisition path
- DSP processing block (CMSIS‑DSP)
- Output path (LCD driver → TFT)
- Support services (delay, usart, LED)
- External hardware interfaces (TFT, analog sensor, debug port)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% MCU Software Layer
    subgraph "MCU Software" 
        direction TB
        CortexM3Core["Cortex‑M3 Core\n(vector table, NVIC)"]:::core
        SysTick["System Clock & SysTick"]:::core
        DelayUtil["Delay Utility"]:::hal
        USARTUtil["USART Utility"]:::hal
    end

    %% Hardware Abstraction Layer
    subgraph "HAL & Drivers"
        direction TB
        StdPeriph["ST StdPeriph Drivers"]:::hal
        subgraph "Board Drivers"
            direction TB
            ADCDrv["ADC Driver"]:::driver
            LCDDrv["LCD Driver & Font"]:::driver
            LEDDrv["LED Driver"]:::driver
        end
    end

    %% DSP Processing Layer
    subgraph "DSP Processing" 
        direction TB
        SampleBuf["ADC Sample Buffer"]:::buffer
        FFTCore["CMSIS‑DSP FFT Routines"]:::dsp
        FFTBuf["FFT Output Buffer"]:::buffer
    end

    %% Application Layer
    subgraph "Application"
        direction TB
        MainApp["main.c\n(init & main loop)"]:::app
        IRQHandlers["Interrupt Handlers\n(stm32f10x_it.c)"]:::app
    end

    %% External Interfaces
    subgraph "External Hardware"
        direction TB
        Sensor["Analog Sensor"]:::external
        TFT["ALIENTEK TFT Display"]:::external
        Debugger["JTAG/SWD Debugger"]:::external
        LEDExt["Status LEDs"]:::external
    end

    %% Data & Control Flows
    Sensor -->|analog input| ADCDrv
    ADCDrv -->|samples| SampleBuf
    SampleBuf -->|buffer| FFTCore
    ADCDrv -->|ADC_EOC IRQ| IRQHandlers
    IRQHandlers -->|calls FFT| FFTCore
    FFTCore -->|frequency data| FFTBuf
    FFTBuf -->|render| LCDDrv
    SysTick -- . . .control--> DelayUtil
    SysTick -- . . .control--> USARTUtil
    USARTUtil -->|debug output| Debugger
    LEDDrv -->|toggle heartbeat| LEDExt
    MainApp -->|uses| SysTick
    MainApp -->|uses| DelayUtil
    MainApp -->|uses| USARTUtil
    MainApp -->|initializes| ADCDrv
    MainApp -->|initializes| LCDDrv
    MainApp -->|initializes| LEDDrv

    %% Click Events
    click CortexM3Core "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/CORE/core_cm3.c"
    click SysTick "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/SYSTEM/sys/sys.c"
    click DelayUtil "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/SYSTEM/delay/delay.c"
    click USARTUtil "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/SYSTEM/usart/usart.c"
    click StdPeriph "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/tree/master/HARDWARE/STM32F10x_StdPeriph_Driver/inc"
    click ADCDrv "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/HARDWARE/ADC/adc.c"
    click LCDDrv "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/HARDWARE/LCD/lcd.c"
    click LEDDrv "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/HARDWARE/LED/led.c"
    click FFTCore "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/USER/arm_fft_bin_example_f32.c"
    click MainApp "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/USER/main.c"
    click IRQHandlers "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/USER/stm32f10x_it.c"
    click Debugger "https://github.com/hxy513696765/stm32f103rb_cmsis-dsp_tft_ddisplay_128_fft/blob/master/USER/JLinkSettings.ini"

    %% Styles
    classDef core fill:#cce5ff,stroke:#3399ff
    classDef hal fill:#d4edda,stroke:#28a745
    classDef driver fill:#d4edda,stroke:#28a745
    classDef dsp fill:#ffe5b4,stroke:#ff9933
    classDef buffer fill:#f5f5f5,stroke:#999999,stroke-dasharray: 5 2
    classDef app fill:#fff3cd,stroke:#ffc107
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-dasharray: 2 2
```
