cancel
Showing results for 
Search instead for 
Did you mean: 

Does the latest STM USB-PD Core stack support PPS?

FZhou.1
Associate II

It is not very clear to me if the latest STM USB-PD core stack support PPS, does anyone have the answer?

10 REPLIES 10
Yohann M.
ST Employee

Dear @FZhou.1​ 

We confirm that our stack support PPS.

Regards,

Yohann

FZhou.1
Associate II

Dear Yohann,

Thanks for the confirmation. I tried PPS and PPS source mode is working for me now.

For PPS sink mode implementation, is this the right sequence?

1) Start PD contract by requesting source capability

2)If APO from source is available, then send a power request according to APDO .

3) Start USBPD_DPM_RequestGetPPS_Status

4)Check PPS_Status.

Thanks & Regards,

Alex

Yohann M.
ST Employee

Dear Alex,

Your sequence is correct. When APDO is selected, you should see automatic requests from sink every 9/10 secs.

GET_PPS_STATUS is just used to have additional information from the source port partner.

Regards,

Yohann

FZhou.1
Associate II

Dear Yohann,

Does sink need to send both power request and GET_PPS_STATUS every 9/10 seconds, or just send GET_PPS_STATUS message every 9/10 seconds unless a power level change?

Thanks,

Alex

Yohann M.
ST Employee

Dear Alex,

No only request is automatically sent by the stack (this is mandatory by the specification, refer to definition of tPPSRequest timer, "Request Message requesting a PPS APDO is sent periodically as a keep alive mechanism").

It is up to application to send a GET_PPS_STATUS message. Yes you can trigger it through the API 'USBPD_DPM_RequestGetPPS_Status'.

You should be informed by the PPS_STATUS through the notification 'USBPD_DPM_SetDataInfo(USBPD_CORE_PPS_STATUS)'.

Please find a Message Sequence Chart linked to this scenario:

0693W000000X5sEQAS.png

Regards,

Yohann

FZhou.1
Associate II

Yohann,

Thanks for your information. I tried the PPS sink mode, it works exactly as you described.

Best Regards,

Alex

FZhou.1
Associate II

Hi Dear Yohann,

I have a couple of more questions about PPS source mode:

1)I need to check if TCPC is under current limit mode so that I can update OMF flag in PPS_Status message. Which routine should I check current limit status, should it be in function USBPD_DPM_UserExecute?

2)I also need to detect vPpsShutdown and send hard_reset when the event happens, should this detection and sending hard_reset be implemented in function USBPD_DPM_UserExecute? Does PE do anything related to vPpsShutdown?

Thanks & Regards,

Alex

Dear Alex,

1) yes, you could add your checks in USBPD_DPM_UserExecute code. We implemented an example in our demonstraction code available for 'STM32G081B-EVAL' board (https://github.com/STMicroelectronics/STM32CubeG0/blob/master/Projects/STM32G081B-EVAL/Demonstrations/DemoUCPD/Src/usbpd_dpm_user.c)

In this example, we use a alert timer of 100ms to check the current limit and if this current is higher than our limits, we send alert to port partner:

/**
  * @brief  Manage the ALERT.
  * @retval none
  */
void DPM_ManageAlert(void)
{
  for(uint8_t _instance = 0; _instance < USBPD_PORT_COUNT; _instance++)
  {
    /* check if Alert timer is expired */
    if (DPM_TIMER_ENABLE_MSK == DPM_Ports[_instance].DPM_TimerAlert)
    {
      /* Restart alert timer */
      DPM_START_TIMER(_instance, DPM_TimerAlert, DPM_TIMER_ALERT);
      DPM_Ports[_instance].DPM_MeasuredCurrent = HW_IF_PWR_GetCurrent(_instance);
      if (DPM_Ports[_instance].DPM_MeasuredCurrent > 3600)
      {
        USBPD_DPM_RequestHardReset(_instance);
      }
      else
      {
        if (DPM_Ports[_instance].DPM_MeasuredCurrent > 3400)
        {
          if (0 == (DPM_Ports[_instance].DPM_SendAlert.b.TypeAlert & USBPD_ADO_TYPE_ALERT_OCP))
          {
            USBPD_ADO_TypeDef alert = {0};
            alert.b.TypeAlert = USBPD_ADO_TYPE_ALERT_OCP;
            USBPD_DPM_RequestAlert(_instance, alert);
            DPM_Ports[_instance].DPM_SendAlert.b.TypeAlert |= alert.b.TypeAlert;
          }
        }
        else
        {
          /* Reset of the OCP bit */
          DPM_Ports[_instance].DPM_SendAlert.b.TypeAlert &= ~USBPD_ADO_TYPE_ALERT_OCP;
          /*
            The Operating Condition Change bit Shall be set when a Source or Sink detects its
            Operating Condition enters or exits either the <warning> or <over temperature> temperature states.
            The Operating Condition Change bit Shall be set when the Source operating in the
            Programmable Power Supply mode detects it has changed its operating condition between Constant Voltage (CV)
            and Current Limit (CL).
          */
          USBPD_PDO_TypeDef pdo;
          pdo.d32 = PWR_Port_PDO_Storage[_instance].SourcePDO.ListOfPDO[DPM_Ports[_instance].DPM_RDOPosition];
          if (USBPD_CORE_PDO_TYPE_APDO == pdo.GenericPDO.PowerObject)
          {
            if (DPM_Ports[_instance].DPM_MeasuredCurrent > PWR_DECODE_50MA(pdo.SRCSNKAPDO.MaxCurrentIn50mAunits))
            {
              if (0 == (DPM_Ports[_instance].DPM_SendAlert.b.TypeAlert & USBPD_ADO_TYPE_ALERT_OPERATING_COND))
              {
                USBPD_ADO_TypeDef alert = {0};
                alert.b.TypeAlert = USBPD_ADO_TYPE_ALERT_OPERATING_COND;
                USBPD_DPM_RequestAlert(_instance, alert);
                DPM_Ports[_instance].DPM_SendAlert.b.TypeAlert |= alert.b.TypeAlert;
              }
            }
            else
            {
              /* Reset alert bits */
              DPM_Ports[_instance].DPM_SendAlert.b.TypeAlert = 0;
            }
          }
          else
          {
            /* Reset alert bits */
            DPM_Ports[_instance].DPM_SendAlert.b.TypeAlert = 0;
          }
        }
      }
    }
  }
}

2) I confirm that  vPpsShutdown is not managed in the stack. You can also manage it in your alert function

Regards,

Yohann

FZhou.1
Associate II

Hi Yohann,

Thank you very much for the information.

By adding that code, when OCP happens at source side, what kind of Alert would be received by the port partner?

My understanding for OCP handling is as following:

1)When CL happens, OMF bit in PPSSDB would be set. The port partner would be notified through PPS_Status.

2)When vPpsShutdown happen, Source should send HardReset to its port partner.

Is this correct?, BTW, Are OMF flag setting and HardReset sending mandatory or optional ?

Thanks & Regards,

Alex