2025-03-05 10:35 PM
Hello,
I have encountered a similar problem to the one in this link .
I am also trying to use the UCPD Monitor to send message. For example, I request a new voltage from the source using the "Request Power Profile" message from the "Message Selector" , and I always get "Message rejected for this port configuration".
After some investigations ,I find out that the USBPD_PE_Send_Request() function in the USBPD_DPM_RequestMessageRequest() function is not working. It returns USBPD_OK the first time I use this function to request another fixed voltage PDO(9V),but actually it is not working. And when I use it again , it returns USBPD_BUSY. Besides, if I request the APDO, it returns USBPD_ERROR.
USBPD_StatusTypeDef USBPD_DPM_RequestMessageRequest(uint8_t PortNum, uint8_t IndexSrcPDO, uint16_t RequestedVoltage)
{
USBPD_StatusTypeDef _status = USBPD_ERROR;
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_SNKPowerRequestDetails_TypeDef 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 == USBPD_DPM_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;
DPM_SNK_BuildRDOfromSelectedPDO(PortNum, (IndexSrcPDO - 1), &request_details, &rdo, &pdo_object);
_status = USBPD_PE_Send_Request(PortNum, rdo.d32, pdo_object);
}
}
DPM_USER_DEBUG_TRACE(PortNum, "build rdo! _stauts = %d",_status);
/* USER CODE END USBPD_DPM_RequestMessageRequest */
DPM_USER_ERROR_TRACE(PortNum, _status, "REQUEST not accepted by the stack");
return _status;
}