2024-09-30 04:05 PM
This is very easy to reproduce:
- Create a new STM32 project using a PD-compatible MCU e.g. STM32G071CBT6
- Enable both UCPD1 and UCPD2 as dual-role ports. Add DMA for Rx/Tx for each port.
- Enable FreeRTOS
- Enable USBPD with default port configuration "Port 0: UCPD1; Port 1: UCPD2", "Full stack", TIM1
- Looking at the "Configuration" window only Port 1 is configurable (see attached)
2024-12-07 07:02 PM
Hi Mahmoud, Carl_G,
Unfortunately this is still pretty broken partly due to missing tabs but also due to ST's hardcoding port 0 as a SNK. You can easily reproduce this by the following:
- Configure UCPD1 as a SRC
- Configure UCPD2 as a DR
- Under port configuration, set Port 0 - UCPD2 (DR), Port 1 - UCPD1 (SRC). The tab for Port 0 SNK config is missing.
You might suggest ok well why don't you change the config around, so that Port 0 - UCPD1 (SRC), Port 1 - UCPD12 (DR)? Well that's broken because of the hardcoded SNK Port 0 check in .USBPD_PWR_IF_Init().
See attached.
2024-12-08 08:55 PM - edited 2024-12-08 08:57 PM
Hi Estua.1,
The "hardcoded" source that you show is considered user code and you must modify it yourself. You can tell because it is between
USBPD_StatusTypeDef USBPD_PWR_IF_Init(void)
{
/* USER CODE BEGIN USBPD_PWR_IF_Init */
return USBPD_ERROR;
/* USER CODE END USBPD_PWR_IF_Init */
}
2024-12-08 11:10 PM
re hardcoded - ah ok must have got that from an ST example a while back.
re broken PD config - The tab is still missing so this is still an open bug.
re DRP - I haven't found an ST example. If you enable CAD there's a 50/50 chance of an another DRP being detected as SNK/SRC and the role change request isn't ideal. Our work around is to disable the CAD toggle in CAD_StateMachine_DRP depending on our adaptor state. i.e. if ADAP is connected, set CAD to SRC otherwise CAD SNK. This isn't a good solution so I'm hoping someone else has a better idea.
2024-12-10 06:21 AM
I have implemented SNK only then change to SRC only when my power is available when using other hardware. In practice this did not work well. DRP followed by a transition to SRC if necessary was much less error prone. Anyway, I had moved that question to another thread almost as soon as I posted it...
2024-12-10 08:45 AM
@EStua.1 Why isn't that a good solution? How do you make it go to SRC? Or do you just let it toggle and prevent it from toggling to SNK?