Skip to main content
Graduate
October 14, 2025
Solved

Using USB-PD SRC and USB-CDC Device together

  • October 14, 2025
  • 4 replies
  • 479 views

Hi @FBL 

I am working on a similar project like This one (USB CDC ACM device with Power Delivery in Source mode using USBX in standalone mode, FreeRTOS and USBPD with a TCPP02). The STM32 used is the H573I.

I have found some code to add in the function USBPD_DPM_Notification() in usbpd_dpm_user.c (solution you gave).

But in my code, the functions called are undefined because the file usbpd_usb_if.c is not generated. What I am missing?

    This topic has been closed for replies.
    Best answer by FBL

    Hi @Aristy 

    You should start as SRC host, then switch to device mode! Check this KB article to use FreeRTOS with USBX: How to add USBX to an STM32 FreeRTOS™ project. It should be helpful ! 

    Also, check stm32h5-eclipse-coremw-apps/Projects/NUCLEO-H563ZI/Applications/USBX/Ux_Device_HID at main · STMicroelectronics/stm32h5-eclipse-coremw-apps

    Internal ticket is submitted to MX team to enhance support of FreeRTOS over CubeMX (220422).

    4 replies

    Technical Moderator
    October 14, 2025

    Hi @Aristy 

    Would you attach your IOC file?

    AristyAuthor
    Graduate
    October 14, 2025

    Hi @FBL,

    Yes, the file is attached.

    Note that since I use FreeRTOS, I can't define the USBX stack in middleware via STM32CubeMX. To counter this issue, I have created another project to define the USBX stack without any RTOS (in standalone mode) and generate the code, then, copy / path the code in my project which has FreeRTOS activated.

    My problem is, the USB communication woks very well when the Power Delivery is not defined and the Power Delivery is works when the USB communication is not defined. However, when I try both solution at the same time, only Power Delivery works and I don't have any communication.

    To debug this, I have connected the USB line between the STM32 and a laptop (on linux) and use the command "dmesg" to get the kernel log :

    [12883.502038] ucsi_acpi USBC000:00: unknown error 0
    [12883.502043] ucsi_acpi USBC000:00: UCSI_GET_PDOS failed (-5)

    Note that I do this in order to send data to a smartphone while charging it.

    Thank you for your help.

     

    AristyAuthor
    Graduate
    October 20, 2025

    Hi @FBL,

    I have some update about that question, 

    I have found out why there is no usbpd_usb_if.c/.h files generated because we need to activate "Enable USB Support" inside the USBPD configuration tab:

    Aristy_0-1760963491463.png

    When deactivating FreeRTOS and enabling AzureOS and USB Support, I can find the files. But of course, when you activate AzureOs, USBX isn't in Stand-alone mode anymore. In the generated files (usbpd_usb_if.c) we can find some related code :

    tx_queue_send(&ux_app_MsgQueue_UCPD, &USB_Host_State_Msg, TX_WAIT_FOREVER) != TX_SUCCESS

    Which use a queue "ux_app_MsgQueue_UCPD" defined in the USBX stack newly re-generated. And is only usable with AzureOs.

    When debugging, the notification goes well inside the functions : "USBPD_USBIF_HostStart()" and "USBPD_USBIF_HostStop()". Where the code with the queue are.

    I am tying to find an alternative to the queue that's works with usbx in standalone mode but I didn't find any source code/example or other question on the topic...

    Any help is greatly appreciated since I don't have any new ideas to resolve this problem.

    Regards,

     

    Visitor II
    October 30, 2025

    Hi @Aristy,

    Did the USB Power Delivery and USBX USB communications work at the same time while you were using the Azure RTOS? I'm also using an H5 micro-controller and am seeing a very similar issue to what you're describing, except I'm using the Azure RTOS/ThreadX middleware instead of FreeRTOS.

     

     

    AristyAuthor
    Graduate
    November 3, 2025

    Hi @LHebert,

    I haven't tried it from scratch but there is an example that works using Azure RTOS with Dual data role and dual power roles.

    The project example name is USBPD_DRP_UX_DRD_HID and works fine with the H5 DevKit.

    FBLAnswer
    Technical Moderator
    October 24, 2025

    Hi @Aristy 

    You should start as SRC host, then switch to device mode! Check this KB article to use FreeRTOS with USBX: How to add USBX to an STM32 FreeRTOS™ project. It should be helpful ! 

    Also, check stm32h5-eclipse-coremw-apps/Projects/NUCLEO-H563ZI/Applications/USBX/Ux_Device_HID at main · STMicroelectronics/stm32h5-eclipse-coremw-apps

    Internal ticket is submitted to MX team to enhance support of FreeRTOS over CubeMX (220422).

    AristyAuthor
    Graduate
    November 3, 2025

    Hi @FBL 

    Thank you for your answer, I will try to do it.