# stmicroelectronics/x-cube-usb-pd architecture

> Architecture diagram of the GitHub repository stmicroelectronics/x-cube-usb-pd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stmicroelectronics/x-cube-usb-pd
- Repository: https://github.com/stmicroelectronics/x-cube-usb-pd

## Overview

X-CUBE-USB-PD is an STM32F0 firmware package for USB Type-C port management and USB Power Delivery. In the EVAL_FUSB307_DRP example, startup initializes the PD Device Policy Manager (DPM) and its application policy; the stack manages negotiation through a board TCPM/TCPCI adapter and FUSB305 controller. The package also provides optional GUI reporting/control and tracing. The graph emphasizes those product capabilities; implementation links for unsampled user-policy and power-management code are left unverified where the excerpts do not establish calls.

Main entry points: [`Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_dpm_core.c`](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_dpm_core.c) (DPM core), [`Utilities/GUI_INTERFACE/gui_api.c`](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/GUI_INTERFACE/gui_api.c) (GUI interface), [`Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/main.c`](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/main.c) (Application startup), [`Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_dpm_user.c`](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_dpm_user.c) (User policy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Example application"]
  node_startup["Application startup<br/>[main.c]"]
  node_user_policy["User policy<br/>[usbpd_dpm_user.c]"]
  node_power_iface["Power interface<br/>[usbpd_pwr_if.c]"]
  node_vdm_policy["VDM policy<br/>[usbpd_vdm_user.c]"]
end

subgraph group_protocol["PD stack"]
  node_dpm["DPM core<br/>[usbpd_dpm_core.c]"]
  node_pd_api["PD core API<br/>[usbpd_core.h]"]
  node_tcpc_api["TCPCI interface<br/>[usbpd_tcpci.h]"]
  node_timers["PD timers"]
end

subgraph group_hardware["Board hardware"]
  node_tcpci_board["Board TCPCI<br/>[usbpd_tcpci.c]"]
  node_fusb_driver["FUSB305 driver<br/>[fusb305.c]"]
  node_nucleo_bsp["Nucleo BSP<br/>[stm32f0xx_nucleo.c]"]
end

subgraph group_utilities["Utilities"]
  node_gui["GUI interface<br/>[gui_api.c]"]
  node_gui_transport["GUI transport<br/>[bsp_gui.c]"]
  node_tlv["TLV encoding<br/>[data_struct_tlv.c]"]
  node_tracer["Embedded tracer<br/>[tracer_emb.c]"]
  node_trace_hw["Tracer hardware<br/>[tracer_emb_hw.c]"]
end

node_host(("Firmware host"))
node_fusb_device{{"FUSB305 controller"}}
node_computer(("Computer"))

node_host -->|"starts"| node_startup
node_startup -->|"initializes"| node_dpm
node_startup -->|"initializes"| node_user_policy
node_startup -->|"initializes optionally"| node_gui
node_dpm -->|"uses API"| node_pd_api
node_dpm -->|"dispatches policy"| node_user_policy
node_dpm -->|"uses interface"| node_tcpc_api
node_dpm -->|"uses timers"| node_timers
node_user_policy -.->|"coordinates power"| node_power_iface
node_user_policy -.->|"coordinates VDM"| node_vdm_policy
node_tcpc_api -.->|"implemented by"| node_tcpci_board
node_tcpci_board -.->|"uses driver"| node_fusb_driver
node_fusb_driver -->|"accesses"| node_fusb_device
node_tcpci_board -.->|"uses board support"| node_nucleo_bsp
node_gui -->|"reads PD state"| node_pd_api
node_gui -->|"encodes messages"| node_tlv
node_gui -.->|"sends GUI data"| node_gui_transport
node_gui_transport -.->|"UART communication"| node_computer
node_gui -.->|"uses tracing"| node_tracer
node_tracer -->|"delegates hardware"| node_trace_hw

click node_startup "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/main.c"
click node_user_policy "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_dpm_user.c"
click node_power_iface "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_pwr_if.c"
click node_vdm_policy "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_vdm_user.c"
click node_dpm "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_dpm_core.c"
click node_pd_api "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Middlewares/ST/STM32_USBPD_Library/Core/inc/usbpd_core.h"
click node_tcpc_api "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/STM32F0xx-Nucleo/usbpd_tcpci.h"
click node_tcpci_board "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/STM32F0xx-Nucleo/usbpd_tcpci.c"
click node_fusb_driver "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/Components/fusb307/fusb305.c"
click node_nucleo_bsp "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/STM32F0xx-Nucleo/stm32f0xx_nucleo.c"
click node_timers "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/STM32F0xx-Nucleo/TCPM/usbpd_timersserver.c"
click node_gui "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/GUI_INTERFACE/gui_api.c"
click node_gui_transport "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/GUI_INTERFACE/bsp_gui.c"
click node_tlv "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/GUI_INTERFACE/data_struct_tlv.c"
click node_tracer "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/TRACER_EMB/tracer_emb.c"
click node_trace_hw "https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/TRACER_EMB/tracer_emb_hw.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_startup,node_user_policy,node_power_iface,node_vdm_policy toneBlue
class node_dpm,node_pd_api,node_tcpc_api,node_timers toneAmber
class node_tcpci_board,node_fusb_driver,node_nucleo_bsp toneMint
class node_gui,node_gui_transport,node_tlv,node_tracer,node_trace_hw toneRose
class node_host,node_fusb_device,node_computer toneIndigo
```

## Components

### Example application

- [Application startup](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/main.c): `Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/main.c`
- [User policy](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_dpm_user.c): `Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_dpm_user.c`
- [Power interface](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_pwr_if.c): `Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_pwr_if.c`
- [VDM policy](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_vdm_user.c): `Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/usbpd_vdm_user.c`

### PD stack

- [DPM core](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_dpm_core.c): `Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_dpm_core.c`
- [PD core API](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Middlewares/ST/STM32_USBPD_Library/Core/inc/usbpd_core.h): `Middlewares/ST/STM32_USBPD_Library/Core/inc/usbpd_core.h`
- [TCPCI interface](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/STM32F0xx-Nucleo/usbpd_tcpci.h): `Drivers/BSP/STM32F0xx-Nucleo/usbpd_tcpci.h`
- [PD timers](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/STM32F0xx-Nucleo/TCPM/usbpd_timersserver.c): `Drivers/BSP/STM32F0xx-Nucleo/TCPM/usbpd_timersserver.c`

### Board hardware

- [Board TCPCI](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/STM32F0xx-Nucleo/usbpd_tcpci.c): `Drivers/BSP/STM32F0xx-Nucleo/usbpd_tcpci.c`
- [FUSB305 driver](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/Components/fusb307/fusb305.c): `Drivers/BSP/Components/fusb307/fusb305.c`
- [Nucleo BSP](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Drivers/BSP/STM32F0xx-Nucleo/stm32f0xx_nucleo.c): `Drivers/BSP/STM32F0xx-Nucleo/stm32f0xx_nucleo.c`

### Utilities

- [GUI interface](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/GUI_INTERFACE/gui_api.c): `Utilities/GUI_INTERFACE/gui_api.c`
- [GUI transport](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/GUI_INTERFACE/bsp_gui.c): `Utilities/GUI_INTERFACE/bsp_gui.c`
- [TLV encoding](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/GUI_INTERFACE/data_struct_tlv.c): `Utilities/GUI_INTERFACE/data_struct_tlv.c`
- [Embedded tracer](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/TRACER_EMB/tracer_emb.c): `Utilities/TRACER_EMB/tracer_emb.c`
- [Tracer hardware](https://github.com/stmicroelectronics/x-cube-usb-pd/blob/master/Utilities/TRACER_EMB/tracer_emb_hw.c): `Utilities/TRACER_EMB/tracer_emb_hw.c`

### Other components

- **Firmware host**
- **FUSB305 controller**
- **Computer**

## Connections

- Firmware host → Application startup: starts (evidence: `Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/main.c`)
- Application startup → DPM core: initializes (evidence: `Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/main.c`)
- Application startup → User policy: initializes (evidence: `Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/main.c`)
- Application startup → GUI interface: initializes optionally (evidence: `Projects/STM32F072RB-Nucleo/Applications/USB_PD/EVAL_FUSB307_DRP/Src/main.c`)
- DPM core → PD core API: uses API (evidence: `Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_dpm_core.c`)
- DPM core → User policy: dispatches policy (evidence: `Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_dpm_core.c`)
- DPM core → TCPCI interface: uses interface (evidence: `Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_dpm_core.c`)
- DPM core → PD timers: uses timers (evidence: `Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_dpm_core.c`)
- User policy → Power interface: coordinates power
- User policy → VDM policy: coordinates VDM
- TCPCI interface → Board TCPCI: implemented by
- Board TCPCI → FUSB305 driver: uses driver
- FUSB305 driver → FUSB305 controller: accesses (evidence: `Drivers/BSP/Components/fusb307/fusb305.c`)
- Board TCPCI → Nucleo BSP: uses board support
- GUI interface → PD core API: reads PD state (evidence: `Utilities/GUI_INTERFACE/gui_api.c`)
- GUI interface → TLV encoding: encodes messages (evidence: `Utilities/GUI_INTERFACE/gui_api.c`)
- GUI interface → GUI transport: sends GUI data
- GUI transport → Computer: UART communication
- GUI interface → Embedded tracer: uses tracing
- Embedded tracer → Tracer hardware: delegates hardware (evidence: `Utilities/TRACER_EMB/tracer_emb.c`)
