cancel
Showing results for 
Search instead for 
Did you mean: 

Are the USBPD_PE_Request_*() and USBPD_CAD_PortEnable() functions of the USBPD library thread-safe?

ChristophR
Associate III

Hi,

Am I allowed to call the USBPD_PE_Request_CtrlMessage(), USBPD_PE_Request_HardReset(), USBPD_CAD_PortEnable() and others from different threads?

I want to request data role swap, power role swap and hard resets from my interface thread.

Thanks!

BR, Christoph

1 ACCEPTED SOLUTION

Accepted Solutions
Guenael Cadier
ST Employee

Dear @Christoph Rüdisser​ 

I would answer Yes : requests could be sent to the USBPD Stack thanks to calls of the API as USBPD_PE_Request_***(). Requests will be handled by the stack assuming current state allows it.

They could be initiated from a dedicated thread.

You could have a look at the UCPD demonstration code, available in STM32CubeG0 firmware package, that implements a USBPD demonstration. In this demo, once Explicit Contract is established, user could select some actions (requests to be sent to distant port). For example user could trigger a Data Role Swap procedure (DR swap request to be sent to attached device).

In this demo, all calls to USBPD_PE_Request_CtrlMessage() API are done from a Demo dedicated thread.

Demo code available here.

In demo_application.c, some examples of USBPD_PE_Request_CtrlMessage() calls are provided.

Regards

Guenael

View solution in original post

2 REPLIES 2
Guenael Cadier
ST Employee

Dear @Christoph Rüdisser​ 

I would answer Yes : requests could be sent to the USBPD Stack thanks to calls of the API as USBPD_PE_Request_***(). Requests will be handled by the stack assuming current state allows it.

They could be initiated from a dedicated thread.

You could have a look at the UCPD demonstration code, available in STM32CubeG0 firmware package, that implements a USBPD demonstration. In this demo, once Explicit Contract is established, user could select some actions (requests to be sent to distant port). For example user could trigger a Data Role Swap procedure (DR swap request to be sent to attached device).

In this demo, all calls to USBPD_PE_Request_CtrlMessage() API are done from a Demo dedicated thread.

Demo code available here.

In demo_application.c, some examples of USBPD_PE_Request_CtrlMessage() calls are provided.

Regards

Guenael

Thanks!