# ziad-abdelkarim/autosar-com-stack architecture

> Architecture diagram of the GitHub repository ziad-abdelkarim/autosar-com-stack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ziad-abdelkarim/autosar-com-stack
- Repository: https://github.com/ziad-abdelkarim/autosar-com-stack

## Overview

##### Project type and purpose
- This is an AUTOSAR-based ADAS (Adaptive Cruise Control) application targeting the TI TM4C123GH6PM microcontroller.
- It is structured as an embedded, full-stack control system: you have host-side Code Composer Studio (CCS) workspaces for building/debugging, a set of AUTOSAR Basic Software (BSW) modules, and a top-level application (“App(Main)”) implementing the cruise control logic.

##### File-tree analysis
- Top-level folders:
- Application(Windows): CCS project files and build outputs for Windows-hosted CCS execution.
- Application: CCS workspace containing demo/test projects (ApplicationCanDRVTest, freertos_demo, dvt).
- BSWs: contains all AUTOSAR BSW modules plus the actual App(Main) code.
- AUTOSAR BSW modules (under BSWs):
- CanDrv (MCAL driver)
- CanIf (CAN Interface)
- PduR (Protocol Data Unit Router)
- Com (Communication module)
- CanSM (CAN State Manager)
- Det (Development Error Tracer)
- App(Main): Setup.c/h and main.c implement the ACC application.
- Several build/configuration files (tm4c123*.cmd, CCS project definitions, linker scripts).

##### Key README insight
- “Autosar based ADAS application (graduation project)” tells us to use a layered AUTOSAR architectural view, even if RTE isn’t explicit in the tree.

a. Main components
- Hardware block: TM4C123GH6PM MCU, CAN transceiver, sensors/actuators (radar, throttle/brake interface).
- MCAL layer: CanDrv (driver directly talking to the CAN peripheral).
- ECU abstraction & services: CanIf → PduR → Com → Det.
- Application SWC: App(Main) containing the ACC algorithm (Setup.c/h + main.c).
- Host PC (CCS IDE): represents build/debug environment, flashing via JTAG.

b. Relationships & interactions
- Application issues actuator commands back down the same chain (→ Com → PduR → CanIf → CanDrv → Hardware).
- Host PC uses JTAG to flash/debug both Application(Windows) projects and BSWs.

c. Architectural patterns & principles
- Layered AUTOSAR architecture (MCAL / ECU-Abstraction / Services / RTE / Application).
- Separation of concerns: each BSW module in its own layer, clean interfaces via headers in BSWs/.../Inc.
- Test harness separation: CAN-driver test and FreeRTOS demo live in their own CCS subprojects.

d. Key technologies & frameworks
- TI Tiva C Series TM4C123GH6PM microcontroller
- Code Composer Studio project structure (Eclipse + CDT)
- AUTOSAR BSW modules (CanDrv, CanIf, PduR, Com, CanSM, Det)
- FreeRTOS (demo only, optional if ACC runs on RTOS)
- Linker scripts & CCS build files (tm4c123gh6pm.cmd, .cproject, .launches)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Application SWC Layer"
        AppMain["App(Main)"]:::app
    end

    subgraph "RTE (Logical Interface)"
        RTE_IF["RTE"]:::rte
    end

    subgraph "BSW Services"
        PduR["PduR"]:::services
        Com["Com"]:::services
        CanSM["CanSM"]:::services
        Det["Det"]:::services
    end

    subgraph "ECU Abstraction"
        CanIf["CanIf"]:::services
    end

    subgraph "MCAL Layer"
        CanDrv["CanDrv"]:::mcal
    end

    subgraph "Hardware Layer"
        MCU["TM4C123GH6PM MCU"]:::mcal
        CANBUS["CAN Bus"]:::infra
    end

    subgraph "Host PC / CCS IDE"
        HostPC["CCS IDE"]:::host
        Test1["ApplicationCanDRVTest"]:::host
        Test2["freertos_demo"]:::host
        Test3["dvt"]:::host
    end

    MCU -->|"CAN-Tx/Rx"| CANBUS
    CANBUS --> CanDrv
    CanDrv --> CanIf
    CanIf --> PduR
    PduR --> Com
    Com --> RTE_IF
    RTE_IF --> AppMain

    AppMain --> RTE_IF
    RTE_IF --> Com
    Com --> PduR
    PduR --> CanIf
    CanIf --> CanDrv
    CanDrv --> CANBUS

    Det -.-> CanDrv
    Det -.-> CanIf
    Det -.-> PduR
    Det -.-> Com
    Det -.-> CanSM

    HostPC -->|JTAG Flash/Debug| MCU
    HostPC --> Test1
    HostPC --> Test2
    HostPC --> Test3

    classDef mcal fill:#ADD8E6,stroke:#000;
    classDef services fill:#90EE90,stroke:#000;
    classDef rte fill:#FFA500,stroke:#000;
    classDef app fill:#FFFF00,stroke:#000;
    classDef host fill:#D3D3D3,stroke:#000;
    classDef infra fill:#B0C4DE,stroke:#000;

    click AppMain "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/BSWs/App(Main)"
    click CanDrv "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/BSWs/CanDrv"
    click CanIf "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/BSWs/CanIf"
    click PduR "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/BSWs/PduR"
    click Com "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/BSWs/Com"
    click CanSM "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/BSWs/CanSM"
    click Det "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/BSWs/Det"
    click MCU "https://github.com/ziad-abdelkarim/autosar-com-stack/blob/master/Application(Windows)/tm4c123gh6pm.cmd"
    click HostPC "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/Application(Windows)"
    click Test1 "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/Application/ApplicationCanDRVTest"
    click Test2 "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/Application/freertos_demo"
    click Test3 "https://github.com/ziad-abdelkarim/autosar-com-stack/tree/master/Application/dvt"
```
