/**
 * @file  hv_drv_TypecTimeoutDefs.h
 * @brief   Timer Configuration file 
 *          This header file contains the definitions of the timers used by Type C,
 *          Policy Engine, Protocol Layer, DPM and Power Management Control.
 * @details This file provides the following functions: \n
 *          (1) \n
 *          (2) \n
 *          (3) \n
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-08-25
 * @copyright Copyright(c),2022-8, Hiview Software. All rights reserved.
 * @par History:
 * <table>
 * <tr><th>Author                         <th>Date         <th>Change Description
 * <tr><td>Hiview SoC Software Team       <td>2022-08-25   <td>init
 * </table>
*/


#ifndef _HV_DRV_TYPECTIMEOUTDEFS_H_    /* Guard against multiple inclusion */
#define _HV_DRV_TYPECTIMEOUTDEFS_H_

// *****************************************************************************
// *****************************************************************************
// Section: Constants
// *****************************************************************************
// *****************************************************************************

// *****************************************************************************
// Section: Type C Timeout configuration
// *****************************************************************************

/*  TYPEC_TCCDEBOUNCE_TIMEOUT_MS defines the tCCDebounce timeout specified in the USB 
    Type C Specification. Default value of TYPEC_TCCDEBOUNCE_TIMEOUT_MS is set as 
    150 milliseconds. */
#define TYPEC_TCCDEBOUNCE_TIMEOUT_MS            MILLISECONDS_TO_TICKS(150)

/*  TYPEC_TPDEBOUNCE_TIMEOUT_MS defines the tPDDebounce timeout specified in the 
    USB Type C Specification. Default value of this macro is set as 10 milliseconds.*/
#define TYPEC_TPDEBOUNCE_TIMEOUT_MS             MILLISECONDS_TO_TICKS(10)

/*  TYPEC_ERRORRECOVERY_TIMEOUT_MS defines the tErrorRecovery timeout specified in the 
    USB Type C Specification.  Default value of TYPEC_ERRORRECOVERY_TIMEOUT_MS is set as 
    500 milliseconds.*/
#define TYPEC_ERRORRECOVERY_TIMEOUT_MS          MILLISECONDS_TO_TICKS(500)

/*  TYPEC_VCONNDISCHARGE_TIMEOUT_MS defines the tVCONNDischarge timeout specified in the 
    USB Type C Specification. Default value of TYPEC_VCONNDISCHARGE_TIMEOUT_MS is set 
    as 35 milliseconds. */ 
#define TYPEC_VCONNDISCHARGE_TIMEOUT_MS         MILLISECONDS_TO_TICKS(35)

/*  TYPEC_VBUS_ON_TIMER_MS defines the tVBUSON specified in the USB-TypeC Specification. 
    Default value of TYPEC_VBUS_ON_TIMER_MS is set as 275 milliseconds.*/
#define TYPEC_VBUS_ON_TIMER_MS                  MILLISECONDS_TO_TICKS(275)

/*  TYPEC_VBUS_OFF_TIMER_MS defines the tVBUSOFF specified in the USB-TypeC Specification. 
    Default value of TYPEC_VBUS_OFF_TIMER_MS is set as 650 milliseconds.*/
#define TYPEC_VBUS_OFF_TIMER_MS                 MILLISECONDS_TO_TICKS(650)

/*  TYPEC_VCONNON_TIMEOUT_MS defines the tVCONNON specified in the USB-Type C Specification. 
    Default value of TYPEC_VCONNON_TIMEOUT_MS is set as 10 milliseconds.*/
#define TYPEC_VCONNON_TIMEOUT_MS                MILLISECONDS_TO_TICKS(10)

/*  TYPEC_VCONNOFF_TIMEOUT_MS defines the tVCONNOFF specified in the USB-Type C Specification. 
    Default value of TYPEC_VCONNOFF_TIMEOUT_MS is set as 25 milliseconds.*/
#define TYPEC_VCONNOFF_TIMEOUT_MS               MILLISECONDS_TO_TICKS(25)

/*  TYPEC_AME_TIMEOUT_MS defines the tAMETimeout specified in the USB-Type C Specification. 
    Default value of TYPEC_AME_TIMEOUT_MS is set as 1000 milliseconds.*/
#define TYPEC_AME_TIMEOUT_MS                    MILLISECONDS_TO_TICKS(2000)

// *****************************************************************************
// Section: Protocol Layer Timeout configuration
// *****************************************************************************

/*  PRL_CHUNKSENDERREQUEST_TIMEOUT_MS defines the ChunkSenderRequestTimer specified in the USB-PD Specification. 
    Default value of PRL_CHUNKSENDERREQUEST_TIMEOUT_MS is set as 26 milliseconds.*/
#define PRL_CHUNKSENDERREQUEST_TIMEOUT_MS       MILLISECONDS_TO_TICKS(30)

/*  PRL_CHUNKSENDERRESPONSE_TIMEOUT_MS defines the ChunkSenderResponseTimer specified in the USB-PD Specification. 
    Default value of PRL_CHUNKSENDERRESPONSE_TIMEOUT_MS is set as 26 milliseconds.*/
#define PRL_CHUNKSENDERRESPONSE_TIMEOUT_MS      MILLISECONDS_TO_TICKS(30)

/*  PRL_SINKTX_TIMEOUT_MS defines the SinkTxTimer specified in the USB-PD Specification. 
    Default value of PRL_SINKTX_TIMEOUT_MS is set as 16 milliseconds.*/
#define PRL_SINKTX_TIMEOUT_MS                   MILLISECONDS_TO_TICKS(16)

/*  PRL_BIST_CONTMODE_TIMEOUT_MS defines the BISTContModeTimer specified in the USB-PD Specification.
    Default value of PRL_BIST_CONTMODE_TIMEOUT_MS is set as 45 milliseconds.*/
#define PRL_BIST_CONTMODE_TIMEOUT_MS            MILLISECONDS_TO_TICKS(45)                                             

// *****************************************************************************
// Section: Policy Engine Timeout configuration
// *****************************************************************************

/*  PE_SOURCECAPABILITY_TIMEOUT_MS defines the SourceCapabilityTimer specified in the 
    USB-PD Specification. Default value of PE_SOURCECAPABILITY_TIMEOUT_MS is set as 
    150 milliseconds.*/
#define PE_SOURCECAPABILITY_TIMEOUT_MS          MILLISECONDS_TO_TICKS(150)

/*  PE_SRC_READY_TIMEOUT_MS defines the tSrcReady specified in the PD 3.0 Specification. 
    Default value of PE_SRC_READY_TIMEOUT_MS is set as 285 milliseconds.*/
#define PE_SRC_READY_TIMEOUT_MS                 MILLISECONDS_TO_TICKS(285)

/*  PE_VCONNON_TIMEOUT_MS defines the tVCONNSourceOn specified in the USB PD Specification. 
    Default value of PE_VCONNON_TIMEOUT_MS is set as 50 milliseconds. */
#define PE_VCONNON_TIMEOUT_MS                   MILLISECONDS_TO_TICKS(50)

/*  PE_VCONN_TIMEOUT_MS defines the tVCONNSourceTimeout specified in the USB PD Specification. 
    Default value of PE_VCONN_TIMEOUT_MS is set as 150 milliseconds. */
#define PE_VCONN_TIMEOUT_MS                   MILLISECONDS_TO_TICKS(150)

/*  PE_VCONNON_SELF_TIMEOUT_MS defines the Self timer used to monitor VCONN ON
    and send hard reset in case of VCONN ON Failure. The value of Self timer is 
    set to a value greater than tVCONNSourceOn. Default value of PE_VCONNON_SELF_TIMEOUT_MS 
    is set as 75 milliseconds.*/
#define PE_VCONNON_SELF_TIMEOUT_MS              MILLISECONDS_TO_TICKS(75)

/*  PE_VCONNOFF_TIMEOUT_MS defines the tVCONNSourceOff specified in the USB PD Specification. 
    Default value of PE_VCONNOFF_TIMEOUT_MS is set as 25 milliseconds.*/
#define PE_VCONNOFF_TIMEOUT_MS                  MILLISECONDS_TO_TICKS(25)

/*  PE_NORESPONSE_TIMEOUT_MS defines the NoResponseTimer specified in the USB-PD Specification. 
    Default value of PE_NORESPONSE_TIMEOUT_MS is set as 5.5 seconds.*/
#define PE_NORESPONSE_TIMEOUT_MS                MILLISECONDS_TO_TICKS(5500)

/*  PE_SENDERRESPONSE_TIMEOUT_MS defines the SenderResponseTimer specified in the USB-PD Specification. 
    Default value of PE_SENDERRESPONSE_TIMEOUT_MS is set as 27 milliseconds.*/
#define PE_SENDERRESPONSE_TIMEOUT_MS            MILLISECONDS_TO_TICKS(27)

/*  PE_SOURCECAPRESPONSE_TIMEOUT_MS defines the SenderResponseTimer specified in the USB-PD Specification. 
    Default value of PE_SOURCECAPRESPONSE_TIMEOUT_MS is set as 26 milliseconds though  tCtsSnkRequest is
    defined 25.26ms for PD3.0 and 22.26ms for PD2.0.
    AND tSenderResponse min max is 24~30ms for PD2 27~33 for PD3, so here select 27ms to test*/
#define PE_SOURCECAPRESPONSE_TIMEOUT_MS            MILLISECONDS_TO_TICKS(27)

/*  PE_SINKWAITCAP_TIMEOUT_MS defines the SinkWaitCapTimer specified in the USB-PD Specification. 
    Default value of PE_SINKWAITCAP_TIMEOUT_MS is set as 465 milliseconds.*/
#define PE_SINKWAITCAP_TIMEOUT_MS               MILLISECONDS_TO_TICKS(350)

/*  PE_PSTRANSITION_TIMEOUT_MS defines the PSTransitionTimer specified in the USB-PD Specification. 
    Default value of PE_PSTRANSITION_TIMEOUT_MS is set as 500 milliseconds.*/
#define PE_PSTRANSITION_TIMEOUT_MS              MILLISECONDS_TO_TICKS(500)

/*  PE_SINKREQUEST_TIMEOUT_MS defines the SinkRequestTimer specified in the USB-PD Specification. 
    Default value of PE_SINKREQUEST_TIMEOUT_MS is set as 100 milliseconds.*/
#define PE_SINKREQUEST_TIMEOUT_MS               MILLISECONDS_TO_TICKS(100)

/*  PE_VDMRESPONSE_TIMEOUT_MS defines the VDMResponseTimer specified in the USB-PD Specification. 
    Default value of PE_VDMRESPONSE_TIMEOUT_MS is set as 28 milliseconds.*/
#define PE_VDMRESPONSE_TIMEOUT_MS               MILLISECONDS_TO_TICKS(28)

/*  PE_PSHARDRESET_TIMEOUT_MS defines the PSHardResetTimer specified in the USB-PD Specification. 
    Default value of PE_PSHARDRESET_TIMEOUT_MS is set as 28 milliseconds.*/
#define PE_PSHARDRESET_TIMEOUT_MS               MILLISECONDS_TO_TICKS(28)

/*  PE_SRCRECOVER_TIMEOUT_MS defines the tSrcRecover specified in the USB-PD Specification. 
    Default value of PE_SRCRECOVER_TIMEOUT_MS is set as 800 milliseconds.*/
#define PE_SRCRECOVER_TIMEOUT_MS                MILLISECONDS_TO_TICKS(800)

/*  PE_SRCTRANSISTION_TIMEOUT_MS defines the tSrcTransistionTimer specified in the 
    USB-PD Specification. By default, it is set to 28 milliseconds.*/
#define PE_SRCTRANSISTION_TIMEOUT_MS            MILLISECONDS_TO_TICKS(28)

/* PE_AVS_SRCTRANSLARGE_TIMEOUT_MS defines the tAvsSrcTransLarge specified 
   in the USB PD Specification. Default value of PE_AVS_SRCTRANSLARGE_TIMEOUT_MS
   is set as 600 milliseconds. */
   #define PE_AVS_SRCTRANSLARGE_TIMEOUT_MS         MILLISECONDS_TO_TICKS(600)

/* PE_AVS_SRCTRANSSMALL_TIMEOUT_MS defines the tAvsSrcTransSmall specified 
   in the USB PD Specification. Default value of PE_AVS_SRCTRANSSMALL_TIMEOUT_MS
   is set as 40 milliseconds. */
   #define PE_AVS_SRCTRANSSMALL_TIMEOUT_MS         MILLISECONDS_TO_TICKS(40)

/* PE_PPS_SRCTRANSLARGE_TIMEOUT_MS defines the tPpsSrcTransLarge specified 
   in the USB PD Specification. Default value of PE_PPS_SRCTRANSLARGE_TIMEOUT_MS
   is set as 250 milliseconds. */
#define PE_PPS_SRCTRANSLARGE_TIMEOUT_MS         MILLISECONDS_TO_TICKS(250)

/* PE_PPS_SRCTRANSSMALL_TIMEOUT_MS defines the tPpsSrcTransLarge specified 
   in the USB PD Specification. Default value of PE_PPS_SRCTRANSSMALL_TIMEOUT_MS
   is set as 15 milliseconds. */
#define PE_PPS_SRCTRANSSMALL_TIMEOUT_MS         MILLISECONDS_TO_TICKS(15)

/* PE_SOURCE_PPS_COMM_TIMEOUT_MS defines the SourcePPSCommTimer specified 
   in the USB PD Specification. Default value of PE_SOURCE_PPS_COMM_TIMEOUT_MS
   is set as 13 seconds. */
#define PE_SOURCE_PPS_COMM_TIMEOUT_MS           MILLISECONDS_TO_TICKS(13000)

/* PE_SOURCE_AVS_COMM_TIMEOUT_MS defines the SourceEPRKeepAlive Timer specified 
   in the USB PD Specification. Default value of PE_SOURCE_AVS_COMM_TIMEOUT_MS
   is set as 875 milliseconds. */
   #define PE_SOURCE_AVS_COMM_TIMEOUT_MS           MILLISECONDS_TO_TICKS(875)

/* PE_VCONN_SWAP_WAIT_TIMEOUT_MS defines the tVCONNSwapWait specified in the 
   PD Specification. Default value of PE_VCONN_SWAP_WAIT_TIMEOUT_MS is 
   set as 100 milliseconds. */
#define PE_VCONN_SWAP_WAIT_TIMEOUT_MS           MILLISECONDS_TO_TICKS(100)

/* PE_PR_SWAP_WAIT_TIMEOUT_MS defines the tPRSwapWait specified in the 
   PD Specification. Default value of PE_PR_SWAP_WAIT_TIMEOUT_MS is 
   set as 100 milliseconds. */
#define PE_PR_SWAP_WAIT_TIMEOUT_MS              MILLISECONDS_TO_TICKS(100)

/* PE_DR_SWAP_WAIT_TIMEOUT_MS defines the tDRSwapWait specified in the 
   PD Specification. Default value of this macro is set to 100ms */
#define PE_DR_SWAP_WAIT_TIMEOUT_MS              MILLISECONDS_TO_TICKS(100)

/* PE_PS_SOURCE_ON_TIMEOUT_MS defines the tPSSourceOn specified in the 
   PD Specification. Default value of PE_PS_SOURCE_ON_TIMEOUT_MS is 
   set as 420 milliseconds. */
#define PE_PS_SOURCE_ON_TIMEOUT_MS              MILLISECONDS_TO_TICKS(390)

/* PE_PS_SOURCE_OFF_TIMEOUT_MS defines the tPSSourceOff specified in the 
   USB PD Specification. Default value of PE_PS_SOURCE_OFF_TIMEOUT_MS is 
   set as 800 milliseconds. */
#define PE_PS_SOURCE_OFF_TIMEOUT_MS             MILLISECONDS_TO_TICKS(800)

/* PE_SWAP_SOURCE_START_TIMEOUT_MS defines the tSwapSourceStart specified in the 
   USB PD Specification. Default value of PE_SWAP_SOURCE_START_TIMEOUT_MS is 
   set as 20 milliseconds. */
#define PE_SWAP_SOURCE_START_TIMEOUT_MS         MILLISECONDS_TO_TICKS(20)

/* PE_SWAP_SINK_READY_TIMEOUT_MS defines the tSwapSinkReady specified in the 
   USB PD Specification. Default value of PE_SWAP_SINK_READY_TIMEOUT_MS is 
   set as 12 milliseconds. */
#define PE_SWAP_SINK_READY_TIMEOUT_MS           MILLISECONDS_TO_TICKS(12)

/* PE_VDM_BUSY_TIMEOUT_MS defines the tVDMBusy specified in the 
   USB PD Specification. Default value of PE_VDM_BUSY_TIMEOUT_MS is 
   set as 50 milliseconds. */
#define PE_VDM_BUSY_TIMEOUT_MS                  MILLISECONDS_TO_TICKS(50)

/* PE_FRS_DETACH_WAIT_TIMEOUT_MS defines the amount of time Policy Engine 
   shall wait before invoking TypeC Error Recovery on failure to receive Good_CRC   
   for the FR_SWAP message sent. This timeout is implemented out of Type C and
   PD Specification to wait for a TypeC Detach event. */
#define PE_FRS_DETACH_WAIT_TIMEOUT_MS           MILLISECONDS_TO_TICKS(5)

/* PE_DISCOVER_IDENTITY_TIMEOUT_MS defines the tDiscoverIdentity specified in the 
   USB PD Specification. Default value of PE_DISCOVER_IDENTITY_TIMEOUT_MS is 
   set as 40 milliseconds. */
#define PE_DISCOVER_IDENTITY_TIMEOUT_MS         MILLISECONDS_TO_TICKS(40)

// *****************************************************************************
// Section: DPM Timeout configuration
// *****************************************************************************
/*Status Fault Persistence Timer - the port shall start a status fault persistence
  timer on the occurrence of the one of the Fault status types. If the status
  is not sent to the partner within the time defined in the 
  DPM_STATUS_FAULT_PERSIST_TIMEOUT_MS, the status shall be cleared.*/
#define DPM_STATUS_FAULT_PERSIST_TIMEOUT_MS    MILLISECONDS_TO_TICKS(19000)

// *****************************************************************************
// Section: UPD Idle Timeout configuration
// *****************************************************************************
 /* UPD_IDLE_TIMEOUT_MS is the idle time after which UPD350 is configured by the power 
    management control layer to enter low power mode if there is no activity or 
    interrupt in UPD350. */
#define UPD_IDLE_TIMEOUT_MS                     MILLISECONDS_TO_TICKS(15000)

/* TYPEC_ADC_DISABLE_TIMEOUT_MS defines time during this time CC adc interrupt is disabled. */
#define TYPEC_ADC_DISABLE_TIMEOUT_MS            MILLISECONDS_TO_TICKS(100)

/* PE_SRCTRANS_PSRDY_TIMEOUT_MS defines time ps_rdy sent after power supply stable. */
#define PE_SRCTRANS_PSRDY_TIMEOUT_MS            MILLISECONDS_TO_TICKS(20)


#define PE_SEND_HPD_ACTION_TIMEOUT_MS            MILLISECONDS_TO_TICKS(500)

/* PE_SOURCE_RDY_ALTMODE_TIMEOUT_MS defines time source rdy and todo dr_swap init. */
#define PE_SOURCE_RDY_ALTMODE_TIMEOUT_MS            MILLISECONDS_TO_TICKS(500)

#define TYPEC_VBUS_CHECK_TIMEOUT_MS             MILLISECONDS_TO_TICKS(20)
#endif /* _TIMER_DEFS_H */

#define TYPEC_CC_DEBOUNCE_TIME_MS               MILLISECONDS_TO_TICKS(20)

#define PE_WAIT_SOURCE_CAPS_TIMEOUT_MS          MILLISECONDS_TO_TICKS(500)

/* PD3.2 Spec tEPRSourceCableDiscovery max is 2s, if the EPR source is not the VCONN source, this time must
   include VCONN SWAP time */
#define PE_EPR_SOURCE_CABLE_DISCOVERY_TIMEOUT_MS    MILLISECONDS_TO_TICKS(1000)

/* EPR tEnterEPR time max 550ms min 450 default 500ms */
#define PE_EPR_ENTEREPR_TIMEOUT_MS                  MILLISECONDS_TO_TICKS(500)

/* EPR tFirstSourceCap time max 250ms */
#define PE_EPR_FIRST_SOURCE_CAP_TIMEOUT_MS                  MILLISECONDS_TO_TICKS(250)

/* *****************************************************************************
 End of File
 */
