cancel
Showing results for 
Search instead for 
Did you mean: 

USB EZ-PD Type-C

Geromino
Contributor II

i have to units  of cypd3175      connceting   via i2c    

when  master unit    send  first time  to slave    the slave unit  does not repones   only  the second   attempt from the master    after   first time the slave coressponding  well

        /*handle  with cypd3175 */

     attached    cypd3175_recieve_packet();

        CyDelay(100);

        /* Handle the device policy tasks for each PD port. */

        for (port = PORT_START_IDX ; port < NO_OF_TYPEC_PORTS; port++)

        {

            dpm_task(port);

            app_task(port);

Q1 :     do i need    special conciduration  in PD stack   ? 

Q2  : why need delay in slave  code  all examples  show with delay ?

Q3   : how hanle slave i2c  in power adapter  project

it is possible  create task which handle i2c slave  or master  in PD task  like call back   i try also  run this  cypd3175_recieve_packet    from timer  bat i get  stack overflow  ?   timer call  back have  max size stack ? 

0 Likes
Reply
9 Replies
ShifangZ_26
Moderator
Moderator

Hi ,

Q1 :     do i need    special conciduration  in PD stack   ?

>> You are not any special conciduration  in PD stack, since the I2C transitions should be not block any PD stack in the firmware side.

Q2  : why need delay in slave  code  all examples  show with delay ?

>> Recommend you use polling way or set I2C slave as FIFO (Ez I2C) and check the contents of FIFO each while loop (500ms). The I2C slave handle call back should be add into the app_task(port), and you also should register I2C wake up in the deep_sleep wake up functions.

Q3   : how hanle slave i2c  in power adapter  project

>> Slave I2C should have register define, you should monitor the changes of registers and define the call backs for this.

Best Regards,

Lisa

0 Likes
Reply
Geromino
Contributor II

Q2 response :

i dont have option Ez I2C in power adpater  project only SCB 

could  you give  exmaple how  add callback to the  app_task or pdf  which explain how also about deepsleep handle  it  will be usefull to other features in the project

0 Likes
Reply
Geromino
Contributor II

void cypd3175_timer_cb (

    uint8_t port,

    timer_id_t id)

{

    (void)port;

    (void)id;

  uint16_t cypd_resualt=0;

  uint8_t sinf_add_reg=0x02;

//uint8_t  srv_reg_add=0x04,src_reg_add=0x05,sinf_add_reg=0x02; //  uint8_t , fw_ver_add_reg=0x00,

uint8_t cypd3175_buffer[2];

memset(cypd3175_buffer,0x00,sizeof(cypd3175_buffer));

uint32_t len_packet=2;

        if (TRANSFER_CMPLT == cypd3175_write_register(I2C_SLAVE_ADDR,&sinf_add_reg))

    {

        if (TRANSFER_CMPLT == cypd3175_read_reagister(I2C_SLAVE_ADDR,cypd3175_buffer,len_packet))

        {

             cypd_resualt=((uint16_t)cypd3175_buffer[0] << 😎 | cypd3175_buffer[1];

             WEIZ_DEBUG_PRINT(WZ_GENERAL_PURPOSE, "[%s] SNIF %2x \r\n", __func__,cypd_resualt);

      

        }

    }

    gpio_set_value (FW_LED_RED_GPIO_PORT_PIN, !(gpio_read_value (FW_LED_RED_GPIO_PORT_PIN)));

    timer_start (0, CYPD3175_TIMER_ID, CYPD3175_TIMER_PERIOD, cypd3175_timer_cb);

}

the fw  stack  not send  any transaction   to slave

0 Likes
Reply
Geromino
Contributor II

any  response  to this case ?

0 Likes
Reply
ShifangZ_26
Moderator
Moderator

Hi Zachar,

I would like to recommend you refer our EZ-PD host SDK which have many I2C operations includes I2C master and I2C slave, you could take a look and refer it.

For example, the I2C transmits prefer to add into application layer --- app.c.

Latest Host SDK download: https://www.cypress.com/documentation/software-and-drivers/ez-pd-host-software-development-kit

And you are on the right way, I2C example code can be download with PSoC Creator.

Best Regards,

Lisa

0 Likes
Reply
Geromino
Contributor II

could  you refer  to  specific example    in host sdk    sash as

pastedImage_0.png

0 Likes
Reply
Geromino
Contributor II

any progress  with answer  to my question   could you provide specific  project  where i could find  implement i2c in app callback i send you screen shot  could you tell me

0 Likes
Reply
Geromino
Contributor II

any respond  to my quastion  which  project from host sdk  show  usage i2c in app callback ?

0 Likes
Reply
Geromino
Contributor II

could you please send me example on host sdk

I2C  Slave SCB block usage byte level APIs 

i didnt  find  any example of  slave  only master 

0 Likes
Reply