# tomasdileo/stm32_trabajo_final architecture

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

- Interactive diagram: https://gitdiagram.com/tomasdileo/stm32_trabajo_final
- Repository: https://github.com/tomasdileo/stm32_trabajo_final

## Overview

##### Project Type and Purpose
- This is an embedded firmware project written in C for an STM32F103C6 microcontroller.
- Purpose: Drive an interactive shopping-mall kiosk system (keypad input, LCD output, temperature sensing, air-conditioning and alarm control).

##### High-Level File Structure Analysis
- Core/Inc & Core/Src: application entry point (`main.c`), system startup, ISR handlers, and syscalls.
- Core/Src/Drivers & Core/Inc/Drivers: application-level drivers for keypad, LCD, temperature sensor, AC and alarm.
- Drivers/CMSIS & Drivers/STM32F1xx_HAL_Driver: vendor libraries (CMSIS + STM32Cube HAL).
- Startup: MCU startup assembly.
- Project files (`.ioc`, linker script): hardware configuration and memory map.

##### README Insights
- Confirms final project for electronics course, focused on STM32 controlling mall locale system.
- User interacts via keypad; system displays status on LCD; monitors temperature; controls AC and triggers alarms.

a. Main Components
1. MCU Core (Cortex-M3)
2. HAL & CMSIS Layer
3. Application Drivers (Keypad, LCD, TempSensor, AC, Alarm)
4. Application Logic / State Machine (in `main.c`)
5. Peripherals:
– Keypad (User Input)
– LCD (User Feedback)
– Temperature Sensor (Data In)
– AC Unit (Control Out)
– Alarm Device (Control Out)
b. Relationships & Interactions
- On reset, Startup → HAL Init → Driver Init → Application Init.
- Main Loop polls keypad → sends commands to Application Logic → updates LCD and controls AC/Alarm based on logic and temperature readings.
- Temperature sensor read periodically → passed to Application Logic.
c. Architectural Patterns / Principles
- Layered design:
- Hardware Abstraction (CMSIS/HAL)
- Driver Layer (Core/Src/Drivers)
- Application Layer (Core/Src/main.c)
- Polling‐based main loop with simple state machine for user flow.
d. Key Technologies / Frameworks
- C language
- STM32Cube HAL (Drivers/STM32F1xx_HAL_Driver)
- CMSIS (Drivers/CMSIS)
- STM32CubeMX project configuration (`trabajo-final.ioc`)

##### Flow Chart of User Input / Usability Flow (Entry Point Focus)
- Start (power-on) → System Init → Display “Ready” on LCD
- Loop:
1. Wait for Keypad Input →
2. Parse Command (set temp, check status, arm/disarm alarm) →
3. Execute Action:
- Update internal state
- Send control signals to AC/Alarm
- Read Temperature Sensor → possibly auto-adjust AC
4. Update LCD Display → return to Wait
- Error/Alarm Condition: blink alarm indicator → display error → sound alarm

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% MCU Core & Startup
    subgraph "MCU Core & Startup"
        Startup["Startup"]:::blue
        SysInit["System Init"]:::blue
    end

    %% HAL & CMSIS Layer
    subgraph "HAL & CMSIS Layer"
        CMSIS["CMSIS"]:::blue
        HAL["HAL"]:::blue
    end

    %% Drivers Layer
    subgraph "Drivers Layer"
        KeypadDriver["Keypad Driver"]:::green
        LCDDriver["LCD Driver"]:::green
        TempDriver["TempSensor Driver"]:::green
        ACDriver["AC Driver"]:::green
        AlarmDriver["Alarm Driver"]:::green
    end

    %% Application Logic
    subgraph "Application Logic"
        Main["main() State Machine"]:::orange
    end

    %% Peripherals
    subgraph "Peripherals"
        Keypad["Keypad"]:::yellow
        LCD["LCD Display"]:::yellow
        TempSensor["Temp Sensor"]:::yellow
        ACUnit["AC Unit"]:::yellow
        AlarmDev["Alarm Device"]:::yellow
    end

    %% Initialization Flow
    Startup -->|"reset"| SysInit
    SysInit -->|"init"| CMSIS
    CMSIS -->|"init"| HAL
    HAL -->|"init"| KeypadDriver
    HAL -->|"init"| LCDDriver
    HAL -->|"init"| TempDriver
    HAL -->|"init"| ACDriver
    HAL -->|"init"| AlarmDriver
    %% Drivers to Application
    KeypadDriver -->|"ready"| Main
    LCDDriver -->|"ready"| Main
    TempDriver -->|"ready"| Main
    ACDriver -->|"ready"| Main
    AlarmDriver -->|"ready"| Main

    %% Hardware Interaction
    KeypadDriver -->|reads| Keypad
    LCDDriver -->|writes| LCD
    TempDriver -->|reads| TempSensor
    ACDriver -->|controls| ACUnit
    AlarmDriver -->|controls| AlarmDev

    %% Main Loop Data Flow
    Keypad -->|input| Main
    TempSensor -->|data| Main
    Main -->|display| LCD
    Main -->|control| ACUnit
    Main -->|control| AlarmDev
    Main -->|loop| Main

    %% Click Events
    click Startup "https://github.com/tomasdileo/stm32_trabajo_final/blob/main/Core/Startup/startup_stm32f103c6tx.s"
    click SysInit "https://github.com/tomasdileo/stm32_trabajo_final/blob/main/Core/Src/system_stm32f1xx.c"
    click CMSIS "https://github.com/tomasdileo/stm32_trabajo_final/tree/main/Drivers/CMSIS"
    click HAL "https://github.com/tomasdileo/stm32_trabajo_final/tree/main/Drivers/STM32F1xx_HAL_Driver/Inc"
    click KeypadDriver "https://github.com/tomasdileo/stm32_trabajo_final/blob/main/Core/Src/Drivers/KEYPAD.c"
    click LCDDriver "https://github.com/tomasdileo/stm32_trabajo_final/blob/main/Core/Src/Drivers/LCD_NC.c"
    click TempDriver "https://github.com/tomasdileo/stm32_trabajo_final/blob/main/Core/Src/Drivers/TEMPERATURE_SENSOR.c"
    click ACDriver "https://github.com/tomasdileo/stm32_trabajo_final/blob/main/Core/Src/Drivers/AIR_CONDITIONING.c"
    click AlarmDriver "https://github.com/tomasdileo/stm32_trabajo_final/blob/main/Core/Src/Drivers/ALARM.c"
    click Main "https://github.com/tomasdileo/stm32_trabajo_final/blob/main/Core/Src/main.c"

    %% Styles
    classDef blue fill:#D0E6FF,stroke:#037FDD;
    classDef green fill:#DFFFE0,stroke:#38A700;
    classDef orange fill:#FFE4B3,stroke:#FF8C00;
    classDef yellow fill:#FFF7C0,stroke:#BBB300;
```
