cancel
Showing results for 
Search instead for 
Did you mean: 

USB EZ-PD™ Type-C

NaMe_2085021
New Contributor II

Hi everyone,

Could you help me?

I use CYPD3120 for my project.

I want create basic program with dynamically update sink power capability, when I press button.

My schematic in attachment.

Thank you!

Best regards,

Nazar Melnichek

0 Likes
1 Solution
YiZ_31
Moderator
Moderator

Hi,

You can refer to the following example code:

void change_pdos(void)

{

  pd_do_t SRC_PDO[4];

    if ( //read pin status register somewhat way == false)

    {

        SRC_PDO[0].val = 0x0001912C; //5V 3A (This value can check on xml file created by EZ-PD Configuration Utility)

        SRC_PDO[1].val = 0x0002D0D2; //9V 2.1A

        SRC_PDO[2].val = 0x0004B12C; //15V 3A

        SRC_PDO[3].val = 0x0006412C; //20V 3A

    

        dpm_update_src_cap(0, 4, SRC_PDO);

        dpm_update_src_cap_mask (0, 0x0F);

        dpm_pd_command (0, DPM_CMD_SRC_CAP_CHNG, NULL,NULL); //Send PD command about the changes in source capabilities

    }

}

CY_ISR(GPIO_ISR_handler)

{

    //clear any active interrupts on corresponds pin for interrupt

    change_pdos();

}

Regards,
Eddie

View solution in original post

0 Likes
5 Replies
YiZ_31
Moderator
Moderator

Hi,

You can refer to the following example code:

void change_pdos(void)

{

  pd_do_t SRC_PDO[4];

    if ( //read pin status register somewhat way == false)

    {

        SRC_PDO[0].val = 0x0001912C; //5V 3A (This value can check on xml file created by EZ-PD Configuration Utility)

        SRC_PDO[1].val = 0x0002D0D2; //9V 2.1A

        SRC_PDO[2].val = 0x0004B12C; //15V 3A

        SRC_PDO[3].val = 0x0006412C; //20V 3A

    

        dpm_update_src_cap(0, 4, SRC_PDO);

        dpm_update_src_cap_mask (0, 0x0F);

        dpm_pd_command (0, DPM_CMD_SRC_CAP_CHNG, NULL,NULL); //Send PD command about the changes in source capabilities

    }

}

CY_ISR(GPIO_ISR_handler)

{

    //clear any active interrupts on corresponds pin for interrupt

    change_pdos();

}

Regards,
Eddie

View solution in original post

0 Likes
NaMe_2085021
New Contributor II

Thank you very much!

It`s works for me, but I have a small problem.

I got 9V, 12V and 15V, but  I could`n get 20 V.

Could you help me?

Thank you!

Best regards,

Nazar Melnichek

0 Likes
YiZ_31
Moderator
Moderator

Hi Nazar,

Have you checked the PD log? There are no 20V PDO in the source_cap message?

Regards,
Eddie

0 Likes
NaMe_2085021
New Contributor II

Hi Eddie,

I checked the pd log. In the source_cap message there are 20V PDO.

This will work if you change the size of the array to 4 and remove the odes from values such as 15V.

Part my code:

.....................................

void change_pdos(void)

{  

  pd_do_t SNK_PDO[4]; 

       if ( SW1_Read() == false )

        {               

        SNK_PDO[0].val = 0x0001912C; //5V 3A (This value can check on xml file created by EZ-PD Configuration Utility)

        SNK_PDO[1].val = 0x0002D12c; //9V 3A      

        SNK_PDO[2].val = 0x0003C12C; //12 3A

        SNK_PDO[3].val = 0x000640C8; //20V 2A

        dpm_update_snk_cap(0, 4, SNK_PDO);

        dpm_update_snk_cap_mask (0, 0x0F);

        dpm_pd_command (0, DPM_CMD_SNK_CAP_CHNG, NULL,NULL); //Send PD command about the changes in source capabilities

        }

}

CY_ISR(SW1_Handler)

{

    SW1_ClearInterrupt();

    change_pdos();

}

int main()

{

    SW1_int_StartEx(SW1_Handler);

.................................

Thank you!

Best regards,

Nazar Melnichek

0 Likes
NaMe_2085021
New Contributor II

Part Code:

...............

void change_pdos(void)

{   

  pd_do_t SNK_PDO[5];  

        if ( SW1_Read() == false )

        {                

        SNK_PDO[0].val = 0x0001912C; //5V 3A (This value can check on xml file created by EZ-PD Configuration Utility)

        SNK_PDO[1].val = 0x0002D12c; //9V 3A

       

        SNK_PDO[2].val = 0x0003C12C; //12 3A

        SNK_PDO[3].val = 0x0004B12C; //15V 3A

  

        SNK_PDO[4].val = 0x000641F4; //20V 5A

    

        dpm_update_snk_cap(0, 5, SNK_PDO);

        dpm_update_snk_cap_mask (0, 0x0F);

        dpm_pd_command (0, DPM_CMD_SNK_CAP_CHNG, NULL,NULL); //Send PD command about the changes in source capabilities

        }

}

CY_ISR(SW1_Handler)

{

    //clear any active interrupts on corresponds pin for interrupt

    SW1_ClearInterrupt();

    change_pdos();

}

int main()

{

    SW1_int_StartEx(SW1_Handler);

.........................

0 Likes