cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G071RB USBPD Sink with X-NUCLEO-USBPDM1 4 Errors after code-generation following example

FLech.1
Associate

I have tried to follow this example:

https://www.st.com/resource/en/application_note/dm00663511-how-to-build-a-simple-usbpd-sink-application-with-stm32cubemx-stmicroelectronics.pdf

Sadly right after code-generation there are already 4 errors without me adding the code as instructed in the document.

In usbpd_dpm_usr.c:

USBPD_StatusTypeDef USBPD_DPM_EvaluateDataRoleSwap(uint8_t PortNum)

{

/* USER CODE BEGIN USBPD_DPM_EvaluateDataRoleSwap */

 USBPD_StatusTypeDef status = USBPD_REJECT;

 if ((USBPD_TRUE == DPM_USER_Settings[PortNum].PE_DataSwap)

   && (((USBPD_TRUE == DPM_USER_Settings[PortNum].PE_DR_Swap_To_DFP) && (USBPD_PORTDATAROLE_UFP == DPM_Params[PortNum].PE_DataRole))

    || ((USBPD_TRUE == DPM_USER_Settings[PortNum].PE_DR_Swap_To_UFP) && (USBPD_PORTDATAROLE_DFP == DPM_Params[PortNum].PE_DataRole)))))

 {

   status = USBPD_ACCEPT;

 }

 return status;

/* USER CODE END USBPD_DPM_EvaluateDataRoleSwap */

}

results in 4 Errors. Specifically PE_DR_Swap_To_DFP and PE_DR_Swap_To_UFP do not seem to be named members of USBPD_USER_SettingsTypeDef.

After some searching I found that in gui_api.h really had no such members in USBPD_USER_SettingsTypeDef.

I am using the STM32CubeIDE Version 1.4.1, and have checked for all relevant updates I could find. In addition I tried using STM32CubeMX as shown in the document and the IAR IDE, which resulted in the same problem.

I would really appreciate getting some help from the community to get this example running.

1 ACCEPTED SOLUTION

Accepted Solutions
Yohann M.
ST Employee

Hello

I imagine you enabled the GUI_INTERFACE feature. Unfortunately the structure 'USBPD_USER_SettingsTypeDef' in gui_api.h is not present in the current G0 FW package 1.3.0.

You can add manually the 2 parameters in the structure like this:

typedef struct
{
  uint32_t PE_DataSwap                                    : 1;  /*!< support data swap                                     */
  uint32_t PE_VconnSwap                                   : 1;  /*!< support VCONN swap                                    */
  uint32_t PE_DR_Swap_To_DFP                              : 1U; /*!< If supported, DR Swap to DFP can be accepted or not by the user else directly rejected */
  uint32_t PE_DR_Swap_To_UFP                              : 1U; /*!< If supported, DR Swap to UFP can be accepted or not by the user else directly rejected */
(...)
} USBPD_USER_SettingsTypeDef;

Regards,

Yohann

View solution in original post

1 REPLY 1
Yohann M.
ST Employee

Hello

I imagine you enabled the GUI_INTERFACE feature. Unfortunately the structure 'USBPD_USER_SettingsTypeDef' in gui_api.h is not present in the current G0 FW package 1.3.0.

You can add manually the 2 parameters in the structure like this:

typedef struct
{
  uint32_t PE_DataSwap                                    : 1;  /*!< support data swap                                     */
  uint32_t PE_VconnSwap                                   : 1;  /*!< support VCONN swap                                    */
  uint32_t PE_DR_Swap_To_DFP                              : 1U; /*!< If supported, DR Swap to DFP can be accepted or not by the user else directly rejected */
  uint32_t PE_DR_Swap_To_UFP                              : 1U; /*!< If supported, DR Swap to UFP can be accepted or not by the user else directly rejected */
(...)
} USBPD_USER_SettingsTypeDef;

Regards,

Yohann