
STSW-STUSB014
Firmware package
documentation
V1.1

Overview
3
The software library includes 8 different software frameworks
already optimized to address most common application scenario:
STM32G474_MB1303_SRC_ONLY (*)
Provider / SOURCE (power management)
SOURCE (power management)
message support + UFP support (Billboard class)
STM32G474_MB1303_SNK_ONLY (*)
Consumer / SINK (power management)
+ extended
message support + UFP support (Billboard class)
STM32G474_MB1303_DRP_ONLY (*)
Role Port (power management)
Role Port (power management)
extended message support + UFP support (Billboard class)
STM32G474_MB1303_DRP_2PORTS
Role Port (power management) + dead battery mode
extended message support + UFP support (HID class)
Dual Role Port requesting
PR_swap when attached in Sink or
when attached in Source + UFP support (HID class)
- by default, all projects are packaged with RTOS support
- project annotated with a (*) are available with and without RTOS support

• Projects folder provides different application examples in which each
project name is prefix with MCU name:
Folder view
4
• Project name is build as: MCUname_shieldref_TypeCrole_type

Projects can be compiled with either:
• IAR 8.x,
• GCC using GNU Arm Embedded Toolchain (version used: 9 2020-q2-update with GNU make-4.3),
• STM32CubeIDE (download here).
Compiler
5

Type = ONLY
• Those projects are simple ones. Only mandatory features are present, with RTOS
Type = ONLY_noRTOS
• Those projects are simple ones. Only mandatory features are present, without RTOS
Type = VDM
• Those projects are complex ones. Lot of optional features are present and could be
disabled/enabled by compilation switch
Type = SRCING_DEVICE
• This project is DRP sourcing device: application always try to achieve power role as
source and data role as UFP
Project Type
6

Switch name Comment
✓ ✓ ✓ ✓ ✓
_TRACE Trace enabled for debug using UART
✓ ✓ ✓ ✓ ✓
_ERROR_RECOVERY Enable error_recovery in lib stack.
Mandatory for DRP compliance
✓ ✓ ✓ ✓ ✓
_VCONN_SUPPORT Enabled in SRC and DRP project for cable
messaging
X X ✓ ✓ ✓
_SRC_CAPA_EXT Enable source extended capability messages
X X ✓ ✓ ✓
_ADC_MONITORING Enable MCU ADC usage for voltage reporting.
X X ✓ ✓ ✓
_VDM Enable VDM messages possibility and needed
for cable messages
☼ ☼ ☼ ☼ ☼
SPI_ONE_LINE Disabled by default.
Allow to merge MOSI and MISO pins
X X ☼ ☼ ☼
_MANU_INFO Disabled by default.
Used to send/reply to manufacturer info
messages
X X ✓ ✓ ✓
_ALERT Allow to send Alert messages
X X ✓ ✓ ✓
_STATUS Allow to send Status messages
Compilation switches (1/2)
7

Compilation switches (2/2)
8
ONLY
RTOS
VDM 2PORTS
SRCING_
DEVICE
Switch name Comment
X X ☼ ☼ ☼
_BATTERY
Disabled by default.
Used to send/reply to battery messages
X X ✓ ✓ ✓
USBPD_DATA
To setup and initialize USB IP in peripheral.
Disabled by default on ‘SRC’ project
X X ☼ ✓ ✓
_CLASS_HID
To configure descriptor class in HID
X X ✓ ☼ ☼
_CLASS_BB
To configure descriptor class in BillBoard
X X ☼ ☼ ✓
SOURCING_DEVICE
Application requests PR_swap
or DR_swap when attached in Source
X X ✓ ☼ ☼
UNCHUNKED_SUPPORT
Allow support of unchunkedmessages
✓ X ✓ ✓ ✓
USBPD_LED_SERVER
To enable LED server for VBUS/CC/role toggling
☼ ☼ ☼ ☼ ☼
_GPIO_FOR_SRC
To drive 2 other voltages on top of 5V, in Source or
DRP, using OpenDrain GPIOs (see here)
☼ ☼ ☼ ☼ ☼
_VVAR_FLASH
Allows to output DAC on ADD0 pin. DAC output value
is always 1/10 of VBUS value
Not supported and can’t be enabled in current project
Not supported by default but can be enabled in current project
Supported by default (and can be disabled) in current project

• MCU and board related settings are part of BSP folder. MCU name is
found in folder name: see stm32G474 example below
• In BSP file, Readme_Nucleo_Hardware_modif.txt file gives instructions
on modifications to be done on Nucleo board used in order to use
MB1303 shield
Shield-MCU setup
9

_GPIO_FOR_SRC
10
Hardware implementation proposal using _GPIO_FOR_SRC switch.
It proposes total 3 PDOs:
5V-9V-15V
toggling PB6 and PB7
defined as OpenDrain GPIOs
using NUCLEO-G474RE

_VVAR_FLASH
11
Hardware implementation proposal using _VVAR_FLASH switch.
Enabling this switch will
allow to output 1/10
th
of
PDO voltage selected for
VBUS on VVAR-ADD0
STUSB1602 pin

• This is the typical framework for SOURCE only applications, implementing USB PD power
negotiation.
• The code provided includes 1 PDO including EMCA support : when used with 3A only
cables, maximum current advertised by the SOURCE is bounded to 3A for those PDO
which normally support more than 3A.
• Default profiles is:
• PDO1: 5V, 3A
#1 - MB1303_SRC_ONLY
overview
12
NB:
Optional 9V and 12V profiles are available using _GPIO_FOR_SRC switch
and appropriate hardware (see here)

• This is the typical framework for SOURCE only applications, implementing USB PD
power negotiation and supporting optional extended messages.
• The code provided includes 1 PDO (including EMCA support ), and is able to answer
to the following messages:
• Manufacturer info
• Discover identity
• Unchunked extended messages
• Defaults profiles is:
• PDO1: 5V - 3A
#2 - MB1303_SRC_VDM
overview
13
NB:
Optional 9V and 12V profiles are available using _GPIO_FOR_SRC switch
and appropriate hardware (see here)

• This is the typical framework for SINK only applications, implementing USB PD power
negotiation.
• The code provided includes 2 PDOs (max power has priority),
• Defaults profiles are:
• PDO1: 5V - 1.5A
• PDO2: 9V - 1.5A
#3 - MB1303_SNK_ONLY
overview
14

• This is the typical framework for SINK only applications, implementing USB PD power
negotiation and supporting optional extended messages. Project is defined as an Alternate
Mode Adapter: it is able to enter alternate as a Display Port and enumerate as Billboard
otherwise.
• The code provided includes 2 PDOs, and is able to answer:
• Manufacturer info
• Discover identity
• Unchunked extended messages
• Defaults profiles are:
• PDO1: 5V - 1.5A
• PDO2: 9V - 1.5A
#4 - MB1303_SNK_VDM
overview
15

• This is the typical framework for Dual Role Port applications, such as Power bank
applications.
• By default, the port connects as a SINK when application is not supplied (dead
Battery mode), and supports both power and data role swap (PR_SWAP and
DR_SWAP) and EMCA.
• Defaults profiles are:
• Source:
• PDO1: 5V - 3A
• Sink:
• PDO1: 5V - 1.5A
• PDO2: 9V - 1.5A
#5 - MB1303_DRP_ONLY
overview
16
NB:
Optional 9V and 12V SOURCE profiles are available using _GPIO_FOR_SRC switch
and appropriate hardware (see here)

• This is the typical framework for Dual Role Port supporting alternate mode in UFP.
• By default, the port connects as a SINK when application is not supplied (dead Battery
mode), and supports both power and data role swaps (PR_SWAP and DR_SWAP). It
implements USB PD power negotiation for both SOURCE (including EMCA support) and
SINK, and supports optional PD3 features like:
• Manufacturer info, Discover identity, Unchunked extended messages
• Alternate mode:
• Enters DP mode
• Enumerate as Billboard if needed
• Defaults profiles are:
• Source:
• PDO1: 5V – 3A
• Sink:
• PDO1: 5V 1.5A
• PDO2: 9V 1.5A
#6 - MB1303_DRP_VDM
overview
17
NB:
Optional 9V and 12V SOURCE profiles are available
using _GPIO_FOR_SRC switch and appropriate
hardware (see here)

• This is the typical framework for dual port applications with Dual Role Port capability
supporting extended messages and UFP.
• It can be used typically for dual DRP applications, sourcing devices or sinking host
• By default, each port connects as a SINK when application is not supplied (dead Battery
mode), and supports both power and data role swaps (PR_SWAP and DR_SWAP). It
implements USB HID device for port #0, and USB PD power negotiation for both
SOURCE (including EMCA support) and SINK, and supports optional PD3 features.
• Defaults profiles are:
• Source:
• PDO1: 5V – 3A
• Sink:
• PDO1: 5V 1.5A
• PDO2: 9V 1.5A
#7 - MB1303_DRP_2ports
overview
18
NB:
Optional 9V and 12V SOURCE profiles are available
using _GPIO_FOR_SRC switch and appropriate
hardware (see here)

• This is the typical framework for single port application with Dual Role Port capability
supporting extended messages and UFP.
• It can be used typically for applications acting as a power SOURCE and as a
PERIPHERAL for USB data.
• At the connection, the port connects either as a SINK or as a SOURCE (depending on
counterpart device role). When contract is established as aSINK (so by default UFP), it
requests a POWER_SWAP to become a SOURCE/UFP (HID). At the opposite, when
contract is established as a SOURCE (so by default DFP), it requests a DATA_SWAP to
become a SOURCE/UFP (HID)
• Defaults profiles are:
• Source:
• PDO1: 5V – 3A
• Sink:
• PDO1: 5V 1.5A
• PDO2: 9V 1.5A
#8 - MB1303_DRP_SRCING_DEVICE
overview
19
NB:
Optional 9V and 12V SOURCE profiles are available
using _GPIO_FOR_SRC switch and appropriate
hardware (see here)