How to modify the Get_Source_Cap reply in CYPD4236-40LQXI_dock

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
MaLi_3529141
Level 3
Level 3
25 replies posted 25 sign-ins 10 replies posted

Hi,

We need to modify the reply of "Get_Source_Cap" in CYPD4236-40LQXI_dock project,

But there is no "Get_source_cap" in app_callback.

Where do we start from?

Best Regards,

Manu

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

Hi Manu,

You can begin with send a GET_SOURCE_CAP by yourself and then write a callback for this action and report EVENT to app.c. The function you can use is below:

==================================================================

/**

* @brief This function provides an interface for the application module to

* send PD commands.

* @param port Port index.

* @param cmd Command name.

* @param buf_ptr Pointer to the command buffer.

* @param cmd_cbk Pointer to the callback function.

* @return Returns CCG_STAT_SUCCESS if the command is registered,

* CCG_STAT_CMD_FAILURE if the PD port is not ready for a command and

* CCG_STAT_BUSY if there is another pending command.

* @warning Data received via the callback should be copied out by the

* application, because the buffer will be reused by the stack to store data on

* new message reception.

*/

ccg_status_t dpm_pd_command(uint8_t port, dpm_pd_cmd_t cmd, dpm_pd_cmd_buf_t* buf_ptr,

                            dpm_pd_cmd_cbk_t cmd_cbk);

=================================================================

You could check the Type-C status and sent it when the Type-C is attached and state is idle.

a. dpm_pd_command (US_TYPEC_PORT_IDX, DPM_CMD_GET_SRC_CAP, NULL, us_get_sourc_cap_cb);

b. dpm_pd_cmd_cbk_t us_get_sourc_cap_cb (uint8_t port);

Best Regards,

Lisa

View solution in original post

0 Likes
5 Replies
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

Hi Manu,

You can begin with send a GET_SOURCE_CAP by yourself and then write a callback for this action and report EVENT to app.c. The function you can use is below:

==================================================================

/**

* @brief This function provides an interface for the application module to

* send PD commands.

* @param port Port index.

* @param cmd Command name.

* @param buf_ptr Pointer to the command buffer.

* @param cmd_cbk Pointer to the callback function.

* @return Returns CCG_STAT_SUCCESS if the command is registered,

* CCG_STAT_CMD_FAILURE if the PD port is not ready for a command and

* CCG_STAT_BUSY if there is another pending command.

* @warning Data received via the callback should be copied out by the

* application, because the buffer will be reused by the stack to store data on

* new message reception.

*/

ccg_status_t dpm_pd_command(uint8_t port, dpm_pd_cmd_t cmd, dpm_pd_cmd_buf_t* buf_ptr,

                            dpm_pd_cmd_cbk_t cmd_cbk);

=================================================================

You could check the Type-C status and sent it when the Type-C is attached and state is idle.

a. dpm_pd_command (US_TYPEC_PORT_IDX, DPM_CMD_GET_SRC_CAP, NULL, us_get_sourc_cap_cb);

b. dpm_pd_cmd_cbk_t us_get_sourc_cap_cb (uint8_t port);

Best Regards,

Lisa

0 Likes

Hi Liza,

If I receive Get_Source_Cap command, where can I modify the action?

Best Regards,

Manu

0 Likes

Hi Manu,

You could refer below way to detect GET_SOURCE_CAP message and then write a callback for your project.

const dpm_status_t*  dpm_stat = dpm_get_info(TYPEC_PORT_0_IDX);

uint8_t msg = pe_stat->rcvd_ptr->msg;

If (msg = CTRL_MSG_GET_SOURCE_CAP)

{

.....

}

Best Regards,

Lisa

0 Likes

Hi Liza,

I create a function that runs in the while loop inside main() :

===

void APP_Recv_Get_Source_Cap_Service(void)

{

      const dpm_status_t*  dpm_stat = dpm_get_info(TYPEC_PORT_0_IDX);

      uint8_t my_msg = dpm_stat->src_cap_p->msg;

      if(my_msg == CTRL_MSG_GET_SOURCE_CAP)

      {

            UART_1_UartPutChar('A');

            UART_1_UartPutChar('B');

            UART_1_UartPutChar('C');

       }

}

===

But received GET_SOURCE_CAP was not detected.

0 Likes

Hi Manu,

You used incorrect value. Please kindly take a look.

const dpm_status_t*  dpm_stat = dpm_get_info(TYPEC_PORT_0_IDX);

uint8_t msg = pe_stat->rcvd_ptr->msg;

Best Regards,

Lisa

0 Likes