/**
 * \file    usbpd_config.h
 * \brief   PD configuration header file
 *
 * \par     Copyright (c) 2018 UWE Technologies Corp., Ltd. All Rights Reserved.
 * \author  James
 * \date    2018-07-30
 * \version
 *
 * \history
 *  Date        Note
 *  2018-07-30  Original Creation
 *
 */

#ifndef __USBPD_CONFIG_H_
#define __USBPD_CONFIG_H_

#include "arch.h"
#include "libc.h"
#include "usbpd.h"

#pragma pack(1)


/*************************************/

//input: mA, output 1/10mA
#define CURRENT_DIV                 10U
#define CURRENT_VAL(v)              ((v)/CURRENT_DIV)
#define CURRENT_PPS_DIV             50U
#define CURRENT_PPS(v)              ((v)/CURRENT_PPS_DIV)
#define CURRENT_500mA               500U
#define CURRENT_1000mA              1000U
#define CURRENT_1250mA              1250U
#define CURRENT_1500mA              1500U
#define CURRENT_2000mA              2000U
#define CURRENT_2250mA              2250U
#define CURRENT_2500mA              2500U
#define CURRENT_2700mA              2700U
#define CURRENT_2800mA              2800U
#define CURRENT_3000mA              3000U
#define CURRENT_4000mA              4000U
#define CURRENT_5000mA              5000U

#define DEFAULT_CURRENT             CURRENT_2000mA
#define DEFAULT_MAX_CURRENT         CURRENT_5000mA

//input: mV, output 1/50mV
#define VOLTAGE_DIV                 50U
#define VOLTAGE_VAL(v)              ((v)/VOLTAGE_DIV)
#define VOLTAGE_PPS_DIV             100U
#define VOLTAGE_PPS_REQ_DIV         20U
#define VOLTAGE_AVS_REQ_DIV         25U
#define VOLTAGE_PPS(v)              ((v)/VOLTAGE_PPS_DIV)
#define VSAFE_0V_MAX                600U
//#define VSAFE_0V_MAX                800U
#define VSAFE_5V                    5000U
#define VSAFE_5V_DISCONNECT         3670U
//#define VSAFE_5V_DISCONNECT         4500U
#define VSAFE_5V_MIN_STD            4750U
#define VSAFE_5V_MIN_OCP            VSAFE_5V_DISCONNECT
#define VSAFE_5V_MIN                4400U
#define VSAFE_5V_MAX                5500U
#define OTG_MIN                     2800U
#define OTG_MAX                     3400U
#define VOLTAGE_5V                  VSAFE_5V
#define VOLTAGE_9V                  9000U
#define VOLTAGE_12V                 12000U
#define VOLTAGE_14P8V               14800U
#define VOLTAGE_15V                 15000U
#define VOLTAGE_20V                 20000U
#define VOLTAGE_28V                 28000U
#define VOLTAGE_36V                 36000U
#define VOLTAGE_48V                 48000U

#define DEFAULT_VOLTAGE             VSAFE_5V
#define DEFAULT_MIN_VOLTAGE         VSAFE_5V
#define DEFAULT_MAX_VOLTAGE         VOLTAGE_20V

#define VOLTAGE_PPS_MAX_5V          5900U
#define VOLTAGE_PPS_MAX_9V          11000U
#define VOLTAGE_PPS_MAX_15V         16000U
#define VOLTAGE_PPS_MAX_20V         21000U

//input: mW, output 1/250mW
#define POWER_DIV                   250U
#define POWER_VAL(v)                ((v)/POWER_DIV)
#define DEFAULT_MIN_PD_POWER        10000U
#define DEFAULT_ALLOW_POWER         40000U
#define DEFAULT_AAPL_ALLOW_POWER    29000U

#define DOCK_RETENION_POWER         4500U
#define DOCK_REMAIN_CURRENT         1500U

#define VOLTAGE_HIGH(v)             (((v) & 0x3C0) >> 6)
#define VOLTAGE_LOW(v)              ((v) & 0x3F)
#define VOLTAGE_COMBINE(vh,vl)      (((vh) << 6) + (vl))

#define VOLTAGE_HIGH_ORIG(v)        ((VOLTAGE_VAL(v) & 0x3C0) >> 6)
#define VOLTAGE_LOW_ORIG(v)         (VOLTAGE_VAL(v) & 0x3F)

#define VOLT_GET(obj)               (((obj)->volt))
#define MAX_CURR_GET(obj)           (((obj)->max_curr))
#define MIN_VOLT_GET(obj)           (((obj)->min_volt))
#define MAX_VOLT_GET(obj)           (((obj)->max_volt))
#define MAX_ALLOW_PWR_GET(obj)      (((obj)->max_allow_pwr))

#define MAX_OPR_CURR_GET(obj)       (((obj)->max_opr_curr))
#define MIN_OPR_CURR_GET(obj)       (((obj)->min_opr_curr))
#define OPR_CURR_GET(obj)           (((obj)->opr_curr))



/* The unit of input parameter v is 1mV */

// DUTY increment by voltage increment
#define PWM_VOLT_TO_DUTY_INC(volt,voltMin,voltStep,dutyMin,dutyMax) \
    (((volt)>(voltMin)) ? ((((((volt)-(voltMin))/(voltStep)) + (dutyMin)) >= (dutyMax)) ? (dutyMax) : ((((volt)-(voltMin))/(voltStep)) + (dutyMin))) : (dutyMin))

// DUTY decrement by voltage increment
#define PWM_VOLT_TO_DUTY_DEC(volt,voltMin,voltStep,dutyMin,dutyMax) \
    (((volt)>(voltMin)) ? (((dutyMax) > (((volt)-(voltMin))/(voltStep))) ? ((dutyMax) - (((volt)-(voltMin))/(voltStep))) : dutyMin ) : (dutyMax))



//PD Standard VID
#define PD_STANDARD_VID             0xFF00U

//USB default value
#define DEFAULT_USB_VID             0x2F85U


#define DEFAULT_USB_BCD_DEVICE      0x0100U

#define DEFAULT_USB_PRODUCT_ID      0x0001U


#define DEFAULT_USB_TID             2465UL



#define DEFAULT_USB_SVID0           0xFF01U
#define DEFAULT_USB_SVID1           0xFF02U

#define DEFAULT_USB_MODE0           0x00000001UL

#define DEFAULT_USB_MODE1           0x00000002UL

#define DEFAULT_USB_MODE_POS        0x1


#define CFG_VOLTAGE_5V_IDX          (0)
#define CFG_MAX_PWR_CAP_NUM         (13)

typedef enum USBPD_DEBUG_LEVEL_e
{
    USBPD_DEBUG_LEVEL_OFF,		///< Debug off
    USBPD_DEBUG_LEVEL_1,        ///< Debug on, level 1
    USBPD_DEBUG_LEVEL_2,        ///< Debug detail, level 2
    USBPD_DEBUG_LEVEL_3,        ///< Debug detail+, level 3
    USBPD_DEBUG_LEVEL_4,        ///< Debug interrupt
    USBPD_DEBUG_LEVEL_END
} USBPD_DEBUG_LEVEL_t;

typedef enum FIXED_SUPPLY_POWER_PROFILE_e
{
    POWER_PROFILE_RESV,         //resv
    POWER_PROFILE_CUSTOM,       //CUSTOM
    POWER_PROFILE_0P5W_FIXED,   //5V@100mA
    POWER_PROFILE_15W_FIXED,    //5V@3A
    POWER_PROFILE_18W_FIXED,    //5V@3A,9V@2A,12V@1.5A,15V@1.2A          18W Fixed
    POWER_PROFILE_18W_PPS,      //5V@3A,9V@2A;3.3-5.9V@3A,3.3-11V@2A     18W PPS
    POWER_PROFILE_27W_FIXED,    //5V,9V@3A;12V@2.25A;15V@1.8A;20V@1.35A  27W Fixed
    POWER_PROFILE_27W_PPS,      //5V,9V@3A;15V@1.8A;20V@1.35A;3.3-11V@3A,3.3-16V@1.8A  27W PPS
    POWER_PROFILE_30W_FIXED,    //5V,9V@3A;12V@2.5A;15V@2A               30W Fixed
    POWER_PROFILE_30W_PPS,      //5V,9V@3A;15V@2A;3.3-11V@3A,3.3-16V@2A  30W PPS
    POWER_PROFILE_30W_FIXED_20V,//5V,9V@3A;12V@2.5A;20V@1.5A             30W Fixed
    POWER_PROFILE_30W_PPS_20V,  //5V,9V@3A;15V@2A;3.3-11V@3A,3.3-20V@1.5A30W PPS
    POWER_PROFILE_45W_FIXED,    //5V,9V,15V@3A;20V@2.25A                 45W Fixed
    POWER_PROFILE_45W_PPS,      //5V,9V,15V@3A;20V@2.25A;3.3-16V@3A      45W PPS
    POWER_PROFILE_60W_FIXED,    //5V,9V,15V@3A;20V@3A                    60W Fixed
    POWER_PROFILE_60W_PPS,      //5V,9V,15V@3A;20V@3A;3.3-21V@3A         60W PPS
	POWER_PROFILE_65W_FIXED,    //5V,9V,15V@3A;20V@3.25A                 65W Fixed
	POWER_PROFILE_65W_PPS,      //5V,9V,15V@3A;20V@3.25A;3.3-21V@3.25A   65W PPS
	POWER_PROFILE_72W_FIXED,    //5V,9V,15V@3A;20V@3.6A                  72W Fixed
	POWER_PROFILE_72W_PPS,      //5V,9V,15V@3A;20V@3.6A;3.3-21V@3.6A     72W PPS
	POWER_PROFILE_75W_FIXED,    //5V,9V,15V@3A;20V@3.75A                 75W Fixed
	POWER_PROFILE_75W_PPS,      //5V,9V,15V@3A;20V@3.75A;3.3-21V@3.75A   75W PPS
    POWER_PROFILE_80W_FIXED,    //5V,9V,15V@3A;20V@4A                    80W Fixed
    POWER_PROFILE_80W_PPS,      //5V,9V,15V@3A;20V@4A;3.3-21V@4A         80W PPS
    POWER_PROFILE_87W_FIXED,    //5V,9V,15V@3A;20V@4.35A                 87W Fixed
    POWER_PROFILE_87W_PPS,      //5V,9V,15V@3A;20V@4.35A;3.3-21V@4.35A   87W PPS
    POWER_PROFILE_90W_FIXED,    //5V,9V,15V@3A;20V@4.5A                  90W Fixed
    POWER_PROFILE_90W_PPS,      //5V,9V,15V@3A;20V@4.5A;3.3-21V@4.5A     90W PPS
    POWER_PROFILE_96W_FIXED,    //5V,9V,15V@3A;20V@4.8A                  96W Fixed
    POWER_PROFILE_96W_PPS,      //5V,9V,15V@3A;20V@4.8A;3.3-21V@4.8A     96W PPS
    POWER_PROFILE_100W_FIXED,   //5V,9V,15V@3A;20V@5A                    100W Fixed
    POWER_PROFILE_100W_PPS,     //5V,9V,15V@3A;20V@5A;3.3-21V@5A         100W PPS
    POWER_PROFILE_50W_FIXED,    //5V,9V,15V@3A;20V@2.5A                  50W Fixed
    POWER_PROFILE_50W_PPS,      //5V,9V,15V@3A;20V@2.5A;3.3-16V@3A;3.3-21V@2.5A  50W PPS
    POWER_PROFILE_5W_FIXED,     //5V@1A;
    POWER_PROFILE_7P5W_FIXED,     //5V@1.5A;
    POWER_PROFILE_10W_FIXED,     //5V@2A;
    POWER_PROFILE_CUSTOMIZE_FIXED, //define by change
    POWER_PROFILE_40W_FIXED,     ////5V,9V,15V@2.6A;20V@2A                 40W Fixed
    POWER_PROFILE_140W_FIXED,     /////epr 5V,9V,15V@3A;20V 28v@5A         140W Fixed
    POWER_PROFILE_140W_AVS,     /////epr 5V,9V,15V@3A;20V 28v@5A 15v-28v@5A 140W AVS
    POWER_PROFILE_180W_FIXED,     ////epr 5V,9V,15V@3A;20V,28v,36v@5A      180W Fixed
    POWER_PROFILE_180W_AVS,     ////epr 5V,9V,15V@3A;20V,28v,36v@5A 15-36v 180W AVS
    POWER_PROFILE_240W_FIXED,     ////epr 5V,9V,15V@3A;20V,28v,36v,48v@5A  240W Fixed
    POWER_PROFILE_240W_AVS,     ////epr 5V,9V,15V@3A;20V,28v,36v,48v@5A 15-48v 240W AVS
    POWER_PROFILE_120W_FIXED,     /////epr 5V,9V,15V@3A;20V 28v@5A         140W Fixed
    POWER_PROFILE_MAX
} FIXED_SUPPLY_POWER_PROFILE_t;

typedef enum SNK_POWER_REQUIRE_e
{
    SNK_POWER_REQUIRE_15W,     //5V@3A
    SNK_POWER_REQUIRE_SRC_MAX,     //follow src cap maximal
    SNK_POWER_REQUIRE_18W,     //9V@2A
    SNK_POWER_REQUIRE_24W,     //12V@2A
    SNK_POWER_REQUIRE_29W,     //14.8V@2A
    SNK_POWER_REQUIRE_30W,     //15V@2A
    SNK_POWER_REQUIRE_40W,     //20V@2A
    SNK_POWER_REQUIRE_45W,      //20v@2.5A
    SNK_POWER_REQUIRE_60W,     //20v@3A
    SNK_POWER_REQUIRE_0P5W,     //5V@0.1A
    SNK_POWER_REQUIRE_100W,     //20V@5A
    SNK_POWER_REQUIRE_140W,     //28V@5A
    SNK_POWER_REQUIRE_180W,     //36V@5A
    SNK_POWER_REQUIRE_240W,     //48V@5A
    SNK_POWER_PROFILE_PPS,      //PPS profile
    SNK_POWER_PROFILE_CUSTOM,   //CUSTOM
    SNK_POWER_REQUIRE_27W,
    SNK_POWER_REQUIRE_MAX
} SNK_POWER_REQUIRE_t;

typedef enum PEAK_CURRENT_LVL_e
{
    PEAK_CURRENT_LVL0,
    PEAK_CURRENT_LVL1,
    PEAK_CURRENT_LVL2,
    PEAK_CURRENT_LVL3
} PEAK_CURRENT_LVL_t;

typedef enum POWER_SUPPLY_TYPE_e
{
    POWER_SUPPLY_TYPE_FIXED,
    POWER_SUPPLY_TYPE_BATTERY,
    POWER_SUPPLY_TYPE_VARIABLE,
    POWER_SUPPLY_TYPE_PPS,
    POWER_SUPPLY_TYPE_INVALID
} POWER_SUPPLY_TYPE_t;

typedef enum PD_ROLE_e
{
    PD_ROLE_CONSUMER,
    PD_ROLE_PROVIDER,
    PD_ROLE_PROVIDER_CONSUMER,
    PD_ROLE_CONSUMER_PROVIDER,
    PD_ROLE_CABLE_PLUG,
    PD_ROLE_CAPTURE,
    PD_ROLE_END
} PD_ROLE_t;

typedef enum CABLE_TYPE_e
{
    CABLE_TYPE_A,
    CABLE_TYPE_B,
    CABLE_TYPE_C,
    CABLE_TYPE_END
} CABLE_TYPE_t;

typedef enum POWER_MODE_e
{
    POWER_MODE_SINK,
    POWER_MODE_SOURCE,
    POWER_MODE_END
} POWER_MODE_t;

typedef enum POWER_ROLE_e
{
    POWER_ROLE_SINK,
    POWER_ROLE_SOURCE,
    POWER_ROLE_DRP,
    POWER_ROLE_END
} POWER_ROLE_t;

typedef enum POWER_SOURCE_e
{
    POWER_SOURCE_AC_INPUT,
    POWER_SOURCE_BATTERY,
    POWER_SOURCE_END
} POWER_SOURCE_t;

typedef enum USB_DATA_MODE_e
{
    USB_DATA_MODE_UFP,
    USB_DATA_MODE_DFP,
    USB_DATA_MODE_END
} USB_DATA_MODE_t;

typedef enum USB_DATA_ROLE_e
{
    USB_DATA_ROLE_UFP,
    USB_DATA_ROLE_DFP,
    USB_DATA_ROLE_DRD,
    USB_DATA_ROLE_END
} USB_DATA_ROLE_t;

typedef enum SPEC_REVISION_e
{
    SPEC_REVISION_1_0,
    SPEC_REVISION_2_0,
    SPEC_REVISION_3_0,
    SPEC_REVISION_END
} SPEC_REVISION_t;

typedef enum SVDM_REVISION_e
{
    SVDM_REVISION_1_0,
    SVDM_REVISION_2_0,
    SVDM_REVISION_END
} SVDM_REVISION_t;

typedef enum MSG_SOP_TYPE_e
{
    MSG_SOP_TYPE_SOP,
    MSG_SOP_TYPE_SOPP,
    MSG_SOP_TYPE_SOPPP,
    MSG_SOP_TYPE_SOPP_DBG,
    MSG_SOP_TYPE_SOPPP_DBG,
    MSG_SOP_TYPE_HARD_RESET,
    MSG_SOP_TYPE_CABLE_RESET,
    MSG_SOP_TYPE_BIST_CM2,
    MSG_SOP_TYPE_END
} MSG_SOP_TYPE_t;

/** Cable latency */
typedef enum CABLE_LATENCY_e
{
    CABLE_LATENCY_1M = 0x01, ///< 0001b <10ns (~1m)
    CABLE_LATENCY_2M = 0x02, ///< 0010b 10ns to 20ns (~2m)
    CABLE_LATENCY_3M = 0x03, ///< 0011b 20ns to 30ns (~3m)
    CABLE_LATENCY_4M = 0x04, ///< 0100b 30ns to 40ns (~4m)
    CABLE_LATENCY_5M = 0x05, ///< 0101b 40ns to 50ns (~5m)
    CABLE_LATENCY_6M = 0x06, ///< 0110b 50ns to 60ns (~6m)
    CABLE_LATENCY_7M = 0x07, ///< 0111b 60ns to 70ns (~7m)
    CABLE_LATENCY_100M = 0x08, ///< 1000b 1000ns (~100m)
    CABLE_LATENCY_200M = 0x09, ///< 1001b 2000ns (~200m)
    CABLE_LATENCY_300M = 0x0A, ///< 1010b 3000ns (~300m)
} CABLE_LATENCY_t;

/** Current Source Supply type */
typedef enum CURRENT_SRC_SUPPLY_TYPE_e
{
    CURRENT_SRC_SUPPLY_OFF,
    CURRENT_SRC_SUPPLY_80uA,
    CURRENT_SRC_SUPPLY_180uA,
    CURRENT_SRC_SUPPLY_330uA,
    CURRENT_SRC_SUPPLY_END
} CURRENT_SRC_SUPPLY_TYPE_t;

typedef enum VBUS_CURR_HANDLING_CAP_e
{
    VBUS_CURR_HANDLING_CAP_RESV,
    VBUS_CURR_HANDLING_CAP_3A,
    VBUS_CURR_HANDLING_CAP_5A,
    VBUS_CURR_HANDLING_CAP_END
} VBUS_CURR_HANDLING_CAP_t;

typedef enum CABLE_VBUS_VOLT_MAX_e
{
    VBUS_VOLT_CABLE_20V,
    VBUS_VOLT_CABLE_30V,
    VBUS_VOLT_CABLE_40V,
    VBUS_VOLT_CABLE_50V,
    VBUS_VOLT_CABLE_END
} CABLE_VBUS_VOLT_MAX_t;

typedef enum USB_HIGHEST_SPEED_e
{
    USB_SPEED_20,
    USB_SPEED_32_GEN1,
    USB_SPEED_32_GEN2,
    USB_SPEED_40_GEN3
} USB_HIGHEST_SPEED_t;

/** USB configuration */
typedef struct VD_USB_CFG_s
{
#if __LITTLE_ENDIAN__
    u32_t vid:16;
    u32_t svid:16;

    u32_t bcd_device:16;
    u32_t prod_id:16;

    u32_t tid;
#else
    u32_t svid:16;
    u32_t vid:16;

    u32_t prod_id:16;
    u32_t bcd_device:16;

    u32_t tid;
#endif
} VD_USB_CFG_t;

/** Vendor defined configuration */
typedef struct VDM_CFG_s
{
    // 1st 32bits
    u32_t struct_vdm_ver:2; /* 0: version 1.0, 1: version 2.0, 2-3 resv */
    u32_t usb_host_data_cap:1;
    u32_t usb_dev_data_cap:1;
    u32_t modal_opr_supp:1;
    u32_t vbus_curr_cap:2;
    u32_t vbus_thr_cbl:1;

    u32_t cbl_latency:4;
    u32_t cbl_term_type:2;
    u32_t sop2_ctrler_pres:1;
    u32_t vbus_req:1;                        /* VBUS required */

    u32_t usb_ss_sig_supp:3;
    u32_t vcon_pwr:3;                         /* VCONN power needed by adapter for full functionality */
    u32_t vcon_req:1;                    /* VCONN required */
    u32_t resv1:1;

    u32_t max_vbus_volt:2;        /* Maximum VBUS Voltage :
                                        00b ¨C 20V
                                        01b ¨C 30V
                                        10b ¨C 40V
                                        11b ¨C 50V */
    u32_t resv3:2;              /*  */
    u32_t mode_pos:3;           //0b001
    u32_t vconn_detected:1;

} VDM_CFG_t;

typedef struct POWER_FIXED_s
{
#if __LITTLE_ENDIAN__
    u32_t max_curr:10;           /* Maximum Current in 10mA units */
    u32_t max_volt:10;           /* Maximum Voltage in 50mV units */
    u32_t peak_curr:2;           /* Peak Current */
    u32_t reserved:8;            /* Reserved */
    u32_t supply_type:2;         /* Variable supply */

    u32_t pwm_duty;              /* PWM duty cycle or VBUS set value */
    u32_t reserved2;              /* Reserved */
#else
    u32_t supply_type:2;         /* Variable supply */
    u32_t reserved:8;            /* Reserved */
    u32_t peak_curr:2;           /* Peak Current */
    u32_t max_volt:10;           /* Maximum Voltage in 50mV units */
    u32_t max_curr:10;           /* Maximum Current in 10mA units */

    u32_t pwm_duty;              /* PWM duty cycle or VBUS set value */
    u32_t reserved2;              /* Reserved */
#endif
} POWER_FIXED_t;


typedef struct POWER_BATTERY_s
{
#if __LITTLE_ENDIAN__
    u32_t max_allow_pwr:10;       /* Maximum Allowable Power in 250mW units */
    u32_t min_volt:10;            /* Minimum Voltage in 50mV units */
    u32_t max_volt:10;            /* Maximum Voltage in 50mV units */
    u32_t supply_type:2;          /* Battery supply */

    u32_t pwm_duty;               /* PWM duty cycle or VBUS set value */
    u32_t pwm_duty_max;           /* PWM duty cycle or VBUS set value */
#else
    u32_t supply_type:2;          /* Battery supply */
    u32_t max_volt:10;            /* Maximum Voltage in 50mV units */
    u32_t min_volt:10;            /* Minimum Voltage in 50mV units */
    u32_t max_allow_pwr:10;       /* Maximum Allowable Power in 250mW units */

    u32_t pwm_duty;               /* PWM duty cycle or VBUS set value */
    u32_t pwm_duty_max;           /* PWM duty cycle or VBUS set value */
#endif
} POWER_BATTERY_t;

typedef struct POWER_VARIABLE_s
{
#if __LITTLE_ENDIAN__
    u32_t max_curr:10;           /* Maximum Current in 10mA units */
    u32_t min_volt:10;           /* Minimum Voltage in 50mV units */
    u32_t max_volt:10;           /* Maximum Voltage in 50mV units */
    u32_t supply_type:2;         /* Variable supply */

    u32_t pwm_duty;              /* PWM duty cycle or VBUS set value */
    u32_t pwm_duty_max;           /* PWM duty cycle or VBUS set value */
#else
    u32_t supply_type:2;         /* Variable supply */
    u32_t max_volt:10;           /* Maximum Voltage in 50mV units */
    u32_t min_volt:10;           /* Minimum Voltage in 50mV units */
    u32_t max_curr:10;           /* Maximum Current in 10mA units */

    u32_t pwm_duty;              /* PWM duty cycle or VBUS set value */
    u32_t pwm_duty_max;           /* PWM duty cycle or VBUS set value */
#endif
} POWER_VARIABLE_t;


typedef struct POWER_PPS_s
{
#if __LITTLE_ENDIAN__
    u32_t max_curr:7;           /* Maximum Voltage in 50mA increments */
    u32_t resv1:1;              /* Reserved - shall be set to zero. */
    u32_t min_volt:8;           /* Minimum Current in 100mV increments */
    u32_t resv2:1;              /* Reserved - shall be set to zero. */
    u32_t max_volt:8;           /* Maximum Voltage in 100mV increments */
    u32_t resv3:2;              /* Reserved - shall be set to zero. */
    u32_t power_limited:1;      /* PPS Power Limited */
    u32_t pps:2;                /* Programmable Power Supply */
    u32_t supply_type:2;        /* 11b ¨C Augmented Power Data Object (APDO) */

    u32_t pwm_duty;             /* PWM duty cycle or VBUS set value */
    u32_t pwm_duty_max;         /* PWM duty cycle or VBUS set value */
#else
    u32_t supply_type:2;        /* 11b ¨C Augmented Power Data Object (APDO) */
    u32_t pps:2;                /* Programmable Power Supply */
    u32_t power_limited:1;      /* PPS Power Limited */
    u32_t resv3:2;              /* Reserved - shall be set to zero. */
    u32_t max_volt:8;           /* Maximum Voltage in 100mV increments */
    u32_t resv2:1;              /* Reserved - shall be set to zero. */
    u32_t min_volt:8;           /* Minimum Current in 100mV increments */
    u32_t resv1:1;              /* Reserved - shall be set to zero. */
    u32_t max_curr:7;           /* Maximum Voltage in 50mA increments */

    u32_t pwm_duty;             /* PWM duty cycle or VBUS set value */
    u32_t pwm_duty_max;         /* PWM duty cycle or VBUS set value */
#endif
} POWER_PPS_t;

typedef struct POWER_AVS_s
{
#if __LITTLE_ENDIAN__
    u32_t pdp:8;                /* PDP in 1W increments */
    u32_t min_volt:8;           /* Minimum Current in 100mV increments */
    u32_t resv1:1;              /* Reserved - shall be set to zero. */
    u32_t max_volt:9;           /* Maximum Voltage in 100mV increments */
    u32_t resv2:2;              /* Reserved - shall be set to zero. */
    u32_t pps:2;                /* 00b -Programmable Power Supply,01 EPR Adjustable Voltage Supply*/
    u32_t supply_type:2;        /* 11b - Augmented Power Data Object (APDO) */

    u32_t pwm_duty;             /* PWM duty cycle or VBUS set value */
    u32_t pwm_duty_max;         /* PWM duty cycle or VBUS set value */
#else
    u32_t supply_type:2;        /* 11b - Augmented Power Data Object (APDO) */
    u32_t pps:2;                /* 00b -Programmable Power Supply, 01 EPR Adjustable Voltage Supply*/
    u32_t resv2:2;              /* Reserved - shall be set to zero. */
    u32_t max_volt:9;           /* Maximum Voltage in 100mV increments */
    u32_t resv1:1;              /* Reserved - shall be set to zero. */
    u32_t min_volt:8;           /* Minimum Current in 100mV increments */
    u32_t pdp:8;                /* PDP in 1W increments */

    u32_t pwm_duty;             /* PWM duty cycle or VBUS set value */
    u32_t pwm_duty_max;         /* PWM duty cycle or VBUS set value */
#endif
} POWER_AVS_t;

/** power profile configuration */
typedef struct POWER_PROFILE_s
{
    struct {
#if __LITTLE_ENDIAN__
        u32_t cap_num:3;        ///< Maximal source capabilities
        u32_t pwm_en:1;         ///< PWM enabled, 0 disabled and use VBUS set, 1 enabled and disabled VBUS set
        u32_t pwm_init_high:1;  ///< PWM intiial high
        u32_t epr_cap_num:3;    ///< reserved
        u32_t profile_changed:1;///< power profile changed flag
        u32_t profile:7;        ///< profile index
        u32_t pwm_per:16;       ///< PWM period
#else
        u32_t pwm_per:16;       ///< PWM period
        u32_t profile:7;        ///< profile index
        u32_t profile_changed:1;///< power profile changed flag
        u32_t epr_cap_num:3;    ///< reserved
        u32_t pwm_init_high:1;  ///< PWM intiial high
        u32_t pwm_en:1;         ///< PWM enabled, 0 disabled and use VBUS set, 1 enabled and disabled VBUS set
        u32_t cap_num:3;        ///< Maximal source capabilities
#endif

        union {
            /** Fixed Power */
            POWER_FIXED_t fixed;
            /** Battery Power */
            POWER_BATTERY_t battery;
            /** Variable Power */
            POWER_VARIABLE_t variable;
            POWER_PPS_t pps;
            POWER_AVS_t avs;
            u32_t u32data[3];
        } caps[CFG_MAX_PWR_CAP_NUM];
    } src;

    struct {
#if __LITTLE_ENDIAN__
        u32_t opr_curr:16;           /* Operating Current in 10mA units */
        u32_t opr_volt:16;           /* Operating Voltage in 50mV units */

        u32_t max_opr_curr:16;       /* Maximum Operating Current in 10mA units */
        u32_t profile:8;             /* profile index */
        u32_t pps_en:1;              /* Sink PPS Enabled */
        u32_t acceptable_volt:5;     /* Sink acceptable voltage, unit is 1V, max 20V */
        u32_t rsvd2:2;               ///< reserved

        u32_t epr_opr_curr:16;       /* epr Operating Current in 10mA units */
        u32_t epr_opr_volt:16;       /* epr Operating Voltage in 50mV units */

        u32_t epr_max_opr_curr:16;   /* epr Maximum Operating Current in 10mA units */
        u32_t epr_profile:8;         /* epr profile index */
        u32_t epr_avs_en:1;          /* epr Sink PPS Enabled */
        u32_t epr_acceptable_volt:7; /* epr Sink acceptable voltage, unit is 1V, max 127V */
#else

        u32_t opr_volt:16;           /* Operating Voltage in 50mV units */
        u32_t opr_curr:16;           /* Operating Current in 10mA units */

        u32_t rsvd2:2;               ///< reserved
        u32_t acceptable_volt:5;     /* Sink acceptable voltage, unit is 1V, max 20V */
        u32_t pps_en:1;              /* Sink PPS Enabled */
        u32_t profile:8;             /* profile index */
        u32_t max_opr_curr:16;       /* Maximum Operating Current in 10mA units */

        u32_t epr_opr_volt:16;        /* epr Operating Voltage in 50mV units */
        u32_t epr_opr_curr:16;        /* epr Operating Current in 10mA units */

        u32_t epr_acceptable_volt:7;  /* epr Sink acceptable voltage, unit is 1V, max 127V */
        u32_t epr_avs_en:1;           /* epr Sink PPS Enabled */
        u32_t epr_profile:8;          /* epr profile index */
        u32_t epr_max_opr_curr:16;    /* epr Maximum Operating Current in 10mA units */

#endif
    } snk;
} POWER_PROFILE_t;

/** PD port Configuration definition */
typedef struct PORT_CFG_s
{
    // 1st 32 bits
    u32_t cbl_type:2;        /* 0: Type-A, 1: Type-B, 2: Type-C */
    u32_t pwr_src:1;         /* Power Source: 0: AC-input, 1: Battery */
    u32_t def_pdr:3;         /* Default PD Role, 0: Consumer, 1: Provider,
                             * 2: Provider/Consumer, 3: Consumer/Provider
                             * 4: Cable Plug
                             */
    u32_t def_usb_pr:2;      /* Port Power Role, 0: Sink, 1: Source, 2: Source and Sink */

    u32_t def_usb_dr:2;      /* Default USB Data Role, 0: UFP, 1: DFP,
                             * 2: DRP
                             */
    u32_t spec_rev:2;        /* Specification Revision
                             * 00'b: Revision 1.0, 01'b: Revision 2.0
                             */
    u32_t try_src:1;         /* Try Source */
    u32_t dual_role_pwr:1;   /* Dual-Role Power */
    u32_t usb_susp_supp:1;   /* USB Suspend Supported */
    u32_t ext_pwr:1;         /* Externally Powered, same as pwr_src */

    u32_t usb_comm_cap:1;    /* USB Communications Capable */
    u32_t drs_cap:1;         /* Data Role Swap Capability */
    u32_t no_pd_mode:1;
    u32_t vdm_en:1;          /* 0: disable; 1: enable sop vdm */
    u32_t vdm_resp_ufp_en:1;    /* 0: disable; 1: enable vdm responsed to UFP discovery id */
    u32_t vdm_src_startup_en:1; /* 0: disable; 1: enabled */
    u32_t try_snk:1;         /* Try Sink */
    u32_t power_limited:1;   /* 0: disabled power limitation, 1: enabled power limited */

    u32_t curr_src_supply_type:2;    /**
                                     * 2'b00: Disabled;
                                     * 2'b01: current source supply 80 uA current;
                                     * 2'b10: current source supply 180 uA current;
                                     * 2'b11: current source supply 333 uA current
                                     */
    u32_t vbus_check_en:1;      /** VBUS check enable, 0: disabled, 1:enabled */
    u32_t quick_charge_en:1;    /** Quick Charge enabled, 0: disabled, 1:enabled */
    u32_t vconn_en:1;           /** Vconn enabled, 0: disabled, 1:enabled */
    u32_t pps_en:1;             /** Programmable power supply, 0: disabled, 1:enabled */
    u32_t prs_auto_en:1;        /** Automatically power role swap, 0: disabled, 1:enabled */
    u32_t source_ocp_en:1;      /** Over current protection enable, 0: disabled, 1:enabled */

    // 2nd 32 bits
    u32_t quick_charge_ver:2;   /** version, 0:V2, 1:V3, 2:V4 3:reserved */
    u32_t auto_power_down:1;
    u32_t power_bank_en:1;
    u32_t bat_cell:3;           /** 0:1s, 1:2s, 2:3s, 3:4s */
    u32_t usba_en:1;            /* 0: disable; 1: enable USB-A */
    u32_t usba_volt_calibration:1; /* 0: disable; 1: enable USB-A voltage calibration */
    u32_t retry_cnt:2;          /** PD retransmission count: 0-3 */
    u32_t vrd_min_src:16;
    u32_t cc1_disabled:1;
    u32_t cc2_disabled:1;
    u32_t ufp_rx_all:1;
    u32_t drp_toggle_randomly_disabled:1;
    u32_t otp_disabled:1;       /** Over temperature protection, 1: disabled, 0:enabled */

    // 3rd 32 bits
    u32_t vrd_max_src:16;
    u32_t vrd_min_snk:16;

    // 4th 32 bits
    u32_t vrd_max_snk:16;
    u32_t vra_min:16;

    // 5th 32 bits
    u32_t vra_max:16;
    u32_t vopen:16;

    // 6th 32 bits
    u32_t pps_volt_step:16,      /** Programmable power supply voltage step, unit: millivolt */
          init_cc_half_bit_flg:1,     ///< CC half bit period init configured flag
          init_cc_half_bit:3,         ///< CC half bit period init configuration
          init_cc_rx_filter_sel_flg:1,///< CC RX_FILTER_SEL init configured flag
          init_cc_rx_filter_sel:2,    ///< CC RX_FILTER_SEL init configuration
          init_adc_stc_flg:1,   ///< ADC STC init configured flag
          init_adc_stc:3,       ///< ADC STC init configuration
          init_cc_ref_sel_flg:1,///< CC RX_REF_SEL init configured flag
          init_cc_ref_sel:2,    ///< CC RX_REF_SEL init configuration
          reserved:2;

    // 7th 32 bits
    u32_t runtime_ldo2_flg:1,   ///< LDO2 runtime configured flag for SRC BIST sending
          runtime_ldo2:5,       ///< LDO2 runtime configuration for SRC BIST sending
          runtime_rd_flg:1,     ///< RD runtime configured flag for SNK BIST sending
          runtime_rd:4,         ///< RD runtime configuration for SNK BIST sending
          runtime_cc_freq_flg:1,///< CC freq init configured flag
          runtime_cc_freq:8,    ///< CC freq init configuration
          init_ldo2_flg:1,      ///< LDO2 init configured flag
          init_ldo2:5,          ///< LDO2 init configuration
          init_cc_es_flg:1,     ///< CC ES init configured flag
          init_cc_es:3,         ///< CC ES init configuration
          init_cc_read_cnt_flg:1,
          epr_check_keepalive_disabled:1;


    // 8th 32 bits
    u32_t load_step:4;      /* Load Step
                                Bit Description
                                1~0 00b: 150mA/us Load Step (default)
                                    01b: 500mA/us Load Step
                                    11b~10b: Reserved and Shall Not be used
                                2~3 Reserved and Shall be set to zero
                             */
    u32_t load_step_magnitude:4;    /* Load Step Magnitude
                                        Bit Description
                                        0   0b: 25% IoC (default)
                                            1b: 90% IoC
                                        1~3 Reserved and Shall be set to zero
                                     */
    u32_t holdup_time:8;        /* Holdup Time
                                 * Output will stay with regulated limits for this number of
                                 * milliseconds after removal of the AC from the input.
                                 * 0x00 = feature not supported
                                 * Note: a value of 3ms Should be used
                                 */
    u32_t compliance:8;        /*  Bit Description
                                0   LPS compliant when set
                                1   PS1 compliant when set
                                2   PS2 compliant when set
                                3~7 Reserved and Shall be set to zero
                                */
    u32_t touch_current:8;     /*  Bit Description
                                0   Low touch Current EPS when set
                                1   Ground pin supported when set
                                2   Ground pin intended for protective earth when set
                                3~7 Reserved and Shall be set to zero
                                */

    // 9th 32 bits
    u32_t peak_current1:16;    /*  Bit     Description
                                0~4     Percent overload in 10% increments, Values higher than 25 (11001b) are clipped to 250%.
                                5~10    Overload period in 20ms
                                11~14   Duty cycle in 5% increments
                                15      VBUS Voltage droop
                             */
    u32_t peak_current2:16;    /*  Bit     Description
                                0~4     Percent overload in 10% increments, Values higher than 25 (11001b) are clipped to 250%.
                                5~10    Overload period in 20ms
                                11~14   Duty cycle in 5% increments
                                15      VBUS Voltage droop
                             */

    // 10th 32 bits
    u32_t peak_current3:16;    /*  Bit     Description
                                0~4     Percent overload in 10% increments, Values higher than 25 (11001b) are clipped to 250%.
                                5~10    Overload period in 20ms
                                11~14   Duty cycle in 5% increments
                                15      VBUS Voltage droop
                             */
    u32_t touch_temp:8;        /* Temperature conforms to:
                                0 = [IEC 60950-1] (default)
                                1 = [IEC 62368-1] TS1
                                2 = [IEC 62368-1] TS2
                                Note: All other values Reserved */
    u32_t src_inputs:8;        /*  Bit Description
                                0   0b: No external supply
                                    1b: External supply present
                                1   If bit 0 is set:
                                    0b: External supply is constrained
                                    1b: External supply is unconstrained
                                    If bit 0 is not set Reserved and Shall be set to zero
                                2   0b: No internal Battery
                                    1b: Internal Battery present
                                3~7 Reserved and Shall be set to zero */

    // 11th 32 bits
    u32_t hot_swappable_batteries:4;    /*  B0 corresponds to Battery 4 and B3 corresponds to Battery 7 */
    u32_t fixed_batteries:4;            /*  B0 corresponds to Battery 0 and B3 corresponds to Battery 3 */
    u32_t src_pdp:8;           /*  0~6: Source's rated PDP
                                7: Reserved and Shall be set to zero */
    u32_t load_characteristics:16; /*  Bit     Description
                                    0~4     Percent overload in 10% increments
                                            Values higher than 25 (11001b) are clipped to 250%. 00000b is the default.
                                    5~10    Overload period in 20ms when bits 0~4 non-zero.
                                    11~14   Duty cycle in 5% increments when bits 0-4 are non-zero
                                    15      Can tolerate VBUS Voltage droopd
                                 */

    // 12th 32 bits
    u32_t snk_modes:8;         /*  Bit Description
                                0   1: PPS charging supported
                                1   1: VBUS powered
                                2   1: Mains powered
                                3   1: Battery powered
                                4   1: Battery essentially unlimited
                                5~7 Reserved and Shall be set to zero
                                */
    u32_t minimum_pdp:8;       /*  Bit     Description
                                0~6     The Minimum PDP required by the Sink to operate without consuming any power from its Battery(s) should it have one.
                                7       Reserved and Shall be set to zero
                             */
    u32_t operational_pdp:8;   /*  Bit     Description
                                0~6     The PDP the Sink requires to operate normally. For Sinks with a Battery, it is the PDP Rating of the charger supplied with it or recommended for it.
                                7       Reserved and Shall be set to zero
                             */
    u32_t maximum_pdp:8;       /*  Bit     Description
                                0~6     The Maximum PDP the Sink can consume to operate and charge its Battery(s) should it have one.
                                7       Reserved and Shall be set to zero
                             */
    //13th 32 bits
    u32_t prs_easy:1;          ///> pwr swap condition
    u32_t w8s_try_src_en:1;     ///> sys power on wait 8s do try src
    u32_t vsafe0_use_large_en:1;///> vsafe0 > 800mv
    u32_t epr_mode_en:1;        ///> epr mode suport flag
    u32_t operational_pdp_epr:8; ///> Epr Mode The PDP the Sink requires to operate normally
    u32_t snk_pps_volt_change_by_ctrl:1;///> snk pps volt req by dpm
    u32_t dc_vbat_sel:1;        ///> 0;internal reg set;1 external res set;
    u32_t dc_vbus_output_sel:1;///> 0;internal reg set;1 external res set;
    u32_t init_ldo1_flg:1;      ///< LDO1 init configured flag
    u32_t init_ldo1:5;          ///< LDO1 init configuration
    u32_t init_cc_read_cnt:4;
    u32_t vbus_drop_check_vsafe5v_only:1;
    u32_t reserved6:6;

    POWER_PROFILE_t power;

    VDM_CFG_t vdm;
} PORT_CFG_t;

/** PD Global Configuration definition */
typedef struct USB_PD_CONFIG_s
{
    u32_t test_mode:1,      ///< 0: disable, 1: enable
          debug:3,          ///< 0: debug off, 1: debug on, 2: debug detail, 3: debug detail+; 4: intr
          prod_type:3,      ///< UFP or Cable plug product type, defined in UPD_PRODUCT_TYPE_t
          dfp_prod_type:3,  ///< DFP product type, defined in UPD_DFP_PROD_TYPE_e
          cable_plug:1,     ///< 0: disable cable plug, 1: enable cable plug
          capture_mode:1,   ///< 0: disable capture mode, 1: enable capture mode
          port_num:2,       ///< port number, read only
          oled_display:1,	///< 0: disable, 1: enable OLED display
          oled_display_dir:1,   ///< 0: HORIZONTAL(2), 1: HORIZONTAL(3)

          hw_ver:8,
          fw_ver:8;

    u32_t vdm_modal;

    /* USB configuration */
    VD_USB_CFG_t vd_usb;

    /* DPM Port configuration */
    PORT_CFG_t port_cfg;

    u8_t mfr_info[ALIGN_32BITS(UPD_EXT_MSG_MFR_MAX_STRING_LEN+1)];

} USB_PD_CONFIG_t;

#pragma pack()

extern volatile USB_PD_CONFIG_t *gp_usbpd_cfg;

/** \name  PD Configuration Interfaces
 * \{
 */

/** Configure testing mode */
#define usbpd_cfg_pps_volt_change_byctrl_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.snk_pps_volt_change_by_ctrl = val; \
    } while(0)

/** Get testing mode */
#define usbpd_cfg_pps_volt_change_byctrl_get() \
    (gp_usbpd_cfg->port_cfg.snk_pps_volt_change_by_ctrl)


/** Configure testing mode */
#define usbpd_cfg_test_mode_set(val) \
    do { \
        gp_usbpd_cfg->test_mode = val; \
    } while(0)

/** Get testing mode */
#define usbpd_cfg_test_mode_get() \
    (gp_usbpd_cfg->test_mode)


/** Configure debug level */
#define usbpd_cfg_dbg_set(val) \
    do { \
        gp_usbpd_cfg->debug = val; \
    } while(0)

/** Get debug level */
#define usbpd_cfg_dbg_get() \
    (gp_usbpd_cfg->debug)


/** Configure product type */
#define usbpd_cfg_prod_type_set(val) \
    do { \
        gp_usbpd_cfg->prod_type = val; \
    } while(0)

/** Get product type */
#define usbpd_cfg_prod_type_get() \
    (gp_usbpd_cfg->prod_type)

/** Configure DFP product type */
#define usbpd_cfg_dfp_prod_type_set(val) \
    do { \
        gp_usbpd_cfg->dfp_prod_type = val; \
    } while(0)

/** Get DFP product type */
#define usbpd_cfg_dfp_prod_type_get() \
    (gp_usbpd_cfg->dfp_prod_type)


/** Configure cable plug mode */
#define usbpd_cfg_cable_plug_set(val) \
    do { \
        gp_usbpd_cfg->cable_plug = val; \
    } while(0)

/** Get cable plug mode */
#define usbpd_cfg_cable_plug_get() \
    (gp_usbpd_cfg->cable_plug)


/** Configure capture */
#define usbpd_cfg_capture_mode_set(val) \
    do { \
        gp_usbpd_cfg->capture_mode = val; \
    } while(0)

/** Get capture mode */
#define usbpd_cfg_capture_mode_get() \
    (gp_usbpd_cfg->capture_mode)


/** Get port number */
#define usbpd_cfg_port_num_get() \
    (gp_usbpd_cfg->port_num)


/** Configure OLED display mode */
#define usbpd_cfg_oled_display_mode_set(val) \
    do { \
        gp_usbpd_cfg->oled_display = val; \
    } while(0)

/** Get OLED display mode */
#define usbpd_cfg_oled_display_mode_get() \
    (gp_usbpd_cfg->oled_display)


/** Configure OLED display direction */
#define usbpd_cfg_oled_display_dir_set(val) \
    do { \
        gp_usbpd_cfg->oled_display_dir = val; \
    } while(0)

/** Get OLED display direction */
#define usbpd_cfg_oled_display_dir_get() \
    (gp_usbpd_cfg->oled_display_dir)



/** Set hardware version  */
#define usbpd_cfg_hw_ver_set(ver) \
    do { \
        gp_usbpd_cfg->hw_ver = ver; \
    } while(0)

/** Get hardware version */
#define usbpd_cfg_hw_ver_get() \
    (gp_usbpd_cfg->hw_ver)


/** Set firmware version  */
#define usbpd_cfg_fw_ver_set(ver) \
    do { \
        gp_usbpd_cfg->fw_ver = ver; \
    } while(0)

/** Get firmware version */
#define usbpd_cfg_fw_ver_get() \
    (gp_usbpd_cfg->fw_ver)


/** Get VDM Modal value */
#define usbpd_cfg_vdm_modal_get() \
    (gp_usbpd_cfg->vdm_modal)

/** Configure VDM Modal value */
#define usbpd_cfg_vdm_modal_set(val) \
    do { \
        gp_usbpd_cfg->vdm_modal = val; \
    } while(0)


/** Set vendor defined svid */
#define usbpd_cfg_vd_usb_svid_set(val) \
    do { \
        gp_usbpd_cfg->vd_usb.svid = val; \
    } while(0)

/** Get vendor defined svid */
#define usbpd_cfg_vd_usb_svid_get() \
    (gp_usbpd_cfg->vd_usb.svid)

/** Set vendor defined USB VID */
#define usbpd_cfg_vd_usb_vid_set(val) \
    do { \
        gp_usbpd_cfg->vd_usb.vid = val; \
    } while(0)

/** Get vendor defined USB VID */
#define usbpd_cfg_vd_usb_vid_get() \
    (gp_usbpd_cfg->vd_usb.vid)

/** Set vendor defined USB test ID */
#define usbpd_cfg_vd_usb_tid_set(val) \
    do { \
        gp_usbpd_cfg->vd_usb.tid = val; \
    } while(0)

/** Get vendor defined USB test ID */
#define usbpd_cfg_vd_usb_tid_get() \
    (gp_usbpd_cfg->vd_usb.tid)

/** Set vendor defined USB bcd device */
#define usbpd_cfg_vd_usb_bcd_device_set(val) \
    do { \
        gp_usbpd_cfg->vd_usb.bcd_device = val; \
    } while(0)

/** Get vendor defined USB bcd device */
#define usbpd_cfg_vd_usb_bcd_device_get() \
    (gp_usbpd_cfg->vd_usb.bcd_device)

/** Set vendor defined USB product ID */
#define usbpd_cfg_vd_usb_prod_id_set(val) \
    do { \
        gp_usbpd_cfg->vd_usb.prod_id = val; \
    } while(0)

/** Get vendor defined USB product ID */
#define usbpd_cfg_vd_usb_prod_id_get() \
    (gp_usbpd_cfg->vd_usb.prod_id)


/** Set port quick charge enable */
#define usbpd_cfg_port_quick_charge_en_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.quick_charge_en = val; \
    } while(0)

/** Get port quick charge enable */
#define usbpd_cfg_port_quick_charge_en_get() \
    (gp_usbpd_cfg->port_cfg.quick_charge_en)


/** Set port quick charge version */
#define usbpd_cfg_port_quick_charge_ver_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.quick_charge_ver = val; \
    } while(0)

/** Get port quick charge version */
#define usbpd_cfg_port_quick_charge_ver_get() \
    (gp_usbpd_cfg->port_cfg.quick_charge_ver)


/** Set port auto_power_down enable */
#define usbpd_cfg_port_auto_power_down_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.auto_power_down = flg; \
    } while(0)

/** Get port auto_power_down enable */
#define usbpd_cfg_port_auto_power_down_get() \
    (gp_usbpd_cfg->port_cfg.auto_power_down)


/** Set port power bank enable */
#define usbpd_cfg_port_power_bank_en_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.power_bank_en = flg; \
    } while(0)

/** Get port power bank enable */
#define usbpd_cfg_port_power_bank_en_get() \
    (gp_usbpd_cfg->port_cfg.power_bank_en)


/** Set port battery cell */
#define usbpd_cfg_port_bat_cell_set(v) \
    do { \
        gp_usbpd_cfg->port_cfg.bat_cell = v; \
    } while(0)

/** Get port battery cell */
#define usbpd_cfg_port_bat_cell_get() \
    (gp_usbpd_cfg->port_cfg.bat_cell)


/** Set port USB-A function enable */
#define usbpd_cfg_port_usba_en_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.usba_en = flg; \
    } while(0)

/** Get port USB-A function enable */
#define usbpd_cfg_port_usba_en_get() \
    (gp_usbpd_cfg->port_cfg.usba_en)


/** Set port USB-A voltage calibration enable */
#define usbpd_cfg_port_usba_volt_calibration_en_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.usba_volt_calibration = flg; \
    } while(0)

/** Get port USB-A voltage calibration enable */
#define usbpd_cfg_port_usba_volt_calibration_en_get() \
    (gp_usbpd_cfg->port_cfg.usba_volt_calibration)


/** Set port cable type */
#define usbpd_cfg_port_cbl_type_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.cbl_type = val; \
    } while(0)

/** Get port cable type */
#define usbpd_cfg_port_cbl_type_get() \
    (gp_usbpd_cfg->port_cfg.cbl_type)


/** Set port CC1 disable */
#define usbpd_cfg_port_cc1_dis_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.cc1_disabled = flg; \
    } while(0)

/** Get port CC1 disabled */
#define usbpd_cfg_port_cc1_dis_get() \
    (gp_usbpd_cfg->port_cfg.cc1_disabled)


/** Set port CC2 disable */
#define usbpd_cfg_port_cc2_dis_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.cc2_disabled = flg; \
    } while(0)

/** Get port CC2 disabled */
#define usbpd_cfg_port_cc2_dis_get() \
    (gp_usbpd_cfg->port_cfg.cc2_disabled)


/** Set UFP receiving all packets flag */
#define usbpd_cfg_port_ufp_rx_all_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.ufp_rx_all = flg; \
    } while(0)

/** Get UFP Sink receiving all packets flag */
#define usbpd_cfg_port_ufp_rx_all_get() \
    (gp_usbpd_cfg->port_cfg.ufp_rx_all)


/** Set DRP toggle randomly disabled flag */
#define usbpd_cfg_port_drp_toggle_randomly_disabled_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.drp_toggle_randomly_disabled = flg; \
    } while(0)

/** Get DRP toggle randomly disabled flag */
#define usbpd_cfg_port_drp_toggle_randomly_disabled_get() \
    (gp_usbpd_cfg->port_cfg.drp_toggle_randomly_disabled)


/** Set over temperature protection disabled flag */
#define usbpd_cfg_port_otp_disabled_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.otp_disabled = flg; \
    } while(0)

/** Get over temperature protection disabled flag */
#define usbpd_cfg_port_otp_disabled_get() \
    (gp_usbpd_cfg->port_cfg.otp_disabled)


/** Set port power source type */
#define usbpd_cfg_port_pwr_src_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.pwr_src = val; \
    } while(0)

/** Get port power source type */
#define usbpd_cfg_port_pwr_src_get() \
    (gp_usbpd_cfg->port_cfg.pwr_src)


/** Set port default PD role */
#define usbpd_cfg_port_def_pdr_set(role) \
    do { \
        gp_usbpd_cfg->port_cfg.def_pdr = role; \
    } while(0)

/** Get port default PD role */
#define usbpd_cfg_port_def_pdr_get() \
    (gp_usbpd_cfg->port_cfg.def_pdr)


/** Set port default USB power role */
#define usbpd_cfg_port_def_pr_set(role) \
    do { \
        gp_usbpd_cfg->port_cfg.def_usb_pr = role; \
    } while(0)

/** Get port default USB power role */
#define usbpd_cfg_port_def_pr_get() \
    (gp_usbpd_cfg->port_cfg.def_usb_pr)


/** Set port default USB data role */
#define usbpd_cfg_port_def_dr_set(role) \
    do { \
        gp_usbpd_cfg->port_cfg.def_usb_dr = role; \
    } while(0)

/** Get port default USB data role */
#define usbpd_cfg_port_def_dr_get() \
    (gp_usbpd_cfg->port_cfg.def_usb_dr)


/** Set port specification revision */
#define usbpd_cfg_port_spec_rev_set(rev) \
    do { \
        gp_usbpd_cfg->port_cfg.spec_rev = rev; \
    } while(0)

/** Get port specification revision */
#define usbpd_cfg_port_spec_rev_get() \
    (gp_usbpd_cfg->port_cfg.spec_rev)


/** Set port try source */
#define usbpd_cfg_port_try_src_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.try_src = en; \
    } while(0)

/** Get port try source */
#define usbpd_cfg_port_try_src_get() \
    (gp_usbpd_cfg->port_cfg.try_src)


/** Set port try sink */
#define usbpd_cfg_port_try_snk_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.try_snk = en; \
    } while(0)

/** Get port try sink */
#define usbpd_cfg_port_try_snk_get() \
    (gp_usbpd_cfg->port_cfg.try_snk)


/** Set port dual role power */
#define usbpd_cfg_port_dual_role_pwr_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.dual_role_pwr = en; \
    } while(0)

/** Get port dual role power */
#define usbpd_cfg_port_dual_role_pwr_get() \
    (gp_usbpd_cfg->port_cfg.dual_role_pwr)


/** Set port USB suspend supported */
#define usbpd_cfg_port_usb_susp_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.usb_susp_supp = en; \
    } while(0)

/** Get port USB suspend supported */
#define usbpd_cfg_port_usb_susp_get() \
    (gp_usbpd_cfg->port_cfg.usb_susp_supp)


/** Set port externally powered */
#define usbpd_cfg_port_ext_pwr_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.ext_pwr = en; \
    } while(0)

/** Get port externally powered */
#define usbpd_cfg_port_ext_pwr_get() \
    (gp_usbpd_cfg->port_cfg.ext_pwr)


/** Set port USB communications capable */
#define usbpd_cfg_port_usb_comm_cap_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.usb_comm_cap = en; \
    } while(0)

/** Get port USB communications capable */
#define usbpd_cfg_port_usb_comm_cap_get() \
    (gp_usbpd_cfg->port_cfg.usb_comm_cap)


/** Set port data role capability */
#define usbpd_cfg_port_drs_cap_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.drs_cap = en; \
    } while(0)

/** Get port data role capability */
#define usbpd_cfg_port_drs_cap_get() \
    (gp_usbpd_cfg->port_cfg.drs_cap)


/** Set port no PD mode */
#define usbpd_cfg_port_no_pd_mode_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.no_pd_mode = en; \
    } while(0)

/** Get port no PD mode */
#define usbpd_cfg_port_no_pd_mode_get() \
    (gp_usbpd_cfg->port_cfg.no_pd_mode)


/** Set port VDM enabled */
#define usbpd_cfg_port_vdm_en_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm_en = en; \
    } while(0)

/** Get port VDM enabled */
#define usbpd_cfg_port_vdm_en_get() \
    (gp_usbpd_cfg->port_cfg.vdm_en)


/** Set port  VDM Responsed to UFP Discovery Identity  */
#define usbpd_cfg_port_vdm_resp_ufp_en_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm_resp_ufp_en = en; \
    } while(0)

/** Get port enabled state VDM Responsed to UFP Discovery Identity */
#define usbpd_cfg_port_vdm_resp_ufp_en_get() \
    (gp_usbpd_cfg->port_cfg.vdm_resp_ufp_en)


/** Set port VDM SRC startup enabled */
#define usbpd_cfg_port_vdm_src_startup_en_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm_src_startup_en = en; \
    } while(0)

/** Get port VDM SRC startup enabled */
#define usbpd_cfg_port_vdm_src_startup_en_get() \
    (gp_usbpd_cfg->port_cfg.vdm_src_startup_en)


/** Set port power limited */
#define usbpd_cfg_port_power_limited_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.power_limited = en; \
    } while(0)

/** Get port power limited */
#define usbpd_cfg_port_power_limited_get() \
    (gp_usbpd_cfg->port_cfg.power_limited)


#define usbpd_cfg_port_load_step_get() \
	(gp_usbpd_cfg->port_cfg.load_step)

#define usbpd_cfg_port_load_step_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.load_step = val; \
	} while(0)


#define usbpd_cfg_port_load_step_magnitude_get() \
	(gp_usbpd_cfg->port_cfg.load_step_magnitude)

#define usbpd_cfg_port_load_step_magnitude_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.load_step_magnitude = val; \
	} while(0)


#define usbpd_cfg_port_holdup_time_get() \
	(gp_usbpd_cfg->port_cfg.holdup_time)

#define usbpd_cfg_port_holdup_time_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.holdup_time = val; \
	} while(0)


#define usbpd_cfg_port_compliance_get() \
	(gp_usbpd_cfg->port_cfg.compliance)

#define usbpd_cfg_port_compliance_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.compliance = val; \
	} while(0)


#define usbpd_cfg_port_touch_current_get() \
	(gp_usbpd_cfg->port_cfg.touch_current)

#define usbpd_cfg_port_touch_current_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.touch_current = val; \
	} while(0)


#define usbpd_cfg_port_peak_current1_get() \
	(gp_usbpd_cfg->port_cfg.peak_current1)

#define usbpd_cfg_port_peak_current1_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.peak_current1 = val; \
	} while(0)


#define usbpd_cfg_port_peak_current2_get() \
	(gp_usbpd_cfg->port_cfg.peak_current2)

#define usbpd_cfg_port_peak_current2_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.peak_current2 = val; \
	} while(0)


#define usbpd_cfg_port_peak_current3_get() \
	(gp_usbpd_cfg->port_cfg.peak_current3)

#define usbpd_cfg_port_peak_current3_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.peak_current3 = val; \
	} while(0)


#define usbpd_cfg_port_touch_temp_get() \
	(gp_usbpd_cfg->port_cfg.touch_temp)

#define usbpd_cfg_port_touch_temp_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.touch_temp = val; \
	} while(0)


#define usbpd_cfg_port_src_inputs_get() \
	(gp_usbpd_cfg->port_cfg.src_inputs)

#define usbpd_cfg_port_src_inputs_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.src_inputs = val; \
	} while(0)


#define usbpd_cfg_port_hot_swappable_batteries_get() \
	(gp_usbpd_cfg->port_cfg.hot_swappable_batteries)

#define usbpd_cfg_port_hot_swappable_batteries_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.hot_swappable_batteries = val; \
	} while(0)


#define usbpd_cfg_port_fixed_batteries_get() \
	(gp_usbpd_cfg->port_cfg.fixed_batteries)

#define usbpd_cfg_port_fixed_batteries_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.fixed_batteries = val; \
	} while(0)


#define usbpd_cfg_port_battery_num_get() \
	(set_bits_get(gp_usbpd_cfg->port_cfg.fixed_batteries)+(set_bits_get(gp_usbpd_cfg->port_cfg.hot_swappable_batteries)<<4))


#define usbpd_cfg_port_src_pdp_get() \
	(gp_usbpd_cfg->port_cfg.src_pdp)

#define usbpd_cfg_port_src_pdp_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.src_pdp = val; \
	} while(0)


#define usbpd_cfg_port_load_characteristics_get() \
	(gp_usbpd_cfg->port_cfg.load_characteristics)

#define usbpd_cfg_port_load_characteristics_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.load_characteristics = val; \
	} while(0)


#define usbpd_cfg_port_snk_modes_get() \
	(gp_usbpd_cfg->port_cfg.snk_modes)

#define usbpd_cfg_port_snk_modes_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.snk_modes = val; \
	} while(0)


#define usbpd_cfg_port_minimum_pdp_get() \
	(gp_usbpd_cfg->port_cfg.minimum_pdp)

#define usbpd_cfg_port_minimum_pdp_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.minimum_pdp = val; \
	} while(0)


#define usbpd_cfg_port_operational_pdp_get() \
	(gp_usbpd_cfg->port_cfg.operational_pdp)

#define usbpd_cfg_port_operational_pdp_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.operational_pdp = val; \
	} while(0)
// epr snk req pdp
#define usbpd_cfg_port_epr_operational_pdp_get() \
	(gp_usbpd_cfg->port_cfg.operational_pdp_epr)

#define usbpd_cfg_port_epr_operational_pdp_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.operational_pdp_epr = val; \
	} while(0)

#define usbpd_cfg_port_maximum_pdp_get() \
	(gp_usbpd_cfg->port_cfg.maximum_pdp)

#define usbpd_cfg_port_maximum_pdp_set(val) \
	do { \
		gp_usbpd_cfg->port_cfg.maximum_pdp = val; \
	} while(0)


/** Get source supply power data object */
#define usbpd_cfg_port_src_pdo_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].u32data[0])

/** Set source supply power data object */
#define usbpd_cfg_port_src_pdo_set(idx,obj) \
    do { \
        gp_usbpd_cfg->port_cfg.power.src.caps[idx].u32data[0] = (u32_t)(obj); \
    } while(0)


/** Get the PWM duty of the source supply power data object */
#define usbpd_cfg_port_src_pdo_pwm_duty_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].u32data[1])

/** Set the PWM duty of the source supply power data object */
#define usbpd_cfg_port_src_pdo_pwm_duty_set(idx,obj) \
    do { \
        gp_usbpd_cfg->port_cfg.power.src.caps[idx].u32data[1] = (u32_t)(obj); \
    } while(0)


/** Get the PWM duty of the source supply power data object */
#define usbpd_cfg_port_src_pdo_pwm_max_duty_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].u32data[2])

/** Set the PWM duty of the source supply power data object */
#define usbpd_cfg_port_src_pdo_pwm_max_duty_set(idx,obj) \
    do { \
        gp_usbpd_cfg->port_cfg.power.src.caps[idx].u32data[2] = (u32_t)(obj); \
    } while(0)


/** Get source power supply type */
#define usbpd_cfg_port_src_pwr_supply_type_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].fixed.supply_type)

/** Get source capability number */
#define usbpd_cfg_port_src_cap_num_get() \
    (gp_usbpd_cfg->port_cfg.power.src.cap_num)

/** Get source capability number */
#define usbpd_cfg_port_epr_src_cap_num_get() \
    (gp_usbpd_cfg->port_cfg.power.src.epr_cap_num)

/** Get source pwm en capability */
#define usbpd_cfg_port_src_pwm_en_get() \
    (gp_usbpd_cfg->port_cfg.power.src.pwm_en)

/** Set source pwm en */
#define usbpd_cfg_port_src_pwm_en_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.src.pwm_en = val; \
    } while(0)

/** Get source pwm per */
#define usbpd_cfg_port_src_pwm_per_get() \
    (gp_usbpd_cfg->port_cfg.power.src.pwm_per)

/** Set source pwm per */
#define usbpd_cfg_port_src_pwm_per_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.src.pwm_per = val; \
    } while(0)

/** Get source fixed power profile */
#define usbpd_cfg_port_src_fixed_pwr_prof_get() \
    (gp_usbpd_cfg->port_cfg.power.src.profile)

/** Get source fixed power profile changed flag */
#define usbpd_cfg_port_src_fixed_pwr_prof_changed_flag_get() \
    (gp_usbpd_cfg->port_cfg.power.src.profile_changed)

/** Set source fixed power profile changed flag */
#define usbpd_cfg_port_src_fixed_pwr_prof_changed_flag_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.power.src.profile_changed = flg; \
    } while(0)

/** Get source fixed power voltage */
#define usbpd_cfg_port_src_fixed_pwr_volt_cap_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].fixed.max_volt)

/** Get source fixed power current */
#define usbpd_cfg_port_src_fixed_pwr_curr_cap_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].fixed.max_curr)

/** Get source fixed power peak current */
#define usbpd_cfg_port_src_fixed_pwr_peak_curr_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].fixed.peak_curr)

/** Get source fixed power pwm duty */
#define usbpd_cfg_port_src_fixed_pwr_pwm_duty_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].fixed.pwm_duty)

/** Set source fixed power pwm duty */
#define usbpd_cfg_port_src_fixed_pwr_pwm_duty_set(idx,val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.src.caps[idx].fixed.pwm_duty = val; \
    } while(0)


/** Get source battery power minimal voltage */
#define usbpd_cfg_port_src_battery_pwr_min_volt_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].battery.min_volt)

/** Get source battery power maximal voltage */
#define usbpd_cfg_port_src_battery_pwr_max_volt_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].battery.max_volt)

/** Get source battery power maximal allow power */
#define usbpd_cfg_port_src_battery_pwr_max_allow_pwr_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].battery.max_allow_pwr)


/** Get source variable power voltage */
#define usbpd_cfg_port_src_vari_pwr_min_volt_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].variable.min_volt)

/** Get source variable power voltage */
#define usbpd_cfg_port_src_vari_pwr_max_volt_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].variable.max_volt)

/** Get source variable power maximal current */
#define usbpd_cfg_port_src_vari_pwr_max_curr_get(idx) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[idx].variable.max_curr)


/** Get source PPS type */
#define usbpd_cfg_port_src_pps_type_get(flg) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[flg].pps.pps)

/** Get source PPS power min voltage */
#define usbpd_cfg_port_src_pps_pwr_min_volt_get(flg) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[flg].pps.min_volt)

/** Get source PPS power max voltage */
#define usbpd_cfg_port_src_pps_pwr_max_volt_get(flg) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[flg].pps.max_volt)

/** Get source PPS power maximal current */
#define usbpd_cfg_port_src_pps_pwr_max_curr_get(flg) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[flg].pps.max_curr)

/** Get source PPS power PWM duty value */
u32_t usbpd_cfg_port_src_pps_pwr_pwm_duty_get(u32_t idx, u32_t voltage);

/** Get source AVS power min voltage */
#define usbpd_cfg_port_src_avs_pwr_min_volt_get(flg) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[flg].avs.min_volt)

/** Get source AVS power max voltage */
#define usbpd_cfg_port_src_avs_pwr_max_volt_get(flg) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[flg].avs.max_volt)

/** Get source AVS power maximal current */
#define usbpd_cfg_port_src_avs_pwr_max_pdp_get(flg) \
    (gp_usbpd_cfg->port_cfg.power.src.caps[flg].avs.pdp)


/** Get sink power profile */
#define usbpd_cfg_port_snk_pwr_prof_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.profile)

/** Get sink epr power profile */
#define usbpd_cfg_port_snk_epr_pwr_prof_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.epr_profile)

/** Set sink power profile */
#define usbpd_cfg_port_snk_pwr_prof_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.profile = val; \
    } while(0)

/** Set sink epr power profile */
#define usbpd_cfg_port_snk_epr_pwr_prof_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.epr_profile = val; \
    } while(0)

/** Get sink power PPS enabled state */
#define usbpd_cfg_port_snk_pwr_pps_en_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.pps_en)


/** Set sink power PPS enabled state */
#define usbpd_cfg_port_snk_pwr_pps_en_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.pps_en = flg; \
    } while(0)

 /** Get sink epr power AVS enabled state */
#define usbpd_cfg_port_snk_epr_pwr_pps_en_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.epr_avs_en)


/** Set sink epr power AVS enabled state */
#define usbpd_cfg_port_snk_epr_pwr_pps_en_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.epr_avs_en = flg; \
    } while(0)

/** Get sink power acceptable voltage */
#define usbpd_cfg_port_snk_pwr_acceptable_volt_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.acceptable_volt)

/** Get sink epr  power acceptable voltage */
#define usbpd_cfg_port_snk_epr_pwr_acceptable_volt_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.epr_acceptable_volt)

/** Set sink power acceptable voltage */
#define usbpd_cfg_port_snk_pwr_acceptable_volt_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.acceptable_volt = flg; \
    } while(0)

 /** Set sink epr power acceptable voltage */
#define usbpd_cfg_port_snk_epr_pwr_acceptable_volt_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.epr_acceptable_volt = flg; \
    } while(0)

/** Get sink power maximal operating current */
#define usbpd_cfg_port_snk_pwr_max_curr_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.max_opr_curr)

/** Set sink power maximal operating current */
#define usbpd_cfg_port_snk_pwr_max_curr_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.max_opr_curr = val; \
    } while(0)

 /** Get sink epr power maximal operating current */
#define usbpd_cfg_port_snk_epr_pwr_max_curr_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.epr_max_opr_curr)

 /** Set sink epr power maximal operating current */
#define usbpd_cfg_port_snk_epr_pwr_max_curr_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.epr_max_opr_curr = val; \
    } while(0)

/** Get sink power operating voltage */
#define usbpd_cfg_port_snk_pwr_volt_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.opr_volt)

/** Get sink epr power operating voltage */
#define usbpd_cfg_port_snk_epr_pwr_volt_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.epr_opr_volt)

/** Set sink power operating voltage */
#define usbpd_cfg_port_snk_pwr_volt_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.opr_volt = val; \
    } while(0)
/** Set sink epr power operating voltage */
#define usbpd_cfg_port_snk_epr_pwr_volt_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.epr_opr_volt = val; \
    } while(0)

/** Get sink power operating current */
#define usbpd_cfg_port_snk_pwr_curr_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.opr_curr)

/** Set sink power operating current */
#define usbpd_cfg_port_snk_pwr_curr_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.opr_curr = val; \
    } while(0)

/** Get sink epr power operating current */
#define usbpd_cfg_port_snk_epr_pwr_curr_get() \
    (gp_usbpd_cfg->port_cfg.power.snk.epr_opr_curr)

 /** Set sink epr power operating current */
#define usbpd_cfg_port_snk_epr_pwr_curr_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.power.snk.epr_opr_curr = val; \
    } while(0)

/** Set structured VDM version  */
#define usbpd_cfg_port_vdm_struct_ver_set(ver) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.struct_vdm_ver = ver; \
    } while(0)

/** Get structured VDM version */
#define usbpd_cfg_port_vdm_struct_ver_get() \
    (gp_usbpd_cfg->port_cfg.vdm.struct_vdm_ver)


/** Set VDM USB host data capable  */
#define usbpd_cfg_port_vdm_usb_host_data_cap_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.usb_host_data_cap = en; \
    } while(0)

/** Get VDM USB host data capable */
#define usbpd_cfg_port_vdm_usb_host_data_cap_get() \
    (gp_usbpd_cfg->port_cfg.vdm.usb_host_data_cap)


/** Set VDM USB device data capable  */
#define usbpd_cfg_port_vdm_usb_dev_data_cap_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.usb_dev_data_cap = en; \
    } while(0)

/** Get VDM USB device data capable */
#define usbpd_cfg_port_vdm_usb_dev_data_cap_get() \
    (gp_usbpd_cfg->port_cfg.vdm.usb_dev_data_cap)


/** Set VDM modal operate supported  */
#define usbpd_cfg_port_vdm_modal_opr_supp_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.modal_opr_supp = en; \
    } while(0)

/** Get VDM modal operate supported */
#define usbpd_cfg_port_vdm_modal_opr_supp_get() \
    (gp_usbpd_cfg->port_cfg.vdm.modal_opr_supp)


/** Set VDM VBUS current capable  */
#define usbpd_cfg_port_vdm_vbus_curr_cap_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.vbus_curr_cap = val; \
    } while(0)

/** Get VDM VBUS current capable */
#define usbpd_cfg_port_vdm_vbus_curr_cap_get() \
    (gp_usbpd_cfg->port_cfg.vdm.vbus_curr_cap)


/** Set VDM VBUS through cable  */
#define usbpd_cfg_port_vdm_vbus_thr_cbl_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.vbus_thr_cbl = en; \
    } while(0)

/** Get VDM VBUS through cable */
#define usbpd_cfg_port_vdm_vbus_thr_cbl_get() \
    (gp_usbpd_cfg->port_cfg.vdm.vbus_thr_cbl)


/** Set VDM cable latency  */
#define usbpd_cfg_port_vdm_cbl_latency_set(latency) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.cbl_latency = latency; \
    } while(0)

/** Get VDM cable latency */
#define usbpd_cfg_port_vdm_cbl_latency_get() \
    (gp_usbpd_cfg->port_cfg.vdm.cbl_latency)


/** Set VDM cable termination type  */
#define usbpd_cfg_port_vdm_cbl_term_type_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.cbl_term_type = val; \
    } while(0)

/** Get VDM cable termination type */
#define usbpd_cfg_port_vdm_cbl_term_type_get() \
    (gp_usbpd_cfg->port_cfg.vdm.cbl_term_type)


/** Set VDM SOP" controller present  */
#define usbpd_cfg_port_vdm_sop2_ctrler_pres_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.sop2_ctrler_pres = en; \
    } while(0)

/** Get VDM SOP" controller present */
#define usbpd_cfg_port_vdm_sop2_ctrler_pres_get() \
    (gp_usbpd_cfg->port_cfg.vdm.sop2_ctrler_pres)


/** Set VDM VBUS required  */
#define usbpd_cfg_port_vdm_vbus_req_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.vbus_req = en; \
    } while(0)

/** Get VDM VBUS required */
#define usbpd_cfg_port_vdm_vbus_req_get() \
    (gp_usbpd_cfg->port_cfg.vdm.vbus_req)


/** Set VDM usb superspeed signaling support  */
#define usbpd_cfg_port_vdm_usb_ss_sig_supp_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.usb_ss_sig_supp = val; \
    } while(0)

/** Get VDM usb superspeed signaling support */
#define usbpd_cfg_port_vdm_usb_ss_sig_supp_get() \
    (gp_usbpd_cfg->port_cfg.vdm.usb_ss_sig_supp)


/** Set VDM VCONN power  */
#define usbpd_cfg_port_vdm_vcon_pwr_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.vcon_pwr = val; \
    } while(0)

/** Get VDM VCONN power */
#define usbpd_cfg_port_vdm_vcon_pwr_get() \
    (gp_usbpd_cfg->port_cfg.vdm.vcon_pwr)


/** Set VDM VCONN required  */
#define usbpd_cfg_port_vdm_vcon_req_set(en) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.vcon_req = en; \
    } while(0)

/** Get VDM VCONN required */
#define usbpd_cfg_port_vdm_vcon_req_get() \
    (gp_usbpd_cfg->port_cfg.vdm.vcon_req)


/** Set Cable VDM Maximum VBUS Voltage   */
#define usbpd_cfg_port_vdm_max_vbus_volt_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.max_vbus_volt = flg; \
    } while(0)

/** Get Cable VDM Maximum VBUS Voltage */
#define usbpd_cfg_port_vdm_max_vbus_volt_get() \
    (gp_usbpd_cfg->port_cfg.vdm.max_vbus_volt)


/** Set Cable vconn detected   */
#define usbpd_cfg_port_vconn_detect_set(flg) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.vconn_detected = flg; \
    } while(0)

/** Get Cable vconn detected */
#define usbpd_cfg_port_vconn_detected_get() \
    (gp_usbpd_cfg->port_cfg.vdm.vconn_detected)


/** Set VDM mode position  */
#define usbpd_cfg_port_vdm_mode_pos_set(pos) \
    do { \
        gp_usbpd_cfg->port_cfg.vdm.mode_pos = pos; \
    } while(0)

/** Get VDM mode position */
#define usbpd_cfg_port_vdm_mode_pos_get() \
    (gp_usbpd_cfg->port_cfg.vdm.mode_pos)


/** Configure current source supply type */
#define usbpd_cfg_port_current_src_supply_type_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.curr_src_supply_type = val; \
    } while(0)

/** Get current source supply type */
#define usbpd_cfg_port_current_src_supply_type_get() \
    (gp_usbpd_cfg->port_cfg.curr_src_supply_type)


/** Set PD retransmission count  */
#define usbpd_cfg_port_retry_cnt_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.retry_cnt = val; \
    } while(0)

/** Get PD retransmission count  */
#define usbpd_cfg_port_retry_cnt_get() \
    (gp_usbpd_cfg->port_cfg.retry_cnt)


/** Set source minimal vRd  */
#define usbpd_cfg_port_vrd_min_src_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vrd_min_src = val; \
    } while(0)

/** Get source minimal vRd  */
#define usbpd_cfg_port_vrd_min_src_get() \
    (gp_usbpd_cfg->port_cfg.vrd_min_src)


/** Set source maximal vRd  */
#define usbpd_cfg_port_vrd_max_src_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vrd_max_src = val; \
    } while(0)

/** Get source maximal vRd  */
#define usbpd_cfg_port_vrd_max_src_get() \
    (gp_usbpd_cfg->port_cfg.vrd_max_src)


/** Set sink minimal vRd  */
#define usbpd_cfg_port_vrd_min_snk_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vrd_min_snk = val; \
    } while(0)

/** Get sink minimal vRd  */
#define usbpd_cfg_port_vrd_min_snk_get() \
    (gp_usbpd_cfg->port_cfg.vrd_min_snk)


/** Set sink maximal vRd  */
#define usbpd_cfg_port_vrd_max_snk_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vrd_max_snk = val; \
    } while(0)

/** Get sink maximal vRd  */
#define usbpd_cfg_port_vrd_max_snk_get() \
    (gp_usbpd_cfg->port_cfg.vrd_max_snk)


/** Set minimal vRa  */
#define usbpd_cfg_port_vra_min_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vra_min = val; \
    } while(0)

/** Get minimal vRa  */
#define usbpd_cfg_port_vra_min_get() \
    (gp_usbpd_cfg->port_cfg.vra_min)


/** Set maximal vRa  */
#define usbpd_cfg_port_vra_max_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vra_max = val; \
    } while(0)

/** Get maximal vRa  */
#define usbpd_cfg_port_vra_max_get() \
    (gp_usbpd_cfg->port_cfg.vra_max)


/** Set source vRd lost  */
#define usbpd_cfg_port_vopen_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vopen = val; \
    } while(0)

/** Get source vRd lost  */
#define usbpd_cfg_port_vopen_get() \
    (gp_usbpd_cfg->port_cfg.vopen)


/** Set port vbus check enable  */
#define usbpd_cfg_port_vbus_check_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vbus_check_en = val; \
    } while(0)

/** Get source vbus check enable  */
#define usbpd_cfg_port_vbus_check_get() \
    (gp_usbpd_cfg->port_cfg.vbus_check_en)


/** Set port vconn enable  */
#define usbpd_cfg_port_vconn_en_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vconn_en = val; \
    } while(0)

/** Get source vconn enable  */
#define usbpd_cfg_port_vconn_en_get() \
    (gp_usbpd_cfg->port_cfg.vconn_en)


/** Set port pps enable  */
#define usbpd_cfg_port_pps_en_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.pps_en = val; \
    } while(0)

/** Get source pps enable  */
#define usbpd_cfg_port_pps_en_get() \
    (gp_usbpd_cfg->port_cfg.pps_en)


/** Set port automatically power role swap enable  */
#define usbpd_cfg_port_prs_auto_en_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.prs_auto_en = val; \
    } while(0)

/** Get automatically power role swap enable  */
#define usbpd_cfg_port_prs_auto_en_get() \
    (gp_usbpd_cfg->port_cfg.prs_auto_en)

/** set automatically power role swap analyzing condition easy  */
#define usbpd_cfg_port_prs_easy_en_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.prs_easy = val; \
    } while(0)

/** Get automatically power role swap analyzing condition easy  */
#define usbpd_cfg_port_prs_easy_en_get()    \
    (gp_usbpd_cfg->port_cfg.prs_easy)

/** Set over current protection enable  */
#define usbpd_cfg_port_source_ocp_en_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.source_ocp_en = val; \
    } while(0)

/** Get over current protection enable  */
#define usbpd_cfg_port_source_ocp_en_get() \
    (gp_usbpd_cfg->port_cfg.source_ocp_en)


/** Set pps voltage step  */
#define usbpd_cfg_port_pps_volt_step_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.pps_volt_step = val; \
    } while(0)

/** Get pps voltage step  */
#define usbpd_cfg_port_pps_volt_step_get() \
    (gp_usbpd_cfg->port_cfg.pps_volt_step)




/** Get the CC half bit period init configured flag */
#define usbpd_cfg_port_init_cc_half_bit_flg_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_half_bit_flg)

/** Set the CC half bit period init configured flag  */
#define usbpd_cfg_port_init_cc_half_bit_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_half_bit_flg=val; \
    } while(0)



/** Get the CC half bit period init configuration */
#define usbpd_cfg_port_init_cc_half_bit_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_half_bit)

/** Set the CC half bit period init configuration  */
#define usbpd_cfg_port_init_cc_half_bit_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_half_bit=val; \
    } while(0)


/** Get the CC RX_FILTER_SEL init configured flag */
#define usbpd_cfg_port_init_cc_rx_filter_sel_flg_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_rx_filter_sel_flg)

/** Set the CC RX_FILTER_SEL init configured flag  */
#define usbpd_cfg_port_init_cc_rx_filter_sel_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_rx_filter_sel_flg=val; \
    } while(0)


/** Get the CC RX_FILTER_SEL init configuration */
#define usbpd_cfg_port_init_cc_rx_filter_sel_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_rx_filter_sel)

/** Set the CC RX_FILTER_SEL init configuration  */
#define usbpd_cfg_port_init_cc_rx_filter_sel_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_rx_filter_sel=val; \
    } while(0)


/** Get the ADC STC init configured flag */
#define usbpd_cfg_port_init_adc_stc_flg_get() \
    (gp_usbpd_cfg->port_cfg.init_adc_stc_flg)

/** Set the ADC STC init configured flag  */
#define usbpd_cfg_port_init_adc_stc_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_adc_stc_flg=val; \
    } while(0)


/** Get the ADC STC init configuration */
#define usbpd_cfg_port_init_adc_stc_get() \
    (gp_usbpd_cfg->port_cfg.init_adc_stc)

/** Set the ADC STC init configuration  */
#define usbpd_cfg_port_init_adc_stc_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_adc_stc=val; \
    } while(0)


/** Get the CC RX_REF_SEL init configured flag */
#define usbpd_cfg_port_init_cc_ref_sel_flg_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_ref_sel_flg)

/** Set the CC RX_REF_SEL init configured flag  */
#define usbpd_cfg_port_init_cc_ref_sel_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_ref_sel_flg=val; \
    } while(0)


/** Get the CC RX_REF_SEL init configuration */
#define usbpd_cfg_port_init_cc_ref_sel_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_ref_sel)

/** Set the CC RX_REF_SEL init configuration  */
#define usbpd_cfg_port_init_cc_ref_sel_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_ref_sel=val; \
    } while(0)


/** Get the LDO2 runtime configured flag */
#define usbpd_cfg_port_runtime_ldo2_flg_get() \
    (gp_usbpd_cfg->port_cfg.runtime_ldo2_flg)

/** Set the LDO2 runtime configured flag  */
#define usbpd_cfg_port_runtime_ldo2_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.runtime_ldo2_flg=val; \
    } while(0)



/** Get the LDO2 runtime configuration */
#define usbpd_cfg_port_runtime_ldo2_get() \
    (gp_usbpd_cfg->port_cfg.runtime_ldo2)

/** Set the LDO2 runtime configuration  */
#define usbpd_cfg_port_runtime_ldo2_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.runtime_ldo2=val; \
    } while(0)



/** Get the RD runtime configured flag */
#define usbpd_cfg_port_runtime_rd_flg_get() \
    (gp_usbpd_cfg->port_cfg.runtime_rd_flg)

/** Set the RD runtime configured flag  */
#define usbpd_cfg_port_runtime_rd_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.runtime_rd_flg=val; \
    } while(0)



/** Get the RD runtime configuration */
#define usbpd_cfg_port_runtime_rd_get() \
    (gp_usbpd_cfg->port_cfg.runtime_rd)

/** Set the RD runtime configuration  */
#define usbpd_cfg_port_runtime_rd_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.runtime_rd=val; \
    } while(0)



/** Get the CC frequency runtime configured flag */
#define usbpd_cfg_port_runtime_cc_freq_flg_get() \
    (gp_usbpd_cfg->port_cfg.runtime_cc_freq_flg)

/** Set the CC frequency runtime configured flag  */
#define usbpd_cfg_port_runtime_cc_freq_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.runtime_cc_freq_flg=val; \
    } while(0)



/** Get the CC frequency runtime configuration */
#define usbpd_cfg_port_runtime_cc_freq_get() \
    (gp_usbpd_cfg->port_cfg.runtime_cc_freq)

/** Set the CC frequency runtime configuration  */
#define usbpd_cfg_port_runtime_cc_freq_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.runtime_cc_freq=val; \
    } while(0)



/** Get the LDO2 init configured flag */
#define usbpd_cfg_port_init_ldo2_flg_get() \
    (gp_usbpd_cfg->port_cfg.init_ldo2_flg)

/** Set the LDO2 init configured flag  */
#define usbpd_cfg_port_init_ldo2_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_ldo2_flg=val; \
    } while(0)



/** Get the LDO2 init configuration */
#define usbpd_cfg_port_init_ldo2_get() \
    (gp_usbpd_cfg->port_cfg.init_ldo2)

/** Set the LDO2 init configuration  */
#define usbpd_cfg_port_init_ldo2_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_ldo2=val; \
    } while(0)



/** Get the LDO1 init configured flag */
#define usbpd_cfg_port_init_ldo1_flg_get() \
    (gp_usbpd_cfg->port_cfg.init_ldo1_flg)

/** Set the LDO1 init configured flag  */
#define usbpd_cfg_port_init_ldo1_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_ldo1_flg=val; \
    } while(0)



/** Get the LDO1 init configuration */
#define usbpd_cfg_port_init_ldo1_get() \
    (gp_usbpd_cfg->port_cfg.init_ldo1)

/** Set the LDO1 init configuration  */
#define usbpd_cfg_port_init_ldo1_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_ldo1=val; \
    } while(0)



/** Get the CC ES init configured flag */
#define usbpd_cfg_port_init_cc_es_flg_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_es_flg)

/** Set the CC ES init configured flag  */
#define usbpd_cfg_port_init_cc_es_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_es_flg=val; \
    } while(0)



/** Get the CC ES init configuration */
#define usbpd_cfg_port_init_cc_es_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_es)

/** Set the CC ES init configuration  */
#define usbpd_cfg_port_init_cc_es_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_es=val; \
    } while(0)

#if 0
/** Get the CC Edge init configured flag */
#define usbpd_cfg_port_init_cc_egctrl_flg_get() \
        (gp_usbpd_cfg->port_cfg.init_cc_egctrl_flag)

/** Set the CC Edge init configured flag  */
#define usbpd_cfg_port_init_cc_egctrl_flg_set(val) \
        do { \
            gp_usbpd_cfg->port_cfg.init_cc_egctrl_flag=val; \
        } while(0)



 /** Get the CC Edge init configuration */
#define usbpd_cfg_port_init_cc_egctrl_get() \
        (gp_usbpd_cfg->port_cfg.init_cc_egctrl)

 /** Set the CC Edge init configuration  */
#define usbpd_cfg_port_init_cc_egctrl_set(val) \
        do { \
            gp_usbpd_cfg->port_cfg.init_cc_egctrl=val; \
        } while(0)

#endif
/** Get the CC read count init configured flag */
#define usbpd_cfg_port_init_cc_read_cnt_flg_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_read_cnt_flg)

/** Set the CC read count init configured flag  */
#define usbpd_cfg_port_init_cc_read_cnt_flg_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_read_cnt_flg=val; \
    } while(0)



/** Get the CC read count init configuration */
#define usbpd_cfg_port_init_cc_read_cnt_get() \
    (gp_usbpd_cfg->port_cfg.init_cc_read_cnt)

/** Set the CC read count init configuration  */
#define usbpd_cfg_port_init_cc_read_cnt_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.init_cc_read_cnt=val; \
    } while(0)


 /** Set port epr keep alive disabled flag */
#define usbpd_cfg_port_epr_check_keepalive_disabled_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.epr_check_keepalive_disabled = val; \
    } while(0)

 /** Get epr keep alive disabled flag */
#define usbpd_cfg_port_epr_check_keepalive_disabled_get() \
        (gp_usbpd_cfg->port_cfg.epr_check_keepalive_disabled)


 /** Set port src epr enable  */
#define usbpd_cfg_port_epr_mode_en_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.epr_mode_en = val; \
    } while(0)

 /** Get source epr enable  */
#define usbpd_cfg_port_epr_mode_en_get() \
        (gp_usbpd_cfg->port_cfg.epr_mode_en)


 /** Set dc vbat sel  */
#define usbpd_cfg_port_dc_vbat_sel_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.dc_vbat_sel = val; \
    } while(0)

 /** Get dc vbat sel funtion  */
#define usbpd_cfg_port_dc_vbat_sel_get() \
        (gp_usbpd_cfg->port_cfg.dc_vbat_sel)

/** Set dc vbus output sel  */
#define usbpd_cfg_port_dc_vbus_output_sel_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.dc_vbus_output_sel = val; \
    } while(0)

 /** Get dc vbus output selfuntion  */
#define usbpd_cfg_port_dc_vbus_output_sel_get() \
        (gp_usbpd_cfg->port_cfg.dc_vbus_output_sel)

/** Set manufacturer info  */
#define usbpd_cfg_mfr_info_set(pval,len) \
    do { \
        if (len < UPD_EXT_MSG_MFR_MAX_STRING_LEN) \
        { \
            memcpy((void *)(gp_usbpd_cfg->mfr_info), pval, len); \
            gp_usbpd_cfg->mfr_info[len] = 0; \
        } else { \
            memcpy((void *)(gp_usbpd_cfg->mfr_info), pval, UPD_EXT_MSG_MFR_MAX_STRING_LEN); \
            gp_usbpd_cfg->mfr_info[UPD_EXT_MSG_MFR_MAX_STRING_LEN] = 0; \
        } \
    } while(0)

/** Get manufacturer info  */
#define usbpd_cfg_mfr_info_get() \
    (&(gp_usbpd_cfg->mfr_info[0]))


/** Set vbus_drop_check_vsafe5v_only  */
#define usbpd_cfg_port_vbus_drop_check_vsafe5v_only_set(val) \
    do { \
        gp_usbpd_cfg->port_cfg.vbus_drop_check_vsafe5v_only = val; \
    } while(0)

 /** Get vbus_drop_check_vsafe5v_only  */
#define usbpd_cfg_port_vbus_drop_check_vsafe5v_only_get() \
        (gp_usbpd_cfg->port_cfg.vbus_drop_check_vsafe5v_only)




/** \}*/




#endif /* #ifndef __USBPD_CONFIG_H_ */

