Problem with dynamicaly changing USB-C PDOs
Hello,
I am trying to make my own custom USB PD application on NucleoG0B1RE + SNK1M1 hardware.
I want to change dynamically the SNK PDOs in my application (it should be possible according to this post). Since I want it to be working with various Source adapters and I dont know their PDOs appriory I want to copy the SRC PDOs into SNK list (if they not exceed the sink power limits, like 100W).
So I have updated the USB_USER_SERV_StoreSRCPDO() function located in usbpd_user_services.c:
/**
* @brief Store the received source PDO
* @PAram PortNum Port number
* @PAram Ptr Pointer on the data
* @PAram Size Nb of bytes to be updated in DPM
* @retval None
*/
void USBPD_USER_SERV_StoreSRCPDO(uint8_t PortNum, uint8_t *Ptr, uint32_t Size)
{
/*!< Storage of Received Source PDO values */
if (Size <= (USBPD_MAX_NB_PDO * 4U))
{
uint8_t *rdo;
DPM_Ports[PortNum].DPM_NumberOfRcvSRCPDO = (Size / 4U);
/* Copy PDO data in DPM Handle field */
for (uint32_t index = 0; index < (Size / 4U); index++)
{
rdo = (uint8_t *)&DPM_Ports[PortNum].DPM_ListOfRcvSRCPDO[index];
(void)memcpy(rdo, (Ptr + (index * 4U)), (4U * sizeof(uint8_t)));
// Copy PDO data in SINK pdo definition
rdo = (uint8_t *)&PORT0_PDO_ListSNK[index];
(void)memcpy(rdo, (Ptr + (index * 4U)), (4U * sizeof(uint8_t)));
}
}
}
This function should just copy the SRC PDOs to SNK. I have checked the PORT0_PDO_ListCNK struct in debbuger mode and it updates correctly. Also when I open the UCPD monitor I can see the PDOs under Sink Capabilities tab located at Port Configuration. The only problem is that I am able to request only Fixed PDOs and not APDOs. If I delete one of the APDOs in UCPD monitor, reconfigure it again with same values and send it to the target APDO request suddenly works.
