cancel
Showing results for 
Search instead for 
Did you mean: 

USB-PD default role initialize & change

H V N D
Associate III

Hi supporter,

I have one question: I want to change Port Role when no cable connect, can I do it?

my behavior:

  1. Init usbpd with default role is Sink
  2. when my application running, I see my adapter plugin, I want change my port to sink

Can I do that?

6 REPLIES 6
Nicolas P.
ST Employee

Hello @H V N D​ ,

I'm not sure to fully understand.

If you have DRP, and nothing is connected, your port Role has to toggle.

You have a DRP, and in case you are connected as a source, you want to switch to sink role ?

In this case you have to request a power role swap.

Sequence is indicated on our wiki.

Is that what you are looking for ?

Nicolas

My problem is:

  • when I power my STM32, I don't know the power supply to STM32 is from Adapter or Vbus of Phone ( because ADC init and convert slow, when app task run I can know )
  • If I want my Port is source, I must wait cable connect and change to source by PowerRoleSwap ( because default is Sink )

Can I change my port is source even no cable connect?

0693W00000D0uVqQAJ.png

You can change role when you are not yet attached; that's the purpose of role toggling when you are DRP (dual role power) capable.

And when you are attached, you can request a role change by sending a message, like mentioned in previous message on the wiki.

Using the UCPD in our microcontrollers, the role toggling has to be done by the application : it is not automatically done by hardware.

Can you precise your question ?

Is your device DRP capable ? Or source only ?

The variable DPM_Param[portnum].PE_PowerRole (structure USBPD_ParamsTypeDef), defined in the file usbpd_def.h, contains the current role information. So you can base you application on this information.

Can you share a .cpd file, generated thanks to STM32CubeMonitor-UCPD ?

This will show dynamic execution, and confirm the role toggling. Very useful !

The Wiki to generate the traces is here.

I have a similar situation. At certain times my device is not capable of providing a charge so it should be SNK only. When it can provide a charge it should be DRP toggling. But this driver doesn't allow that. You must pick a mode and stick with it.

1. You are always a SNK.

2. You are always a SRC.

3. You are always DRP (toggling).