cancel
Showing results for 
Search instead for 
Did you mean: 

DRD Settings for NUCLEO-G071RB and X-NUCLEO-DRP1M1

forst
Associate III

I would like to use NUCLEO-G071RB and X-NUCLEO-DRP1M1 to Source,UFP my USB devices

When the USB device side is set as Source, the role of data is DFP.

I used the DR SWAP command to change from DFP to UFP.

But there was no sample code in x-cube-tcpp_v4.0.0.

I thought the following APIs would be applicable

-- USBPD_StatusTypeDef USBPD_DPM_EvaluateDataRoleSwap(uint8_t PortNum)

How should I use it?

Best Regards

1 REPLY 1
Nicolas P.
ST Employee

Hello @forst​ 

The below function can be used :

USBPD_StatusTypeDef USBPD_DPM_RequestDataRoleSwap(uint8_t PortNum)
{
  USBPD_StatusTypeDef _status = USBPD_PE_Request_CtrlMessage(PortNum, USBPD_CONTROLMSG_DR_SWAP, USBPD_SOPTYPE_SOP);
  DPM_USER_ERROR_TRACE(PortNum, _status, "DRS not accepted by the stack");
  return _status;
}

A similar use case (automatic power role swap) is described in our wiki.

Does it help ?

And a data role swap call example is available in the STM32G0 discovery analyser demonstration firmware here on github.

If you have a look on the wiki, have a look also at the debug tool, and the stack user manual.

Regards,

Nicolas