2021-05-28 11:35 AM
If it does support EMC, how can I read some ID information from the cable?
Solved! Go to Solution.
2021-05-30 11:00 PM
Dear @ADoro.2
I confirm than STM USB-PD core stack supports EMC cable.
Please find the associated Message Sequence Chart:
The option '_VCONN_SUPPORT' should be enabled in your workspace.
With this switch, "DPM_Params[PortNum].VconnStatus" variable is set to USBPD_TRUE and will be used to activate VCONN and start VDM negotiation on EMC cable (VDM Discovery message).
You could refer to demonstration code on STM32G081B-EVAL board to see where this flag is enabled:
This activation is necessary to enable VCONN on the CC line used to power on the cable like this
USBPD_StatusTypeDef USBPD_PWR_IF_VBUSEnable(uint8_t PortNum)
{
/* USER CODE BEGIN USBPD_PWR_IF_VBUSEnable */
USBPD_StatusTypeDef _status = USBPD_ERROR;
/* check for valid port */
if (USBPD_PORT_IsValid(PortNum))
{
POWER_IF_TRACE(PortNum, "EN_VBUS", 7);
/* Set the new state */
#ifdef _TRACE
char str[20];
sprintf(str, "CC:%d VCONN:%d", DPM_Params[PortNum].VconnCCIs, DPM_Params[PortNum].VconnStatus);
POWER_IF_TRACE(PortNum, (uint8_t*)str, strlen(str));
#endif /* _TRACE */
_status = (USBPD_StatusTypeDef)HW_IF_PWR_Enable(PortNum, USBPD_ENABLE, DPM_Params[PortNum].VconnCCIs, DPM_Params[PortNum].VconnStatus, USBPD_PORTPOWERROLE_SRC);
}
return _status;
/* USER CODE END USBPD_PWR_IF_VBUSEnable */
}
And
USBPD_StatusTypeDef HW_IF_PWR_Enable(uint8_t PortNum, USBPD_FunctionalState state, CCxPin_TypeDef Cc, uint32_t VconnState, USBPD_PortPowerRole_TypeDef role)
{
UNUSED(role);
int32_t status;
if (USBPD_ENABLE == state)
{
#if defined(_VCONN_SUPPORT)
if (USBPD_TRUE == VconnState)
{
POWER_DEBUG((uint8_t *)"VCONN ON", 8);
(void)BSP_USBPD_PWR_VCONNOn(PortNum, Cc);
}
#endif /* _VCONN_SUPPORT */
Cable ID information will be retrieved thanks to the callback in usbpd_vdm_user code:
static void USBPD_VDM_InformIdentity(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_DiscoveryIdentity_TypeDef *pIdentity)
{
/* USER CODE BEGIN USBPD_VDM_InformIdentity */
switch(CommandStatus)
{
case SVDM_RESPONDER_ACK :
if (USBPD_SOPTYPE_SOP1 == SOPType)
{
uint8_t* disco_ident;
disco_ident = (uint8_t*)&DPM_Ports[PortNum].VDM_DiscoCableIdentify;
memcpy(disco_ident, (uint8_t*)pIdentity, sizeof(USBPD_DiscoveryIdentity_TypeDef));
DEMO_SetCableInfo(PortNum, pIdentity);
if (NULL != DPM_GUI_SaveInfo)
{
DPM_GUI_SaveInfo(PortNum, VDM_CABLE_INFO, (uint8_t*)pIdentity, sizeof(USBPD_DiscoveryIdentity_TypeDef));
}
}
Regards,
Yohann
2021-05-30 11:00 PM
Dear @ADoro.2
I confirm than STM USB-PD core stack supports EMC cable.
Please find the associated Message Sequence Chart:
The option '_VCONN_SUPPORT' should be enabled in your workspace.
With this switch, "DPM_Params[PortNum].VconnStatus" variable is set to USBPD_TRUE and will be used to activate VCONN and start VDM negotiation on EMC cable (VDM Discovery message).
You could refer to demonstration code on STM32G081B-EVAL board to see where this flag is enabled:
This activation is necessary to enable VCONN on the CC line used to power on the cable like this
USBPD_StatusTypeDef USBPD_PWR_IF_VBUSEnable(uint8_t PortNum)
{
/* USER CODE BEGIN USBPD_PWR_IF_VBUSEnable */
USBPD_StatusTypeDef _status = USBPD_ERROR;
/* check for valid port */
if (USBPD_PORT_IsValid(PortNum))
{
POWER_IF_TRACE(PortNum, "EN_VBUS", 7);
/* Set the new state */
#ifdef _TRACE
char str[20];
sprintf(str, "CC:%d VCONN:%d", DPM_Params[PortNum].VconnCCIs, DPM_Params[PortNum].VconnStatus);
POWER_IF_TRACE(PortNum, (uint8_t*)str, strlen(str));
#endif /* _TRACE */
_status = (USBPD_StatusTypeDef)HW_IF_PWR_Enable(PortNum, USBPD_ENABLE, DPM_Params[PortNum].VconnCCIs, DPM_Params[PortNum].VconnStatus, USBPD_PORTPOWERROLE_SRC);
}
return _status;
/* USER CODE END USBPD_PWR_IF_VBUSEnable */
}
And
USBPD_StatusTypeDef HW_IF_PWR_Enable(uint8_t PortNum, USBPD_FunctionalState state, CCxPin_TypeDef Cc, uint32_t VconnState, USBPD_PortPowerRole_TypeDef role)
{
UNUSED(role);
int32_t status;
if (USBPD_ENABLE == state)
{
#if defined(_VCONN_SUPPORT)
if (USBPD_TRUE == VconnState)
{
POWER_DEBUG((uint8_t *)"VCONN ON", 8);
(void)BSP_USBPD_PWR_VCONNOn(PortNum, Cc);
}
#endif /* _VCONN_SUPPORT */
Cable ID information will be retrieved thanks to the callback in usbpd_vdm_user code:
static void USBPD_VDM_InformIdentity(uint8_t PortNum, USBPD_SOPType_TypeDef SOPType, USBPD_VDM_CommandType_Typedef CommandStatus, USBPD_DiscoveryIdentity_TypeDef *pIdentity)
{
/* USER CODE BEGIN USBPD_VDM_InformIdentity */
switch(CommandStatus)
{
case SVDM_RESPONDER_ACK :
if (USBPD_SOPTYPE_SOP1 == SOPType)
{
uint8_t* disco_ident;
disco_ident = (uint8_t*)&DPM_Ports[PortNum].VDM_DiscoCableIdentify;
memcpy(disco_ident, (uint8_t*)pIdentity, sizeof(USBPD_DiscoveryIdentity_TypeDef));
DEMO_SetCableInfo(PortNum, pIdentity);
if (NULL != DPM_GUI_SaveInfo)
{
DPM_GUI_SaveInfo(PortNum, VDM_CABLE_INFO, (uint8_t*)pIdentity, sizeof(USBPD_DiscoveryIdentity_TypeDef));
}
}
Regards,
Yohann
2021-05-31 11:43 PM
Thank you, @Yohann M.
I'll try to figure it out.
2021-06-10 03:44 AM
Everything works well.
But I have a couple more questions.
2021-06-10 05:29 AM
Great to see I helped you to fix your issue...
No, it is not possible to detect an EMC in Sink mode. Solution is to request a VCONN_SWAP to be able to start a VDM negotiation with the cable.
Please find a example of Message Sequence Chart:
Regards,
Yohann
2021-06-10 05:45 AM
And is it possible to identify EMC if it is only connected to the Source, and nothing is connected to the other end of the cable?
2021-06-10 06:26 AM
No this is in the Type-C specification... VCONN is turn on only in Attached.SRC state and to enter in this state, Source should detect a sink.
2021-06-10 06:29 AM
Thanks a lot for the answers!