cancel
Showing results for 
Search instead for 
Did you mean: 

What is the correct way to disable and enable the USB-C PD stack during operation?

ChristophR
Associate III

Hi,

I want to enable or disable the USB-C PD stack of my DRP device during operation. What is the right way?

I tried this for disabling:

USBPD_CAD_PortEnable(0, USBPD_CAD_DISABLE);
USBPD_PE_Request_HardReset(0);

And I tried to enable again afterwards without success:

USBPD_CAD_PortEnable(0, USBPD_CAD_ENABLE);

I'm using:

- FW pack STM32Cube_FW_G0_V1.5.1

- USBPD core library V4.0.0

- USBPD device library V3.3.1

Thanks!

BR, Christoph

8 REPLIES 8
Guenael Cadier
ST Employee

Hello @Christoph Rüdisser​ 

Your intention is to be able to fully switch on and off the USBPD feature of your device ?

Could this happen while an Explicit Contract is ongoing (device is "Attached" to another PD port) or would it be disabled only when in Detached state ?

When disabling the USBPD feature, how is your device expected to behave when something is connected ? Some default resistors are to be presented ?

Guenael

ChristophR
Associate III

Hi @Guenael Cadier​ 

Yes, we want to switch the USBPD feature of our device temporarily off e.g. before doing a FW upgrade or when our supply monitoring shows an error. This could happen at any time in source or sink operation (our device is a DRP device), also while a explicit contract is ongoing.

Expected behavior: I think our device should switch to the "Disabled State" (4.5.2.2.1, USB Type-C Cable and Connector Specification, Release 2.0, August 2019). I.e. disable VBUS, remove all terminations from CC pins. Very similar to the ErrorRecovery state. How could I achieve that?

Thanks,

Christoph

ChristophR
Associate III

Hi @Guenael Cadier​ 

could you please help me with the questions above?

Thanks,

Christoph

Nicolas P.
ST Employee

Hello @Christoph Rüdisser​ 

You are right there is actually no way to disable the stack.

Have you tried modifying CAD ?

We could perhaps test hacking the variable DPM_Params[PortNum].PE_IsConnected ?

But it hasn't been validated on our side.

Does your IC protection isolate the CC lines, and do you have some ways to be informed about that ?

Because our PE thread is started upon attach information raised by CAD.

Regards,

Nicolas

ChristophR
Associate III

Hi @Nicolas P​ 

No, I haven't tried to modify CAD. I didn't want to edit anything outside the /* USER CODE */ sections, so that I'm always able to update the code using CubeMX.

It would be great if you could try to find and validate a solution on your side. Goal should be what I have written above: I think our device should switch to the "Disabled State" (4.5.2.2.1, USB Type-C Cable and Connector Specification, Release 2.0, August 2019). I.e. disable VBUS, remove all terminations from CC pins. Very similar to the ErrorRecovery state. 

Regarding our protection IC: yes, it isolates the CC signals, and we get informed about errors. More information is here.

BR,

Christoph

Hi @Christoph Rüdisser​ 

Understood you would also want to stop the stack for a firmware upgrade for example.

You will need to edit the file out of the tags /* USER CODE */, because you won't have fast update of this CAD code through CubeMX.

You cannot use this ERRORRECOVERY state because it has a timeout to get out of it.

What about creating a new state (USBPD_CAD_STATE_DISABLED ?) in the UCPD device (function CAD_StateMachine in usbpd_cad_hw_if.c), similar to the state USBPD_CAD_STATE_ERRORRECOVERY ?

For you, what would be the conditions to start again the stack ? Would it be controlled by application, or by CAD ?

Regards,

Nicolas

Hi @Nicolas P​ 

yes, that's true, we would like to disable the USB-C functionality also when doing firmware upgrades. But also in case of persistent errors detected by the the protection IC or from other hardware (e.g. overheated DCDC, too low supply voltage, etc.).

The condition to start again is when the firmware upgrade is complete or the error has vanished for some time. The stack should then only leave the disabled state when commanded by our application (not CAD).

I'll have a look at the CAD_StateMachine, but this will take some time, since I have to work on something else at the moment.

It would be nice to here from you, if you could find a good solution.

Thanks,

Christoph

Nicolas P.
ST Employee

Hello @Christoph Rüdisser​ 

To come back to the original question.

What you have done at the beginning of this thread is right :

USBPD_CAD_PortEnable(0, USBPD_CAD_DISABLE);

But to be valid, you need to be in detached state.

So the solution for you, when you detect a fault, is to go in error recovery thanks to the function USBPD_DPM_EnterErrorRecovery. This will trigger a detach.

And once the detach is captured by your application, then you can disable CAD as you saw above.

Regards,

Nicolas