zephyr/samples/subsys/usb_c/source
Andreas Sandberg b41853127f samples: usb_c: Rename port1 to port0 for consistency
Aliases, including usbc_port0, start counting from zero. This meant
that the DT alias is inconsistent with the port numbering in the
samples. Change the numbering scheme to start from zero to make this
consistent.

Signed-off-by: Andreas Sandberg <andreas@sandberg.uk>
2023-10-25 18:37:53 -07:00
..
boards usbc: Use a DT alias to identify USB-C port 2023-10-25 18:37:53 -07:00
src samples: usb_c: Rename port1 to port0 for consistency 2023-10-25 18:37:53 -07:00
CMakeLists.txt
README.rst doc: Migrate subsys/ code samples to new Sphinx extension 2023-09-21 09:28:31 +02:00
prj.conf
sample.yaml tests: samples: Resolve duplicates in names. 2023-05-16 06:21:25 -04:00

README.rst

.. zephyr:code-sample:: usb-c-source
   :name: Basic USB-C Source
   :relevant-api: _usbc_device_api

   Implement a USB-C Power Delivery application in the form of a USB-C Source.

Overview
********

This example demonstrates how to create a USB-C Power Delivery application
using the USB-C subsystem. The application implements a USB-C Source device.

After a USB-C Sink device is plugged into the USB-C Source device, it
negotiates with the Source device to provide 5V at 100mA, 9V at 100mA,
or 15V at 100mA and the Requested Data Object (RDO) provided by the Source
is displayed.

.. _usb-c-source-sample-requirements:

Requirements
************
The TCPC device used by the sample is specified in the devicetree
node that's compatible with ``usb-c-connector``.
The sample has been tested on ``stm32g081b_eval``.
An overlay file is provided.

Building and Running
********************

Build and flash as follows, changing ``stm32g081b_eval`` for your board:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/usb_c/source
   :board: stm32g081b_eval
   :goals: build flash
   :compact:

Connect a sink device and see console output:

Sample Output
=============

.. code-block:: console

 PRL_TX_SUSPEND
 PRL_HR_SUSPEND
 PE_SUSPEND
 UnattachedWait.SRC
 Unattached.SRC
 AttachWait.SRC
 Attached.SRC
 PE_SRC_Startup
 PRL_INIT
 PRL_HR_Wait_for_Request
 PRL_Tx_PHY_Layer_Reset
 PRL_Tx_Wait_for_Message_Request
 PE_SRC_Send_Capabilities
 PRL_Tx_Wait_for_PHY_response
 PRL_Tx_Wait_for_Message_Request
 PE_SRC_Discover
 PE_SRC_Send_Capabilities
 PRL_Tx_Wait_for_PHY_response
 RECV 1042/1
    [0]1300280a
 PRL_Tx_Wait_for_Message_Request
 PE_SRC_Negotiate_Capability
 PE_SRC_Transition_Supply
 PRL_Tx_Wait_for_PHY_response
 RECV 0441/0
 PRL_Tx_Wait_for_Message_Request
 PE_SRC_Ready
 PRL_Tx_Wait_for_PHY_response
 RECV 0641/0
 PRL_Tx_Wait_for_Message_Request
 REQUEST RDO: 1300280a
  Object Position:         1
  Giveback:                0
  Capability Mismatch:     0
  USB Comm Capable:        1
  No USB Suspend:          1
  Unchunk Ext MSG Support: 0
  Operating Current:       100 mA
  Min Operating Current:   100 mA