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

cross mob

CCG3PA Power Adapter/Car Charger (1C+1A) single chip solution firmware customize steps

CCG3PA Power Adapter/Car Charger (1C+1A) single chip solution firmware customize steps

ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

Below steps for make a firmware for CCG3PA Power Adapter/Car Charger (1C+1A) single chip solution based on example firmware CYPD3171-24LQXQ_cla.

 

1. New created a project based on firmware source code CYPD3171-24LQXQ_cla.

a. Click File > New > Project, and select Ez-PD CCGx Power SDK (CCG3PA) as Target kit.

pastedImage_0.png

b. Select Code Example:CYPD3171-24LQXQ_cla.

pastedImage_1.png

pastedImage_2.png

c. Create a new work-space and choose a name and location for the design. (Since the target part number is going to use CYPD3175, so that I named it start with CYPD3175.)

pastedImage_3.png

NOW, the new project is created complete.

 

2. Clean the project as per CY4532 hardware schematic before start your new project if the hardware is not totally same as CY4532.

a. Change the part number of cc bootloader.

(1) Add a cc bootloader project into the workspace. (There are two types of cc bootloader, cc_sink_boot.cydsn and cc_src_boot.cydsn. cc_sink_boot.cydsn will present as power sink role with this bootloader after entering boot mode. cc_src_boot.cydsn will present as power source role with this bootloader after entering boot mode. )

(2) Change the part number of cc bootloader to make sure the bootloader project and application project use same project.

pastedImage_14.png

(3) Re-build cc bootloader project and update Bootloadable dependencies HEX and ELF files.

pastedImage_15.png

b. Clean application project.

(1) Type-C Port

Disable BUCK_BOOST_EN_C on TopDesign.cysch. Comment out or delete relates functions/operation of BUCK_BOOST_EN_C.

pastedImage_17.png

(2) Type-A Port

Disable PWM_A, BUCK_BOOST_EN_A, and TYPE_A_VBUS_EN. And open type_a.c and config.h files for cleaning firmware.

pastedImage_18.png

@file type_a.c.

Comment out line#55 - line#62

pastedImage_19.png

clear functions:

void type_a_enable_sdp(void)

static void type_a_enable_boost(void)

static void type_a_disable_boost(void)

void type_a_reg_switch_timer_cb(uint8_t instance, timer_id_t id)

void type_a_set_volt_timer_cbk(uint8_t port, timer_id_t id)

void type_a_set_voltage(uint16_t volt_mV)

 

@file config.h

pastedImage_23.png

 

@file stack_prarams.h

/* Dual regulator support for TYPE-A VBUS. */

//1C+1A #define TYPE_A_DUAL_REG_ENABLE                  (1u)

 

NOW, the firmware project is cleared. The project can verified on the board with Type-C port directly.

 

3. Add functions as per application.

a. Add a I2C Master/Slave in CCG3PA.

pastedImage_27.png

b. Use GPIO for Type-A VBUS current sense. Below function is example for using P2.3 for Type-A current sensing.

---------------------------------------------------------------------------------------------------------------------------------------------------------

uint16_t Read_PortA_Current(void)

{

    uint8_t level;

    uint16_t current_volt;

 

    /* Configure GPIO. */

    hsiom_set_config(GPIO_PORT_2_PIN_3, HSIOM_MODE_AMUXA);

    /* Take ADC sample. */

    level = pd_adc_sample (0, PD_ADC_ID_1, PD_ADC_INPUT_AMUX_A);

    current_volt = pd_adc_level_to_volt (0, PD_ADC_ID_1, level);

 

    hsiom_set_config(GPIO_PORT_2_PIN_3, HSIOM_MODE_GPIO);

  

    return current_volt;

}

--------------------------------------------------------------------------------------------------------------------------------------------------------------

c. Add state machine for Type-A and Type-C power source capabilities. Below APIs can be refer to mask Type-C or Type-A power source capabilities.

 

/**

* @brief This function updates the source PDOs at runtime thereby overriding

* the source PDOs in the config table.

* @param port Port index.

* @param count Count of PDOs.

* @param pdo Pointer to the PDO array.

* @return CCG_STAT_SUCCESS if operation is successful, CCG_STAT_BAD_PARAM

* otherwise.

*/

ccg_status_t dpm_update_src_cap(uint8_t port, uint8_t count, pd_do_t* pdo);

 

 

/**

* @brief This function updates the source PDO mask at runtime thereby

* overriding the source PDO mask in the config table.

* @param port Port index.

* @param mask PDO mask.

* @return CCG_STAT_SUCCESS if operation is successful, CCG_STAT_BAD_PARAM

* otherwise.

*/

ccg_status_t dpm_update_src_cap_mask(uint8_t port, uint8_t mask);

 

/**

* @brief This function updates the battery charging configuration.

* This is valid only if LEGACY_DYN_CFG_ENABLE macro is enabled. The configuration

* can only be updated when the BC state machine is stopped. Also note that

* bc_init() shall reload the configuration from the table.

*

* @param cport Battery Charging port index.

* @param chg_cfg Pointer to structure containing new configuration.

*

* @return ccg_status_t

*/

ccg_status_t bc_set_config(uint8_t cport, chg_cfg_params_t *chg_cfg);

0 Likes
808 Views