# texasinstruments/ti-pmic-lld architecture

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

- Interactive diagram: https://gitdiagram.com/texasinstruments/ti-pmic-lld
- Repository: https://github.com/texasinstruments/ti-pmic-lld

## Overview

##### Project type and purpose
- This is neither a full-stack app nor a web service, but a low-level embedded software library (TI PMIC LLD).
- Purpose: provide a platform- and OS-agnostic C API to configure Texas Instruments power management ICs, in compliance with ISO 26262.

##### Insights from README
- Abstracts register- and bit-field details via a well-defined API.
- Intended for automotive/industrial; supports multiple device families by branching per device.
- Integration: you clone the branch matching your PMIC family, then include its headers & sources in your embedded project.

a. Main components to show:
- Application Layer (your embedded application or RTOS driver)
- PMIC LLD Core API
- Device-Specific Modules (Leo, Hera)
- HAL Layer (I2C/SPI driver interface)
- Physical Bus (I2C or SPI)
- PMIC Hardware (Leo/Hera devices)
- Optional: Test Harness / CI component

b. Relationships & interactions:
1. The Application Layer calls functions in the PMIC LLD Core API.
2. Core API dispatches to the correct device driver module (leo or hera) based on compile-time configuration.
3. Device module uses HAL APIs to read/write PMIC registers over I2C/SPI.
4. HAL invokes the platform’s bus driver.
5. Bus driver communicates with the PMIC hardware.

c. Architectural patterns/design principles:
- Layered architecture (Application → Core API → Device Module → HAL → Bus → HW)
- Hardware Abstraction (separate HAL allows portability)
- Device Abstraction (branch per PMIC family encapsulates register details)

d. Key technologies/frameworks:
- Language: C, ISO 26262 safety guidelines
- Build system: Make/CMake or TI’s proprietary build scripts
- Bus protocols: I2C, SPI
- Test frameworks: Unity or CUnit (in tests/)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Software"
        direction TB
        App["Embedded Application/RTOS"]:::external
        Core["PMIC_LLD Core API\n(common/)"]:::core
        subgraph "Device Modules\n(compile-time)"
            direction TB
            Leo["Leo Driver Module\n(device/leo/)"]:::device
            Hera["Hera Driver Module\n(device/hera/)"]:::device
        end
        subgraph "HAL Layer"
            direction TB
            HALI2C["HAL I2C Driver\n(hal/)"]:::hal
            HALSPI["HAL SPI Driver\n(hal/)"]:::hal
        end
        Tests["Test Harness\n(tests/)"]:::external
    end

    subgraph "Bus Layer"
        direction TB
        I2C["I2C Bus"]:::hardware
        SPI["SPI Bus"]:::hardware
    end

    subgraph "Hardware"
        direction TB
        PMICLEO["PMIC Leo Device"]:::hardware
        PMICHERA["PMIC Hera Device"]:::hardware
    end

    App -->|"calls"| Core
    Core -->|"dispatch compile-time"| Leo
    Core -->|"dispatch compile-time"| Hera
    Leo -->|"uses"| HALI2C
    Leo -->|"uses"| HALSPI
    Hera -->|"uses"| HALI2C
    Hera -->|"uses"| HALSPI
    HALI2C -->|"I2C transactions"| I2C
    HALSPI -->|"SPI transactions"| SPI
    I2C --> PMICLEO
    I2C --> PMICHERA
    SPI --> PMICLEO
    SPI --> PMICHERA
    Tests --> Core
    Tests --> Leo
    Tests --> Hera

    classDef core fill:#cce5ff,stroke:#000,stroke-width:1px
    classDef device fill:#ccffcc,stroke:#000,stroke-width:1px
    classDef hal fill:#ffffcc,stroke:#000,stroke-width:1px
    classDef hardware fill:#ffffcc,stroke:#000,stroke-width:1px
    classDef external fill:#eeeeee,stroke:#000,stroke-width:1px
```
