3 Replies Latest reply on Jul 3, 2019 9:15 PM by MuthuM_11

    CCG3PAS I2C, port role check and led blink

    chch_3621411

      Hello i'm using 2 CCG3PA in my system for a power bank one port will be dual role and the other will be source only, so i would like to connect them to communicate trough, I2C.

      where should i put the i2c code in main ?
      where should i put the code for checking the port role for example i would like to check if the port is sourcing power then blink blue led or if it is sinking power blink red led, where should i put the API code ?
      for the led there's led only in main.c

      #if APP_FW_LED_ENABLE

       

       

      /* Blink the LED every LED_TIMER_PERIOD ms. This serves as an indication of the firmware running. */

      void led_timer_cb (

          uint8_t port,

          timer_id_t id)

      {

          (void)port;

          (void)id;

       

       

          gpio_set_value (FW_LED_GPIO_PORT_PIN, !(gpio_read_value (FW_LED_GPIO_PORT_PIN)));

          timer_start (0, LED_TIMER_ID, LED_TIMER_PERIOD, led_timer_cb);

      }

       

       

      #endif /* APP_FW_LED_ENABLE */

      and in config.h there is this code for the led

       

      * Enable/Disable firmware active LED operation.

      *

      * The blinking LED is enabled by default but it is recommended to disable it

      * for production designs to save power.

      */

      #define APP_FW_LED_ENABLE                           (0u)

       

       

      /* Enable Internal UVP Comparator to be used as VBUS divider. */

      #define VBUS_MON_INTERNAL                           (1u)

       

       

      /*

      * Select CCG3 GPIO to be used as Activity Indication. This should be set to a

      * valid value if APP_FW_LED_ENABLE is non-zero.

      */

      #define FW_LED_GPIO_PORT_PIN                        (GPIO_PORT_2_PIN_0)

       

       

      /*

      * Timer ID allocation for various solution soft timers.

      */

       

       

      /*

      * Activity indicator LED timer. The timer is used to indicate that the firmware

      * is functional. The feature is controlled by APP_FW_LED_ENABLE.

      */

      #define LED_TIMER_ID                                (0xC0)

      /*

      * The LED toggle period.

      */

      #define LED_TIMER_PERIOD                            (1000)

        • 1. Re: CCG3PAS I2C, port role check and led blink
          ShifangZ_26

          Hi ,

           

          For your questions,

          1. where should i put the i2c code in main ?

          >> You need add I2C initial in main() and before while(1).  And then, you could add others operations in app.c and call it in function void ccg_app_task(uint8_t port).

           

          2. where should i put the code for checking the port role for example i would like to check if the port is sourcing power then blink blue led or if it is sinking power blink red led, where should i put the API code ?

          >> You could add it into void ccg_app_task(uint8_t port).

          And use below way to check whether it is source or sink.

          Is it SOURCE?  >> dpm_get_info(TYPEC_PORT_0_IDX)->cur_port_role == PRT_ROLE_SOURCE

          Is it SINK?  >> dpm_get_info(TYPEC_PORT_0_IDX)->cur_port_role == PRT_ROLE_SINK

           

          Best Regards,

          Lisa

          1 of 1 people found this helpful
          • 2. Re: CCG3PAS I2C, port role check and led blink
            chch_3621411

            hello thanks for the answer,

            so i have added

            void ccg_app_task(uint8_t port)

            {

                /*port role check API added on 04/07/2019*/

                dpm_get_info (TYPEC_PORT_0_IDX)->cur_port_role=PRT_ROLE_SOURCE;

                dpm_get_info (TYPEC_PORT_0_IDX)->cur_port_role=PRT_ROLE_SINK;

            #if CCG_CABLE_COMP_ENABLE

            in app.c batt i have error "cannot assing to return value because fucntion dpm_get_info can't return const value"

            for the two API line

            • 3. Re: CCG3PAS I2C, port role check and led blink
              MuthuM_11

              You should use comparison operator == instead of assignment operator =

               

              Regards,

              Muthu