Skip to main content
Visitor II
March 10, 2022
Solved

How to renegotiate the existing contract?

  • March 10, 2022
  • 2 replies
  • 1617 views

UM2552 has a paragraph 4.2.2: Send request message

A SINK must send a request message to ask for a new power level, the rest of the sequence is identical to AMS power negotiation.

How and what should I do to start the process of renegotiation? How to send USBPD_PE_Request_Ctrl/Message REQUEST?

Thanks.

    This topic has been closed for replies.
    Best answer by BMcK

    I did make it work. The problem is that the library REQUIRES at least memory for USBPD_SettingsTypeDef Settings, USBPD_ParamsTypeDef Params, but completely lacks any documentation on what they are for and how to use them.

    2 replies

    ST Employee
    March 11, 2022

    Hi @BMcK​ 

    The exact API for initiating a new REQUEST message to be sent from SNK side, is to call USBPD_PE_Send_Request() function.

    This API allows to provide arguments that will be used for building the Request message :

    /**
     * @brief This function request PE to send a request message
     * @param PortNum Index of current used port
     * @param Rdo Requested data object
     * @param PWobject Power Object
     * @retval status @ref USBPD_OK, @ref USBPD_BUSY, @ref USBPD_ERROR or @ref USBPD_FAIL
     */
    USBPD_StatusTypeDef USBPD_PE_Send_Request(uint8_t PortNum, uint32_t Rdo, USBPD_CORE_PDO_Type_TypeDef PWobject);

    Rdo parameter should contain the Requested Data Object, as built by the SNK application.

    PWObject should contains the type of received SRC PDO value that is requested (either Fixed, Variable ...).

    I tried to write a call example her :

     USBPD_StatusTypeDef _status;
     USBPD_SNKRDO_TypeDef rdo;
     USBPD_PDO_TypeDef SrcPDO;
     USBPD_CORE_PDO_Type_TypeDef pdo_object;
     
     /* select the SRC PDO that will be selected => Application policy */
     ... 
     /* retrieve the type of selected SRC PDO */
     /* If SrcPDO contains the selected SRC PDO */
     pdo_object = SrcPDO.GenericPDO.PowerObject;
     ... 
     /* Build the RDO value */
     ...
     
     /* Send the request */
     _status = USBPD_PE_Send_Request(PortNum, rdo.d32, pdo_object);

    I think Figure 13 in UM2552 has to be updated, indeed.

    Regards

    BMcKAuthor
    Visitor II
    March 11, 2022

    0693W00000KcKOeQAN.pngI still can't make it work.

    if (blah == 0) {
     if (!get_contract(0, &rdo))
     continue;
     if (rdo.fix_var.obj_pos > 2) {
     rdo.fix_var.obj_pos--;
     if (!get_pdo(0, rdo.fix_var.obj_pos, &pdo))
     continue;
     rdo.fix_var.max_oper_cur_ma10 = pdo.fix.ma10;
     rdo.fix_var.oper_cur_ma10 = pdo.fix.ma10;
     if (USBPD_PE_Send_Request(0, rdo.b, PD_PDO_TYPE_FIXED) == USBPD_OK)
     blah = 1;
     }

    As you can see, I'm reading the existing contract to rdo, then if SRC has another pdo, I'm trying to switch to it. I do monitor CC-lies using Cypress EZ-PD and it doesn't indicate any activity. The flag blah is set.

    BMcKAuthorAnswer
    Visitor II
    March 14, 2022

    I did make it work. The problem is that the library REQUIRES at least memory for USBPD_SettingsTypeDef Settings, USBPD_ParamsTypeDef Params, but completely lacks any documentation on what they are for and how to use them.

    ST Employee
    March 11, 2022

    Hello

    The USBPD specification defines a dedicated message to ask a new power contract with a SRC, the command is "REQUEST" and it has a parameter called RDO (request data object).

    The API provided by the stack to perform this action is

    USBPD_StatusTypeDef USBPD_PE_Send_Request(uint8_t PortNum, uint32_t Rdo, USBPD_CORE_PDO_Type_TypeDef PWobject)

    • RDO : is the object to build according your need and the PDO provided by the source
    • USBPD_CORE_PDO_Type_TypeDef : specify the type of requested PDO

    To help you build your RDO, you can take the DPM_SNK_BuildRDOfromSelectedPDO function as an example, it is used by our applications to build the RDO identifier based on the PDO of the SNK and the SRC.

    BR

    Dominique