/**
 * \file    usbpd_defs.h
 * \brief   PD feature definitions
 *
 * \par     Copyright (c) 2018 UWE Technologies Corp., Ltd. All Rights Reserved.
 * \author  James
 * \date    2018-03-22
 * \version 
 * 
 * \history 
 *  Date        Note
 *  2018-03-22  Original Creation
 * 
 */
 
#ifndef __USBPD_DEFS_H_
#define __USBPD_DEFS_H_

#pragma pack(1)

#define CHIP_TYPE_UPD300                        (0)
#define CHIP_TYPE_UPD330F                       (1)
#define CHIP_TYPE_UPD350                        (2)

#define CHIP_TYPE_DEFINITION                    CHIP_TYPE_UPD350

#define USBPD_DEBUG_ENABLED                     (1)

/** System definitions */


/** System PD hardware and firmware version number */
#define SYS_PD_HARDWARE_VERSION                 (0)//(1)
#define SYS_PD_FIRMWARE_VERSION                 (0)//(1)
/** System SKEDB version, Currently only Version 1 is defined. */
#define SYS_PD_SKEDB_VERSION                    (1)


/** Enable or disable capture mode */
#define CAPTURE_MODE_ENABLED                    (0)


/** \name DPM power role definition for code control
 * \{ 
 */
#define DPM_POWER_ROLE_SINK_ONLY                (1)
#define DPM_POWER_ROLE_SOURCE_ONLY              (2)
#define DPM_POWER_ROLE_DRP                      (3)
#define DPM_POWER_ROLE                          DPM_POWER_ROLE_DRP
/** \}*/


/** Enable or disable power source AC input, for configuration only */
#define POWER_AC_INPUT_ENABLED                  (1)


/** Enable or disable cable plug mode */
#define CABLE_PLUG_ENABLED                      (0)


/** Enable or disable VCONN detection and VCONN sourcing */
#define VCONN_ENABLED                           (1)

/** Enable or disable vendor defined message */
#define VENDOR_DEFINE_ENABLED                   (1)
/** Enable or disable vendor defined modal operation */
#define VENDOR_DEFINE_MODE_ENABLED              (1)
/** Enable or disable vendor defined message misc handling */
#define VENDOR_DEFINE_MISC_ENABLED              (0)
/** Enable or disable vendor defined message ack delay */
#define VENDOR_DEFINE_ACK_DELAY_ENABLED         (1)
/** Vendor defined message ack delay time */
#define VENDOR_DEFINE_ACK_DELAY_TIME            (5200)



/** PE BIST receiver mode enabled */
#define PE_BIST_CARRIER_MODE2_ENABLED       (1)


#if FPGA_MODE

/** SRC: vRd/vRa/vOpen parameter default USB */
#define VRA_MIN_DEF_USB                     (0x0)
#define VRA_MAX_DEF_USB                     (0x7A)
#define VRD_MIN_SRC_DEF_USB                 (0xCC)
#define VRD_MAX_SRC_DEF_USB                 (0x4CC)
#define VOPEN_DEF_USB                       (0x547)

/** SRC: vRd/vRa/vOpen parameter 5V\1.5A */
#define VRA_MIN_5V_1P5A                     (0x0)
#define VRA_MAX_5V_1P5A                     (0x11E)
#define VRD_MIN_SRC_5V_1P5A                 (0x170)
#define VRD_MAX_SRC_5V_1P5A                 (0x4CC)
#define VOPEN_5V_1P5A                       (0x547)

/** SRC: vRd/vRa/vOpen parameter 5V\3.0A */
#define VRA_MIN_5V_3A                       (0x0)
#define VRA_MAX_5V_3A                       (0x266)
#define VRD_MIN_SRC_5V_3A                   (0x2B8)
#define VRD_MAX_SRC_5V_3A                   (0x7D7)
#define VOPEN_5V_3A                         (0x8CC)

/** SNK: vRd parameter 5V\All */
#define VRD_MIN_SNK                         (0xCC)
#define VRD_MAX_SNK                         (0x687)
#define VRD_MIN_SNK_NO_PD                   (0xCC)
#define VRD_MAX_SNK_NO_PD                   (0x6F9)

#else

/** SRC: vRd/vRa/vOpen parameter default USB */
#define VRA_MIN_DEF_USB                     (0x0)
#define VRA_MAX_DEF_USB                     (0xBA)
#define VRD_MIN_SRC_DEF_USB                 (0x136)
#define VRD_MAX_SRC_DEF_USB                 (0x745)
#define VOPEN_DEF_USB                       (0x800)

/** SRC: vRd/vRa/vOpen parameter 5V\1.5A */
#define VRA_MIN_5V_1P5A                     (0x0)
#define VRA_MAX_5V_1P5A                     (0x1B2)
#define VRD_MIN_SRC_5V_1P5A                 (0x22E)
#define VRD_MAX_SRC_5V_1P5A                 (0x745)
#define VOPEN_5V_1P5A                       (0x800)

/** SRC: vRd/vRa/vOpen parameter 5V\3.0A */
#define VRA_MIN_5V_3A                       (0x0)
#define VRA_MAX_5V_3A                       (0x3A2)
#define VRD_MIN_SRC_5V_3A                   (0x41F)
#if 0  /* modified by James Gan - 2019-05-23 */
#define VRD_MAX_SRC_5V_3A                   (0xBE0)
#define VOPEN_5V_3A                         (0xD55)
#else
/* vRd Source Max: 2.1V */
#define VRD_MAX_SRC_5V_3A                   (0xA2E)
/* vRd Source Max: 2.2V */
//#define VOPEN_5V_3A_2P2V                    (0xAAA)
#define VOPEN_5V_3A                         (0xAAA)
//#define VOPEN_5V_3A                         (0xB58)
#endif /* #if 0 */

/** SNK: vRd parameter 5V\All */
#define VRD_MIN_SNK                         (0x136)
#define VRD_MAX_SNK                         (0x9E4)
#define VRD_MIN_SNK_NO_PD                   (0x136)
#define VRD_MAX_SNK_NO_PD                   (0xA91)

#endif


/** Power role swap request automatically enabled */
#define PR_SWP_REQUEST_AUTO_ENABLED         (1)


/** Enable or disable system over current protection */
#define SYS_POWER_SRC_OCP_ENABLED           (1)


/** Enable or disable CC read adc with mask */
#define SYS_CC_READ_ADC_WITH_MASK           (0)


/** Enable or disable CC DRP toggle randomly */
#define SYS_CC_DRP_TOGGLE_RANDOMLY          (1)


/** Enable or disable capture mode configure CC selection automatically */
#define CAPTURE_MODE_CC_CONFIGURABLE        (1)


/** Enable or disable PD 3.0 extended message */
#define SYS_PD_3_0_EXTENDED_MSG_ENABLED         (1)
#define SYS_PD_3_0_COUNTRY_INFO_ENABLED         (0)
#define SYS_PD_3_0_MANUFACTURER_INFO_ENABLED    (1)
#define SYS_PD_3_0_FIRMWARE_UPGRADE_ENABLED     (0)
#define SYS_PD_3_0_SECURITY_ENABLED             (0)

#define SYS_PD_3_0_FIRMWARE_VERSION             (1)
#define SYS_PD_3_0_HARDWARE_VERSION             (1)


#pragma pack()

#endif /* #ifndef __USBPD_DEFS_H_ */

