2022-11-30 04:39 PM
I am trying to build an application with a SNK and DRP usbc port, using a USBPDM1 and a DRP1M1 with a nucleo g071rb
I have successfully run the DRP example application, but when I try and add the functionality to my sink application stm32cubemonitor-ucpd stops seeing the board.
Specifically when adding in the drp example code:
// (in usbpd_dpm_user.c)
USBPD_StatusTypeDef USBPD_DPM_UserInit(void)
{
/* USER CODE BEGIN USBPD_DPM_UserInit */
/* PWR SET UP */
if(USBPD_OK != USBPD_PWR_IF_Init())
{
return USBPD_ERROR;
}
#if defined(_RTOS)
#if (osCMSIS < 0x20000U)
osMessageQDef(MsgBox, DPM_BOX_MESSAGES_MAX, uint32_t);
DPMMsgBox = osMessageCreate(osMessageQ(MsgBox), NULL);
if(NULL == osThreadCreate(osThread(DPM), &DPMMsgBox))
#else
DPMMsgBox = osMessageQueueNew (DPM_BOX_MESSAGES_MAX, sizeof(uint32_t), NULL);
if (NULL == osThreadNew(USBPD_DPM_UserExecute, &DPMMsgBox, &DPM_Thread_Atrr))
#endif /* osCMSIS < 0x20000U */
{
return USBPD_ERROR;
}
#endif /* _RTOS */
return USBPD_OK;
/* USER CODE END USBPD_DPM_UserInit */
}
Because osMessageGet seems to have changed for cmsis2
I changed the USBPD_DPM_UserExecute function to use the new "osMessageQueueGet" call
#if (osCMSIS < 0x20000U)
void USBPD_DPM_UserExecute(void const *argument)
#else
void USBPD_DPM_UserExecute(void *argument)
#endif /* osCMSIS < 0x20000U */
{
/* USER CODE BEGIN USBPD_DPM_UserExecute */
#if defined(_RTOS)
/* User code implementation */
uint32_t _timing = osWaitForever;
osMessageQId queue = *(osMessageQId *)argument;
osEvent msg;
osStatus_t status;
do
{
status = osMessageQueueGet(queue, &msg, NULL, _timing);
switch (((DPM_USER_EVENT)msg.value.v & 0xF))
{
case DPM_USER_EVENT_TIMER:
{
break;
}
default:
break;
}
_timing = CheckDPMTimers();
}
while(1);
#endif /* _RTOS */
/* USER CODE END USBPD_DPM_UserExecute */
}
other then that and the required defs in the same file. I cant find any more changes that would be needed to get the tracer to run properly
I'm curious if I have missed anything required?
2022-12-12 02:48 AM
Hello @Community member
When you say that "UCPD Tracer stops seeing the board", have you tested to open the COM port like described in the Wiki ?
Perhaps the problem is that the GUI_INTERFACE that should respond to the UCPD monitor is not called ?
Do you call :
GUI_Init(BSP_GetBoardName, BSP_GetBoardID, HW_IF_PWR_GetVoltage, HW_IF_PWR_GetCurrent) ?
regards,
Nicolas
2022-12-15 07:49 PM
Thanks @Nicolas P
When I build and run the DRP example as is the board shows up with one port, so it looks like it is open. also when I build the SNK example from the wiki the board shows up as well.
GUI_Init is called
both the DRP example and https://github.com/STMicroelectronics/STM32CubeG0/blob/master/Projects/STM32G081B-EVAL/Demonstrations/DemoUCPD
seem to use the same method for the USBPD_DPM_UserInit and USBPD_DPM_UserExecute functions, I am probably missing some code, but I just cant seem to locate it
2022-12-16 11:44 AM
Found it, I was not properly initialling USBPD_PWR_IF_Init, causing USBPD_DPM_UserInit to return an error, d'oh
follow up question, with it working under one sink port, when adding a second port or switching to DRP, it fails again, it is probably me just missing some initialization code, but if you can think of any areas that could be causing it that would a help a ton. (I am new to the UCPD system)
strangely enough, with out the osMessageQ code in the USBPD_DPM_UserInit and USBPD_DPM_UserExecute functions and CMSIS_V2 a SNK and DRP work, but under CMSIS_V1 they fail to show up in UCPD-monitor