# infineon/target_psoc6-generic architecture

> Architecture diagram of the GitHub repository infineon/target_psoc6-generic, 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/target_psoc6-generic
- Repository: https://github.com/infineon/target_psoc6-generic

## Overview

##### Project Type and Purpose
- This is a Board Support Package (BSP) for the PSoC™ 6 microcontroller family.
- Its purpose is to provide hardware-abstraction, startup code, device initialization, clock/power configuration, and multi-toolchain support so that application projects can include a single “cybsp.h” header and immediately target a custom PSoC6 board.
- It is not a full-stack web application or microservice; rather, it is embedded-firmware infrastructure that sits between the bare metal hardware and end-user application code.

##### File Structure Analysis
- Top-level build files:
- bsp.mk – Makefile that pulls in default components and defines BSP configuration flags
- props.json, config/design.modus – hardware manifest and design metadata used by ModusToolbox
- Core components:
- COMPONENT_CM0P, COMPONENT_CM4 – startup and system files for the CM0+ and CM4 cores
- Each contains subfolders per toolchain (ARM, Clang, GCC, IAR) with linker scripts and startup assembly
- system_psoc6_cm0plus.c / system_psoc6_cm4.c – clock, power, and system initialization
- BSP HAL and headers:
- cybsp.c/.h, cybsp_hw_config.h, cybsp_types.h, cybsp_doc.h – hardware-abstraction API
- Documentation:
- docs/html – generated Doxygen API reference and BSP user guide
- Licensing and metadata:
- LICENSE, EULA, RELEASE.md

##### Key Insights from README
- The BSP is a template; it requires a custom manifest to define actual board pins and peripherals.
- Default clock (FLL, PLL) and power configurations are provided.
- BSP features are toggled via defines (e.g., CY_USING_HAL, CYBSP_WIFI_CAPABLE).
- Intended to be consumed via ModusToolbox or any make-based build system.

a. Main Components
1. Hardware Layer
- PSoC6 SoC with dual cores: CM0+ (low-power) and CM4 (application)
- On-chip peripherals: Clocks (FLL, PLL), GPIO, Power Management, IPC channel
2. BSP Software Layer
- Startup Sequences (core-specific assembly + linker scripts)
- system_psoc6_cm0plus.c / system_psoc6_cm4.c – clock/power init
- HAL APIs (cybsp.c/h) – board-level drivers for pins, power, system callbacks
- Configuration/Manifest (props.json, design.modus, mk files)
3. Build Toolchain Layer
- ModusToolbox or Make
- Toolchain adapters for ARM, Clang, GCC, IAR – select appropriate startup/linker
4. Application Layer
- User code includes cybsp.h, invokes BSP init, then uses HAL drivers and system callbacks
5. Documentation & Examples
- Doxygen-generated HTML under docs/html for API reference

b. Relationships & Interactions
- On power-up, the build system selects the correct toolchain folder; startup code runs on both cores.
- system_*.c configures clocks, power modes based on BSP defaults or user defines.
- cybsp.c/.h exposes HAL functions that abstract peripheral initialization and pin assignments.
- Application code calls into the HAL, which in turn manipulates hardware registers.
- Configuration files feed both the build system and the BSP code so that manifests, callbacks, and power settings can be customized.

c. Architectural Patterns & Principles
- Layered Abstraction – hardware registers < BSP system init < HAL API < user application
- Core Separation – dual-core startup and synchronization via IPC (implied)
- Toolchain Abstraction – maintain identical directory structures per toolchain for consistency
- Configuration-over-Code – uses manifest files and make-file defines to customize behavior

d. Relevant Technologies
- PSoC6 MCU (dual-core ARM Cortex®-M architecture)
- Make (bsp.mk, toolchain-specific makefiles)
- ModusToolbox design metadata (design.modus, props.json)
- Doxygen for documentation generation

##### Essential Details to Capture
- Both cores and their initialization paths
- Clock and power configuration flow
- HAL layer as the only exposed API to application
- Configuration feedback loop (defines, manifest)
- Multi-toolchain support points

## Diagram (Mermaid)

```mermaid
graph TD
    %% Hardware Layer
    subgraph "Hardware Layer"
        style HardwareLayer fill:#eeeeee,stroke:#333,stroke-width:1px
        SOC["PSoC6 SoC\n(CM0+ & CM4 cores)"]:::hardware
        Peripherals["On-chip Peripherals\n(Clocks, GPIO, Power, IPC)"]:::hardware
    end

    %% Build Toolchain Layer
    subgraph "Build Toolchain Layer"
        Make["ModusToolbox / Make"]:::build
        subgraph "Toolchain Adapters"
            TC_CM0["CM0+ Toolchain Folders"]:::build
            TC_CM4["CM4 Toolchain Folders"]:::build
        end
    end

    %% BSP System Layer
    subgraph "BSP System Layer"
        subgraph "Startup Sequences (CM0+)"
            CM0_ARM["Startup CM0+ (ARM)"]:::bsp
            CM0_Clang["Startup CM0+ (Clang)"]:::bsp
            CM0_GCC["Startup CM0+ (GCC)"]:::bsp
            CM0_IAR["Startup CM0+ (IAR)"]:::bsp
        end
        Sys0["system_psoc6_cm0plus.c"]:::bsp

        subgraph "Startup Sequences (CM4)"
            CM4_ARM["Startup CM4 (ARM)"]:::bsp
            CM4_Clang["Startup CM4 (Clang)"]:::bsp
            CM4_GCC["Startup CM4 (GCC)"]:::bsp
            CM4_IAR["Startup CM4 (IAR)"]:::bsp
        end
        Sys4["system_psoc6_cm4.c"]:::bsp

        HAL["cybsp HAL APIs\n(cybsp.c/.h, config, types)"]:::bsp
        Config["Configuration & Manifest\n(props.json, design.modus, bsp.mk)"]:::bsp
    end

    %% Application Layer
    subgraph "Application Layer"
        App["User Application Code\n(includes cybsp.h)"]:::app
    end

    %% Documentation & Metadata
    subgraph "Docs & Metadata"
        Docs["Doxygen HTML Docs\n(docs/html)"]:::docs
        License["LICENSE, EULA, RELEASE.md"]:::docs
    end

    %% Connections
    Make -->|selects| TC_CM0
    Make -->|selects| TC_CM4

    TC_CM0 -->|provides| CM0_ARM
    TC_CM0 -->|provides| CM0_Clang
    TC_CM0 -->|provides| CM0_GCC
    TC_CM0 -->|provides| CM0_IAR
    CM0_ARM -->|executes| Sys0
    CM0_Clang -->|executes| Sys0
    CM0_GCC -->|executes| Sys0
    CM0_IAR -->|executes| Sys0

    TC_CM4 -->|provides| CM4_ARM
    TC_CM4 -->|provides| CM4_Clang
    TC_CM4 -->|provides| CM4_GCC
    TC_CM4 -->|provides| CM4_IAR
    CM4_ARM -->|executes| Sys4
    CM4_Clang -->|executes| Sys4
    CM4_GCC -->|executes| Sys4
    CM4_IAR -->|executes| Sys4

    Sys0 -->|initializes clocks/power| HAL
    Sys4 -->|initializes clocks/power| HAL
    Config -->|drives defines| Sys0
    Config -->|drives defines| Sys4
    HAL -->|exposes API to| App
    App -->|calls| HAL

    Config -->|used by| Make
    Docs -->|documents| HAL
    Docs -->|documents| Config

    SOC -->|contains| Peripherals
    HAL -->|manipulates| Peripherals
    App -->|runs on| SOC

    %% Click Events
    click CM0_ARM "https://github.com/infineon/target_psoc6-generic/tree/master/COMPONENT_CM0P/TOOLCHAIN_ARM"
    click CM0_Clang "https://github.com/infineon/target_psoc6-generic/tree/master/COMPONENT_CM0P/TOOLCHAIN_A_Clang"
    click CM0_GCC "https://github.com/infineon/target_psoc6-generic/tree/master/COMPONENT_CM0P/TOOLCHAIN_GCC_ARM"
    click CM0_IAR "https://github.com/infineon/target_psoc6-generic/tree/master/COMPONENT_CM0P/TOOLCHAIN_IAR"
    click Sys0 "https://github.com/infineon/target_psoc6-generic/blob/master/COMPONENT_CM0P/system_psoc6_cm0plus.c"

    click CM4_ARM "https://github.com/infineon/target_psoc6-generic/tree/master/COMPONENT_CM4/TOOLCHAIN_ARM"
    click CM4_Clang "https://github.com/infineon/target_psoc6-generic/tree/master/COMPONENT_CM4/TOOLCHAIN_A_Clang"
    click CM4_GCC "https://github.com/infineon/target_psoc6-generic/tree/master/COMPONENT_CM4/TOOLCHAIN_GCC_ARM"
    click CM4_IAR "https://github.com/infineon/target_psoc6-generic/tree/master/COMPONENT_CM4/TOOLCHAIN_IAR"
    click Sys4 "https://github.com/infineon/target_psoc6-generic/blob/master/COMPONENT_CM4/system_psoc6_cm4.c"

    click HAL "https://github.com/infineon/target_psoc6-generic/blob/master/cybsp.c"
    click Config "https://github.com/infineon/target_psoc6-generic/blob/master/bsp.mk"
    click Docs "https://github.com/infineon/target_psoc6-generic/tree/master/docs/html"
    click License "https://github.com/infineon/target_psoc6-generic/tree/master/LICENSE"

    %% Styles
    classDef hardware fill:#cccccc,stroke:#333,stroke-width:1px
    classDef build fill:#bbffbb,stroke:#333,stroke-width:1px
    classDef bsp fill:#bbbbff,stroke:#333,stroke-width:1px
    classDef app fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef docs fill:#ddccff,stroke:#333,stroke-width:1px
```
