CYPD3171-24LQXQ_pb: any API to get the CC pin voltage?

Announcements

Live Webinar: USB-C adoption. Simple & Cost-efficient solutions | April 18th @9am or 5pm CEST. Register now !

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
HuEd_3452391
Level 3
Level 3
25 sign-ins First like received 10 sign-ins

Hi,

I would like to get CC pin voltage in order to check the cable type. Any API to get the CC pin voltage?

BRs

0 Likes
1 Solution
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

Hello,

CCGx power SDK is not offering the voltage value retrieve back.  But, below API returns the current status on the CC line (rp_cc_status_t or rd_cc_status_t), you refer this API.

static uint8_t pd_typec_get_rp_rd_status(uint8_t port, uint8_t channel, bool rd_idx)

{

    dpm_status_t* dpm_stat = dpm_get_status(port);

    PPDSS_REGS_T pd = gl_pdss[port];

    uint32_t rval = 0;

    uint32_t temp;

    uint8_t out;

    uint32_t status;

    bool change = false;

    /* Set default output. */

    if (dpm_stat->cur_port_role == PRT_ROLE_SOURCE)

    {

        out = RP_OPEN;

    }

    else

    {

        out = RD_RA + rd_idx;

    }

    /* Connect both the Up/Dn comparators to the active CC line. */

    if (channel == CC_CHANNEL_2)

    {

        rval = (PDSS_CC_CTRL_0_CMP_DN_CC1V2 | PDSS_CC_CTRL_0_CMP_UP_CC1V2);

    }

    temp = pd->cc_ctrl_0 & (PDSS_CC_CTRL_0_CMP_DN_CC1V2 | PDSS_CC_CTRL_0_CMP_UP_CC1V2);

    if ( temp != rval)

    {

        pd->cc_ctrl_0 &= ~(PDSS_CC_CTRL_0_CMP_DN_CC1V2 | PDSS_CC_CTRL_0_CMP_UP_CC1V2);

        pd->cc_ctrl_0 |= rval;

        change = true;

    }

    if (dpm_stat->cur_port_role == PRT_ROLE_SOURCE)

    {

        /*

         * Set the threshold of the Dn comparator to Ra level and the Up

         * comparator to Rp open level.

         */

        rval = ((thresholds[dpm_stat->src_cur_level_live][0]) << PDSS_CC_CTRL_0_CMP_DN_VSEL_POS) |

            ((thresholds[dpm_stat->src_cur_level_live][1]) << PDSS_CC_CTRL_0_CMP_UP_VSEL_POS);

    }

    else

    {

        /* Set the Dn comparator to vRdUSB and the Up comparator to vRd1.5A. */

        rval = ((thresholds[RD_ROW_NO][rd_idx]) << PDSS_CC_CTRL_0_CMP_DN_VSEL_POS) |

            ((thresholds[RD_ROW_NO][rd_idx + 1]) << PDSS_CC_CTRL_0_CMP_UP_VSEL_POS);

    }

    temp = pd->cc_ctrl_0 & (PDSS_CC_CTRL_0_CMP_DN_VSEL_MASK | PDSS_CC_CTRL_0_CMP_UP_VSEL_MASK);

    if (temp != rval)

    {

        pd->cc_ctrl_0 &= ~(PDSS_CC_CTRL_0_CMP_DN_VSEL_MASK | PDSS_CC_CTRL_0_CMP_UP_VSEL_MASK);

        pd->cc_ctrl_0 |= rval;

        change = true;

    }

    if (change == true)

    {

        /* Delay to allow references to settle. */

        CyDelayUs (50);

    }

    status = pd->intr1_status;

    if (((status & PDSS_INTR1_STATUS_VCMP_DN_STATUS) != 0) && ((status & PDSS_INTR1_STATUS_VCMP_UP_STATUS) == 0))

    {

        if (dpm_stat->cur_port_role == PRT_ROLE_SOURCE)

        {

            out = RP_RD;

        }

        else

        {

            out = RD_USB + rd_idx;

        }

    }

    if (dpm_stat->cur_port_role == PRT_ROLE_SOURCE)

    {

        if (((status & PDSS_INTR1_STATUS_VCMP_DN_STATUS) == 0) && ((status & PDSS_INTR1_STATUS_VCMP_UP_STATUS) == 0))

        {

            out = RP_RA;

        }

    }

    if (dpm_stat->cur_port_role == PRT_ROLE_SINK)

    {

        if (((status & PDSS_INTR1_STATUS_VCMP_DN_STATUS) != 0) && ((status & PDSS_INTR1_STATUS_VCMP_UP_STATUS) != 0))

        {

            out = RD_1_5A + rd_idx;

        }

    }

    return out;

}

Best Regards,

Lisa

View solution in original post

0 Likes
1 Reply
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

Hello,

CCGx power SDK is not offering the voltage value retrieve back.  But, below API returns the current status on the CC line (rp_cc_status_t or rd_cc_status_t), you refer this API.

static uint8_t pd_typec_get_rp_rd_status(uint8_t port, uint8_t channel, bool rd_idx)

{

    dpm_status_t* dpm_stat = dpm_get_status(port);

    PPDSS_REGS_T pd = gl_pdss[port];

    uint32_t rval = 0;

    uint32_t temp;

    uint8_t out;

    uint32_t status;

    bool change = false;

    /* Set default output. */

    if (dpm_stat->cur_port_role == PRT_ROLE_SOURCE)

    {

        out = RP_OPEN;

    }

    else

    {

        out = RD_RA + rd_idx;

    }

    /* Connect both the Up/Dn comparators to the active CC line. */

    if (channel == CC_CHANNEL_2)

    {

        rval = (PDSS_CC_CTRL_0_CMP_DN_CC1V2 | PDSS_CC_CTRL_0_CMP_UP_CC1V2);

    }

    temp = pd->cc_ctrl_0 & (PDSS_CC_CTRL_0_CMP_DN_CC1V2 | PDSS_CC_CTRL_0_CMP_UP_CC1V2);

    if ( temp != rval)

    {

        pd->cc_ctrl_0 &= ~(PDSS_CC_CTRL_0_CMP_DN_CC1V2 | PDSS_CC_CTRL_0_CMP_UP_CC1V2);

        pd->cc_ctrl_0 |= rval;

        change = true;

    }

    if (dpm_stat->cur_port_role == PRT_ROLE_SOURCE)

    {

        /*

         * Set the threshold of the Dn comparator to Ra level and the Up

         * comparator to Rp open level.

         */

        rval = ((thresholds[dpm_stat->src_cur_level_live][0]) << PDSS_CC_CTRL_0_CMP_DN_VSEL_POS) |

            ((thresholds[dpm_stat->src_cur_level_live][1]) << PDSS_CC_CTRL_0_CMP_UP_VSEL_POS);

    }

    else

    {

        /* Set the Dn comparator to vRdUSB and the Up comparator to vRd1.5A. */

        rval = ((thresholds[RD_ROW_NO][rd_idx]) << PDSS_CC_CTRL_0_CMP_DN_VSEL_POS) |

            ((thresholds[RD_ROW_NO][rd_idx + 1]) << PDSS_CC_CTRL_0_CMP_UP_VSEL_POS);

    }

    temp = pd->cc_ctrl_0 & (PDSS_CC_CTRL_0_CMP_DN_VSEL_MASK | PDSS_CC_CTRL_0_CMP_UP_VSEL_MASK);

    if (temp != rval)

    {

        pd->cc_ctrl_0 &= ~(PDSS_CC_CTRL_0_CMP_DN_VSEL_MASK | PDSS_CC_CTRL_0_CMP_UP_VSEL_MASK);

        pd->cc_ctrl_0 |= rval;

        change = true;

    }

    if (change == true)

    {

        /* Delay to allow references to settle. */

        CyDelayUs (50);

    }

    status = pd->intr1_status;

    if (((status & PDSS_INTR1_STATUS_VCMP_DN_STATUS) != 0) && ((status & PDSS_INTR1_STATUS_VCMP_UP_STATUS) == 0))

    {

        if (dpm_stat->cur_port_role == PRT_ROLE_SOURCE)

        {

            out = RP_RD;

        }

        else

        {

            out = RD_USB + rd_idx;

        }

    }

    if (dpm_stat->cur_port_role == PRT_ROLE_SOURCE)

    {

        if (((status & PDSS_INTR1_STATUS_VCMP_DN_STATUS) == 0) && ((status & PDSS_INTR1_STATUS_VCMP_UP_STATUS) == 0))

        {

            out = RP_RA;

        }

    }

    if (dpm_stat->cur_port_role == PRT_ROLE_SINK)

    {

        if (((status & PDSS_INTR1_STATUS_VCMP_DN_STATUS) != 0) && ((status & PDSS_INTR1_STATUS_VCMP_UP_STATUS) != 0))

        {

            out = RD_1_5A + rd_idx;

        }

    }

    return out;

}

Best Regards,

Lisa

0 Likes