# infineon/mtb-hal-cat1 architecture

> Architecture diagram of the GitHub repository infineon/mtb-hal-cat1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/infineon/mtb-hal-cat1
- Repository: https://github.com/infineon/mtb-hal-cat1

## Overview

##### Project type and purpose
- This is a cross-platform Hardware Abstraction Layer (HAL) library for Infineon/Cypress MCUs (ModusToolbox™).
- It provides a uniform, high-level C interface (cyhal_*.h) for peripheral drivers, power management, resource arbitration, and event callbacks.

##### File structure
- Top-level directories:
- / – public HAL headers (cyhal.h, cyhal_<peripheral>.h)
- include_pvt/ – private headers and internal hardware-type definitions
- source/ – core HAL implementation (.c)
- COMPONENT_CAT1A, COMPONENT_CAT1B, COMPONENT_CAT1C – platform-specific sub-modules for different MCU families (pin packages & trigger mappings)
- docs/ – generated API reference (Doxygen HTML)
- Key patterns:
- Layered API → core → platform
- “Hardware Manager” for resource arbitration (cyhal_hwmgr_*)
- “Syspm” for system power management (cyhal_syspm_*)
- Pin-package modules (per MCU package) and trigger mapping modules

##### README for additional insights
- HAL public interface vs. platform-specific implementation
- Resource management via Hardware Manager
- Power‐management strategies via Syspm driver
- Optional RTOS integration via RTOS_AWARE component
- Compile‐time binding to a specific device family

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Layer
    App["Application Layer"]:::external
    App -->|"uses"| PublicAPI

    %% Public API Layer
    PublicAPI["Public HAL API\n(include/)"]:::api
    PublicAPI -->|"dispatch to"| CoreHAL
    PublicAPI -->|"generate docs"| Docs

    %% Core HAL Engine
    subgraph "Core HAL Engine" 
        CoreHAL["Core HAL Engine\n(source/)"]:::core
        CoreHAL -->|reserve/release| HWMGR
        CoreHAL -->|register/unregister| SYSPM
        CoreHAL -->|handle events| EVENT
        CoreHAL -->|utility functions| UTILS
        CoreHAL -->|invoke| PERI
        CoreHAL -->|manage interconnect| INTERC
        CoreHAL -->|communicate IPC| IPC
        CoreHAL -->|private mappings| PrivateHAL
        CoreHAL -->|optional blocking| RTOS
        CoreHAL -->|optional register access| PDL
    end

    %% Private HAL Implementation
    PrivateHAL["Private HAL Implementation\n(include_pvt/)"]:::priv
    PrivateHAL -->|"compile-time bind"| Platform

    %% Platform-Specific Modules
    subgraph "Platform-Specific Modules" 
        subgraph "CAT1A" 
            CAT1A_H["Headers\n(COMPONENT_CAT1A/include/)"]:::plat
            CAT1A_Pin["Pin Packages\n(COMPONENT_CAT1A/include/pin_packages/)"]:::plat
            CAT1A_Trig["Trigger Mappings\n(COMPONENT_CAT1A/include/triggers/)"]:::plat
            CAT1A_SRC["Implementations\n(COMPONENT_CAT1A/source/)"]:::plat
            CAT1A_H --> CAT1A_Pin
            CAT1A_H --> CAT1A_Trig
            CAT1A_Pin --> CAT1A_SRC
            CAT1A_Trig --> CAT1A_SRC
        end
        subgraph "CAT1B" 
            CAT1B_H["Headers\n(COMPONENT_CAT1B/include/)"]:::plat
            CAT1B_Pin["Pin Packages\n(COMPONENT_CAT1B/include/pin_packages/)"]:::plat
            CAT1B_Trig["Trigger Mappings\n(COMPONENT_CAT1B/include/triggers/)"]:::plat
            CAT1B_SRC["Implementations\n(COMPONENT_CAT1B/source/)"]:::plat
            CAT1B_H --> CAT1B_Pin
            CAT1B_H --> CAT1B_Trig
            CAT1B_Pin --> CAT1B_SRC
            CAT1B_Trig --> CAT1B_SRC
        end
        subgraph "CAT1C" 
            CAT1C_H["Headers\n(COMPONENT_CAT1C/include/)"]:::plat
            CAT1C_Pin["Pin Packages\n(COMPONENT_CAT1C/include/pin_packages/)"]:::plat
            CAT1C_Trig["Trigger Mappings\n(COMPONENT_CAT1C/include/triggers/)"]:::plat
            CAT1C_SRC["Implementations\n(COMPONENT_CAT1C/source/)"]:::plat
            CAT1C_H --> CAT1C_Pin
            CAT1C_H --> CAT1C_Trig
            CAT1C_Pin --> CAT1C_SRC
            CAT1C_Trig --> CAT1C_SRC
        end
    end

    %% Hardware Layer
    Platform -->|"access hardware"| Hardware
    Hardware["MCU Hardware Registers\n(via PDL or direct)"]:::external

    %% Documentation
    Docs["Doxygen Docs\n(docs/html/)"]:::docs

    %% Optional Dependencies
    RTOS["RTOS Abstraction"]:::external
    PDL["Peripheral Driver Library (PDL)"]:::external

    %% Click Events
    click PublicAPI "https://github.com/infineon/mtb-hal-cat1/tree/master/include/"
    click CoreHAL "https://github.com/infineon/mtb-hal-cat1/tree/master/source/"
    click PrivateHAL "https://github.com/infineon/mtb-hal-cat1/tree/master/include_pvt/"
    click HWMGR "https://github.com/infineon/mtb-hal-cat1/blob/master/include/cyhal_hwmgr.h"
    click HWMGR "https://github.com/infineon/mtb-hal-cat1/blob/master/source/cyhal_hwmgr.c"
    click SYSPM "https://github.com/infineon/mtb-hal-cat1/blob/master/include/cyhal_syspm.h"
    click SYSPM "https://github.com/infineon/mtb-hal-cat1/blob/master/source/cyhal_syspm.c"
    click CAT1A_H "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1A/include/"
    click CAT1A_Pin "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1A/include/pin_packages/"
    click CAT1A_Trig "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1A/include/triggers/"
    click CAT1A_SRC "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1A/source/"
    click CAT1B_H "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1B/include/"
    click CAT1B_Pin "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1B/include/pin_packages/"
    click CAT1B_Trig "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1B/include/triggers/"
    click CAT1B_SRC "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1B/source/"
    click CAT1C_H "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1C/include/"
    click CAT1C_Pin "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1C/include/pin_packages/"
    click CAT1C_Trig "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1C/include/triggers/"
    click CAT1C_SRC "https://github.com/infineon/mtb-hal-cat1/tree/master/COMPONENT_CAT1C/source/"
    click Docs "https://github.com/infineon/mtb-hal-cat1/tree/master/docs/html/"
    click UTILS "https://github.com/infineon/mtb-hal-cat1/blob/master/include_pvt/cyhal_utils.h"
    click UTILS "https://github.com/infineon/mtb-hal-cat1/blob/master/include_pvt/cyhal_utils_impl.h"
    click UTILS "https://github.com/infineon/mtb-hal-cat1/blob/master/source/cyhal_utils.c"
    click UTILS "https://github.com/infineon/mtb-hal-cat1/blob/master/source/cyhal_utils_impl.c"
    click EVENT "https://github.com/infineon/mtb-hal-cat1/blob/master/include_pvt/cyhal_irq_impl.h"
    click EVENT "https://github.com/infineon/mtb-hal-cat1/blob/master/source/cyhal_irq_impl.c"
    click PERI "https://github.com/infineon/mtb-hal-cat1/blob/master/include/cyhal_gpio.h"
    click PERI "https://github.com/infineon/mtb-hal-cat1/blob/master/source/cyhal_gpio.c"
    click PERI "https://github.com/infineon/mtb-hal-cat1/blob/master/include_pvt/cyhal_gpio_impl.h"
    click INTERC "https://github.com/infineon/mtb-hal-cat1/blob/master/include/cyhal_interconnect.h"
    click INTERC "https://github.com/infineon/mtb-hal-cat1/blob/master/source/cyhal_interconnect.c"
    click IPC "https://github.com/infineon/mtb-hal-cat1/blob/master/include/cyhal_ipc.h"
    click IPC "https://github.com/infineon/mtb-hal-cat1/blob/master/source/cyhal_ipc.c"

    %% Styles
    classDef api fill:#D0E4F5,stroke:#0366d6,color:#0366d6;
    classDef core fill:#DFF5D0,stroke:#228B22,color:#228B22;
    classDef plat fill:#FFD8B1,stroke:#FF8C00,color:#FF8C00;
    classDef priv fill:#E0E0E0,stroke:#A9A9A9,color:#696969;
    classDef docs fill:#F3D0F5,stroke:#9400D3,color:#9400D3;
    classDef external fill:#FFFFFF,stroke-dasharray: 5 5,color:#808080;
```
