Skip navigation
Home > All Places > USB > EZ-PD Type-C USB > Blog > 2018 > March


March 2018 Previous month Next month

1. [CCG2 is power sink role] Adjust request PDO as per SOURCE CAP advertised.


{CCG2 firmware is following PD 2.0 SPEC, the function static bool is_src_acceptable_snk(tPD_DO* pdo_src, tPD_DO* pdo_snk) @ file cy_solution.c is for checking which sink PDO is acceptable based on the SOURC_CAP from DFP. CCG2 firmware is select out the one match the SOURCE_CAP as per Power Delivery SPEC, which is means, the sink voltage and current shall be covered by SOURCE_CAP (Voltage shall be match, Current of SOUCE CAP s larger or equal sink capabilities), otherwise, CCG2 will request 5V request.}

>> Need update the case PDO_FIXED_SUPPLY. Example is below


                    if(fix_volt == pdo_snk->fixed_snk.voltage)


                        max_type_cur = get_max_cur(0u, pdo_snk, fix_volt);

                        if(pdo_src->fixed_src.max_current >= max_type_cur)


                            contract_power = udiv_round_up(fix_volt * pdo_snk->fixed_snk.op_current, 500u);

                            contract_voltage = fix_volt;

                            op_cur_power = pdo_snk->fixed_snk.op_current;

                            out = true;


                        //Added for update current for mismatch current only

                        else if(fix_volt > V_SAFE_5V)


                            contract_power = udiv_round_up(fix_volt * pdo_src->fixed_src.max_current, 500u);

                            contract_voltage = fix_volt;

                            op_cur_power = pdo_src->fixed_src.max_current;

                            max_type_cur = pdo_src->fixed_src.max_current;

                            out = true;





2. [CCG2 is power sink role] Request DR_SWAP or PR_SWAP


{Type-C SPEC defines Power source role as data host by default and power sink role as data device. Type-C can support Power role is not sync with data role. For example, Power source role and data sink role.}

>> Firmware implement process is: (PR_SWAP for example, and expect to work as Power source role.)

a. Check current role.((get_current_port_role() == PRT_ROLE_SINK) )

{There may need add more conditions to go ahead to next step, for example, make sure power source is already asserted.}

b. send PR_SWAP if the current role is not match the expect. (handle_pd_command (DPM_CMD_PR_SWAP, NULL, NULL); )



This is mini customize firmware based on Notebook firmware example for power bank solution. This is Dual Role Port design with software disable and delete DisplayPort, HPI, and I2C master from the project. (Since HPI have pre-build as a library, the HPI cannot disable it totally).


The firmware modification process is almost as below.

  1. Firmware compiler setting before re-build firmware project.

     a. Install MDK.exe from link:

     b. Open CYPD2122-24LQXI project and select Tools>Options>Project Management>ARM Toolchains

     c. Fill ARMCC.exe folder path in ARM MDK Generic (default): (Refer below Figure).



2. Customize source code of Notebook example on Creator

  1. Open/New Create a Notebook project with code example.
  2. Double click TopDesign.cysch and disable HPD, HPI, I2C related components.


And then save all.

     c. Open usbpd_config.h under notebook project Header Files and change below configuration define.


     Open usbpd.h under notebook project Header Files and change below configuration define.



     d. Open file dp_source.c to add below function in it.

void dp_source_init(void)





void dp_source_deinit(void)





tDP_STATE get_dp_state (void)


    return 0;



bool update_dp_config(uint8_t config_cmd)


    return 1;




     e. Set Project”Notebook” as Active, and then rebuild the project. You shall get 26 Errors or more errors as below. And check all errors related MUX (CY4521 hardware have PS874x on board) to clean errors from I2C Master.


     f. Save all changes and re-build project.


-----------------------------------------a clean project can be used for CCG2 DRP (or power bank) design----------------------------------------------