Hello @nikolai2111 ,
Thank you for the details, I understand your problem.
In your case if you look at the very end of the trace where the message is rejected, you will see "ADVICE: update USBPD_DPM_RequestMessageRequest", which means that you are trying to use a function which is not implemented yet on this simple example. This is user code that you can make according to your needs.
If you search for the actual USBPD_DPM_RequestMessageRequest function, you will find a short explanation on what you could do with your implementation.
As a quick example to just make what you were trying to do on STM32CubeMonitorUCPD work, you can try this code:
USBPD_StatusTypeDef USBPD_DPM_RequestMessageRequest(uint8_t PortNum, uint8_t IndexSrcPDO, uint16_t RequestedVoltage)
{
USBPD_StatusTypeDef _status = USBPD_ERROR;
/* USER CODE BEGIN USBPD_DPM_RequestMessageRequest */
uint32_t voltage, allowablepower;
USBPD_SNKRDO_TypeDef rdo;
USBPD_PDO_TypeDef pdo;
USBPD_CORE_PDO_Type_TypeDef pdo_object;
USBPD_USER_SettingsTypeDef *puser = (USBPD_USER_SettingsTypeDef *)&DPM_USER_Settings[PortNum];
USBPD_DPM_SNKPowerRequestDetailsTypeDef request_details;
rdo.d32 = 0;
/* selected SRC PDO */
pdo.d32 = DPM_Ports[PortNum].DPM_ListOfRcvSRCPDO[(IndexSrcPDO - 1)];
voltage = RequestedVoltage;
allowablepower = (puser->DPM_SNKRequestedPower.MaxOperatingCurrentInmAunits * RequestedVoltage) / 1000U;
if (USBPD_TRUE == USER_SERV_SNK_EvaluateMatchWithSRCPDO(PortNum, pdo.d32, &voltage, &allowablepower))
{
/* Check that voltage has been correctly selected */
if (RequestedVoltage == voltage)
{
request_details.RequestedVoltageInmVunits = RequestedVoltage;
request_details.OperatingCurrentInmAunits = (1000U * allowablepower)/RequestedVoltage;
request_details.MaxOperatingCurrentInmAunits = puser->DPM_SNKRequestedPower.MaxOperatingCurrentInmAunits;
request_details.MaxOperatingPowerInmWunits = puser->DPM_SNKRequestedPower.MaxOperatingPowerInmWunits;
request_details.OperatingPowerInmWunits = puser->DPM_SNKRequestedPower.OperatingPowerInmWunits;
USER_SERV_SNK_BuildRDOfromSelectedPDO(PortNum, (IndexSrcPDO - 1), &request_details, &rdo, &pdo_object);
_status = USBPD_PE_Send_Request(PortNum, rdo.d32, pdo_object);
}
}
/* USER CODE END USBPD_DPM_RequestMessageRequest */
DPM_USER_ERROR_TRACE(PortNum, _status, "REQUEST not accepted by the stack");
return _status;
}
Make sure you also export the USER_SERV_SNK_BuildRDOfromSelectedPDO and USER_SERV_SNK_EvaluateMatchWithSRCPDO functions in usbpd_user_services.h (meaning removing "static"), as you will now be calling them from a different file.
As a generic rule, where you find "ADVICE" in the trace is where you should add some code in order to implement the functionalities you need.
Hope this solves your problem,
Best regards