Skip to main content
Visitor II
June 23, 2022
Solved

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

  • June 23, 2022
  • 1 reply
  • 1423 views

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

    This topic has been closed for replies.
    Best answer by Guenael Cadier

    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

    1 reply

    ST Employee
    June 24, 2022

    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

    Visitor II
    June 27, 2022

    Thanks!