# infineon/ref_esc_48v_80a_foc architecture

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

- Interactive diagram: https://gitdiagram.com/infineon/ref_esc_48v_80a_foc
- Repository: https://github.com/infineon/ref_esc_48v_80a_foc

## Overview

##### Project type and purpose
- This is an embedded C firmware project for an Electronic Speed Controller (ESC) reference design (REF_ESC_48V_80A_FOC).
- Purpose: implement sensorless Field-Oriented Control (FOC) of a three-phase PMSM using a PSOC™ Control C3 MCU, non-invasive current sensors, and generate PWM/DSHOT signals to drive a power stage for drone motors.

##### File structure
- Top-level:
- bsps/… – board support package for the ESC reference board (linker scripts, startup, HAL wrappers, auto-generated hardware-config sources)
- configuration/… – user-configurable C modules for hardware interfaces (MCU, pins, clocks) and motor-control library parameters
- deps/… – ModusToolbox library metadata (.mtb, .mtbx)
- main.c – application entry point (initializes hardware, kicks off FOC loops, handles DSHOT decoding)
- build/… – build artifacts, object files, linker reports; ninja/make integration
- templates/… – project templates for other target boards
- Makefile, compile_commands.json, csources, linker scripts, etc.
- Architectural patterns: layered firmware: BSP → HAL/PDL → motor-control library → application
- Key configuration files: bsp.mk, props.json, linker scripts, cycfg.c/.h modules

##### README for additional insights
- Confirms use of PSOC™ Control C3 MCU (Arm® Cortex®-M33), XENSIV™ TMR current sensors, OptiMOS™ MOSFETs and DSHOT600 for flight-controller communication.
- Describes flight-controller interface, Motor Suite GUI, J-Link debug.
- Highlights discrete hardware (sensor, driver, power stage) and firmware layers (FOC algorithm, DSHOT decoder, UART/retarget-io).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Hardware Components"
        direction TB
        Sensors["Current Sensors\n(TMR + Op-Amps)"]:::hardware
        ADC["ADC Peripheral"]:::hardware
        MCU["MCU\n(Cortex-M33 PSOC™ Control C3)"]:::hardware
        PWM["PWM Module"]:::hardware
        GateDrivers["Gate Drivers"]:::hardware
        MOSFETs["OptiMOS™ MOSFET Bridge"]:::hardware
        Motor["3-Phase PMSM Motor"]:::hardware
        Sensors --> ADC --> MCU --> PWM --> GateDrivers --> MOSFETs --> Motor
    end

    subgraph "Firmware Stack"
        direction TB
        BSP["Board Support Package (BSP)"]:::bsp
        Cfg["cycfg Init"]:::cycfg
        PDL["Peripheral Driver Library (PDL/HAL)"]:::pdl
        MCLib["Motor-Control Lib v3.x"]:::lib
        App["Application\n(main.c & ISRs)"]:::app
        BuildSys["Build System\n(Makefile, Ninja, metadata)"]:::build
        BSP --> Cfg --> PDL --> MCLib --> App --> BuildSys
    end

    App -->|"DSHOT600 ISR"| MCU
    App -->|"FOC ISR"| ADC

    subgraph "External Interfaces"
        direction TB
        MotorSuite["Motor Suite GUI"]:::ext
        JLink["J-Link SWD Debug"]:::ext
        MotorSuite --> App
        JLink --> BSP
    end

    %% Click Events
    click BSP "https://github.com/infineon/ref_esc_48v_80a_foc/tree/main/bsps/TARGET_KIT_ESC_DEMO/"
    click BSP "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/startup_cat1b_cm33.c"
    click BSP "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/startup_cat1b.h"
    click BSP "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/system_psc3.c"
    click BSP "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/system_cat1b.h"
    click BSP "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/TOOLCHAIN_*/*.sct"
    click BSP "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/TOOLCHAIN_*/*.ld"
    click BSP "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/TOOLCHAIN_*/*.icf"

    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg.c"
    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg.h"
    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg_clocks.c"
    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg_clocks.h"
    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg_pins.c"
    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg_pins.h"
    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg_peripherals.c"
    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg_peripherals.h"
    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg_system.c"
    click Cfg "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/config/GeneratedSource/cycfg_system.h"

    click PDL "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/deps/mtb-hal-psc3.mtbx"
    click PDL "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/deps/mtb-pdl-cat1.mtbx"
    click PDL "https://github.com/infineon/ref_esc_48v_80a_foc/tree/main/build/Custom/libraries_shared/mtb-hal-psc3/source/"
    click PDL "https://github.com/infineon/ref_esc_48v_80a_foc/tree/main/build/Custom/libraries_shared/mtb-pdl-cat1/drivers/source/"

    click MCLib "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/deps/motor-ctrl-lib.mtbx"
    click MCLib "https://github.com/infineon/ref_esc_48v_80a_foc/tree/main/build/Custom/libraries_shared/motor-ctrl-lib/OperationalCode/"
    click MCLib "https://github.com/infineon/ref_esc_48v_80a_foc/tree/main/build/Custom/libraries_shared/motor-ctrl-lib/ThirdPartyLib/"

    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/main.c"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/hw-Config/HardwareIface.c"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/hw-Config/HardwareIface.h"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/hw-Config/MCU.c"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/hw-Config/MCU.h"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/hw-Config/MotorCtrlHWConfig.c"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/hw-Config/MotorCtrlHWConfig.h"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/motor-ctrl-lib-config/MotorCtrlLibConfig.c"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/motor-ctrl-lib-config/MotorCtrlLibConfig.h"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/motor-ctrl-lib-config/ParamConfig.c"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/configuration/motor-ctrl-lib-config/ParamConfig.h"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/deps/retarget-io.mtbx"
    click App "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/build/Custom/libraries_shared/retarget-io/source/cy_retarget_io.o"

    click BuildSys "https://github.com/infineon/ref_esc_48v_80a_foc/tree/main/Makefile"
    click BuildSys "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/compile_commands.json"
    click BuildSys "https://github.com/infineon/ref_esc_48v_80a_foc/blob/main/bsps/TARGET_KIT_ESC_DEMO/props.json"
    click BuildSys "https://github.com/infineon/ref_esc_48v_80a_foc/tree/main/csources"

    %% Styles
    classDef hardware fill:#ccffcc,stroke:#2e7d32,stroke-width:2px;
    classDef bsp fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef cycfg fill:#e0f2f1,stroke:#004d40,stroke-width:1px;
    classDef pdl fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px;
    classDef lib fill:#f3e5f5,stroke:#6a1b9a,stroke-width:2px;
    classDef app fill:#fff3e0,stroke:#bf360c,stroke-width:2px;
    classDef build fill:#eceff1,stroke:#607d8b,stroke-width:2px;
    classDef ext stroke-dasharray:5 5,fill:none,stroke:#424242;
```
