# thiennguyen15/s32k144f architecture

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

- Interactive diagram: https://gitdiagram.com/thiennguyen15/s32k144f
- Repository: https://github.com/thiennguyen15/s32k144f

## Overview

##### Project type and purpose
- This is a hybrid embedded‐firmware and desktop helper tool project for the NXP S32K144F512M15 microcontroller.
- The firmware portion (C code under Header/ and Source/) provides drivers, configuration, and application examples (GPIO, LPUART, LPIT timer, SPI, SysTick, MAX7219).
- The “Register Header” subproject and the Python UI (under “UI – Python”) generate MCU register header files from CSV templates.

##### File structure
- Top level
- Header/                 ← Hand-written driver/header templates (MAX7219, ST registers, peripheral configs)
- Register Header/       ← Code‐generator source and CSV template for automatically emitting register headers
- Source/                ← Firmware examples & library code for GPIO, LPUART, timers, SPI, main.c, config.c
- UI – Python/           ← Python GUI (Tkinter) and assets for user to drive register header generation
- Mock Project.c, README.md
- Key patterns
- Separation between code‐generation toolchain (Python + C generator) and firmware code
- Modular driver layers per peripheral (GPIO, LPUART, LPIT, LPSPI)
- Build inputs: CSV + Template.txt → Generate_Register.c → output .h files → included by firmware

##### README
- Shows screenshots: “Generating-Register-Header-File” and “Initial User Interface (UI)”.
- Confirms the dual purpose: user interacts with a desktop GUI to generate updated MCU register headers, then rebuilds/flashes firmware.

##### Key points to capture
- The feedback loop: editing CSV or template in UI regenerates headers → drivers adapt automatically
- The modular driver architecture on the MCU side
- The overall flow from user input to hardware action

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Desktop Toolchain
    subgraph "Desktop Toolchain"
        direction TB
        UI["Python UI"]:::desktop
        Assets["UI Assets"]:::desktop
        CSV["Register_S32K144.csv"]:::data
        Template["Template.txt"]:::data
        GenCode["Generate_Register.c"]:::codegen
    end

    %% Generated Headers
    subgraph "Generated Register Headers"
        direction TB
        GPIOH["GPIO_Register.h"]:::generated
        LPITH["LPIT_Register.h"]:::generated
        LPSPIH["LPSPI_Register.h"]:::generated
        LPUARTH["LPUART_Register.h"]:::generated
        PCCH["PCC_Register.h"]:::generated
        PORTH["PORT_Register.h"]:::generated
        SCGH["SCG_Register.h"]:::generated
        SMCH["SMC_Register.h"]:::generated
        STH["ST_Register.h"]:::generated
    end

    %% Firmware Build
    Build["Firmware Build System"]:::tool

    %% Firmware Source
    subgraph "MCU Firmware"
        direction TB
        HWHeaders["Hand-written Headers"]:::firmware
        MainC["main.c"]:::firmware
        subgraph "Config Modules"
            direction TB
            ClockCfg["clock_config.c"]:::firmware
            LPITCfg["lpit_config.c"]:::firmware
            LPSPICfg["lpspi_config.c"]:::firmware
            LPUARTCfg["lpuart_config.c"]:::firmware
            TimerSvc["software_timer.c"]:::firmware
        end
        subgraph "Driver Examples"
            direction TB
            GPIOEx["GPIO Examples"]:::firmware
            LPUARTEx["LPUART Examples"]:::firmware
            MAX7219Ex["MAX7219 Example"]:::firmware
            SysTickEx["SysTick Timer Example"]:::firmware
            LPITEx["LPIT Interrupt Example"]:::firmware
        end
    end

    %% MCU & Peripherals
    Binary["Flashed MCU Binary"]:::firmware
    subgraph "Hardware Peripherals"
        direction TB
        GPIOHW["GPIO Pins"]:::hardware
        UARTHW["LPUART"]:::hardware
        SPIHW["SPI Peripheral"]:::hardware
        TimerHW["Timers"]:::hardware
        MAXHW["MAX7219 LED Driver"]:::hardware
    end

    %% Connections
    UI -->|selects CSV & Template| CSV
    UI -->|selects CSV & Template| Template
    UI -->|uses assets| Assets
    CSV --> GenCode
    Template --> GenCode
    GenCode -->|generates| GPIOH & LPITH & LPSPIH & LPUARTH & PCCH & PORTH & SCGH & SMCH & STH
    GPIOH & LPITH & LPSPIH & LPUARTH & PCCH & PORTH & SCGH & SMCH & STH --> Build
    Build -->|compiles| HWHeaders & MainC & ClockCfg & LPITCfg & LPSPICfg & LPUARTCfg & TimerSvc & GPIOEx & LPUARTEx & MAX7219Ex & SysTickEx & LPITEx
    HWHeaders & MainC & ClockCfg & LPITCfg & LPSPICfg & LPUARTCfg & TimerSvc & GPIOEx & LPUARTEx & MAX7219Ex & SysTickEx & LPITEx --> Binary
    Binary -->|runs on| GPIOHW & UARTHW & SPIHW & TimerHW & MAXHW

    %% Click Events
    click UI "https://github.com/thiennguyen15/s32k144f/blob/main/UI - Python/GUI.py"
    click Assets "https://github.com/thiennguyen15/s32k144f/tree/main/UI - Python/assets/"
    click GenCode "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/Generate Code/Generate_Register.c"
    click CSV "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/Generate Code/Register_S32K144.csv"
    click Template "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/Generate Code/Template.txt"
    click GPIOH "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/GPIO_Register.h"
    click LPITH "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/LPIT_Register.h"
    click LPSPIH "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/LPSPI_Register.h"
    click LPUARTH "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/LPUART_Register.h"
    click PCCH "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/PCC_Register.h"
    click PORTH "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/PORT_Register.h"
    click SCGH "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/SCG_Register.h"
    click SMCH "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/SMC_Register.h"
    click STH "https://github.com/thiennguyen15/s32k144f/blob/main/Register Header/ST_Register.h"
    click HWHeaders "https://github.com/thiennguyen15/s32k144f/tree/main/Header/"
    click MainC "https://github.com/thiennguyen15/s32k144f/blob/main/Source/main.c"
    click ClockCfg "https://github.com/thiennguyen15/s32k144f/blob/main/Source/clock_config.c"
    click LPITCfg "https://github.com/thiennguyen15/s32k144f/blob/main/Source/lpit_config.c"
    click LPSPICfg "https://github.com/thiennguyen15/s32k144f/blob/main/Source/lpspi_config.c"
    click LPUARTCfg "https://github.com/thiennguyen15/s32k144f/blob/main/Source/lpuart_config.c"
    click TimerSvc "https://github.com/thiennguyen15/s32k144f/blob/main/Source/software_timer.c"
    click GPIOEx "https://github.com/thiennguyen15/s32k144f/tree/main/Source/GPIO/"
    click LPUARTEx "https://github.com/thiennguyen15/s32k144f/tree/main/Source/LPUART/"
    click MAX7219Ex "https://github.com/thiennguyen15/s32k144f/blob/main/Source/MAX7219.c"
    click SysTickEx "https://github.com/thiennguyen15/s32k144f/blob/main/Source/SysTick_Timer.c"
    click LPITEx "https://github.com/thiennguyen15/s32k144f/blob/main/Source/Watcher - LPIT Interrupt.c"
    click Mock "https://github.com/thiennguyen15/s32k144f/blob/main/Mock Project.c"
    click Readme "https://github.com/thiennguyen15/s32k144f/blob/main/README.md"

    %% Styles
    classDef desktop fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef data fill:#E2F0CB,stroke:#6A994E,color:#6A994E;
    classDef codegen fill:#D0F4DE,stroke:#38A3A5,color:#086E7D;
    classDef generated fill:#E8F1D4,stroke:#A3B18A,color:#688E26;
    classDef tool fill:#FFF3B0,stroke:#F08A5D,color:#D1495B;
    classDef firmware fill:#FFE3E3,stroke:#E27D60,color:#C23B22;
    classDef hardware fill:#F0F0F0,stroke:#999999,color:#666666;
```
