
#ifndef _HV_DRV_TYPECPORTABLE_H
#define _HV_DRV_TYPECPORTABLE_H

#define TYPEC_VBUS_THR_VAL_0V           (0)
#define TYPEC_VBUS_THR_VAL_5V           (5000)
#define TYPEC_VBUS_THR_VAL_9V           (9000)
#define TYPEC_VBUS_THR_VAL_12V          (12000)
#define TYPEC_VBUS_THR_VAL_15V          (15000)
#define TYPEC_VBUS_THR_VAL_20V          (20000)
#define TYPEC_VBUS_THR_VAL_UNDEF        (0xFFFE)
#define TYPEC_VBUS_THR_VAL_INIT         (0xFFFF)

#include "hv_drv_TypecCircuit.h"
typedef struct _TypecPlatformCB {
    void (*DetachHandler)(UCHAR8 ucTypecPortNum);
    void (*AttachHandler)(UCHAR8 ucTypecPortNum);
    void (*PdDoneHandler)(UCHAR8 ucTypecPortNum);
    void (*VdmDoneHandler)(UCHAR8 ucTypecPortNum);
    void (*VdmExitHandler)(UCHAR8 ucTypecPortNum);
    void (*VdmFailedHandler)(UCHAR8 ucTypecPortNum);
    void (*VdmConfigHandler)(UCHAR8 ucTypecPortNum, UCHAR8 ucOrientation, UCHAR8 ucPinAssignment);
    HV_VOS_QUEUE_S* (*GetTypecQueue)(void);
    Status (*DpRxReset)(LinkPortIndex enPortIndex);
}TypecPlatformCB;

/**
 * @brief Enable or Disable interrupt of type-c.
 * @param[in] u8En  0: disable  Non 0: enable.
 * @return void
 */
void Hv_Drv_Typec_EnableDisableIntr(UCHAR8 u8En);

/**
 * @brief The implementation of the memory compare function in type-c.
 * @param[in] pc1  string 1 to be compared.
 * @param[in] pc2  string 2 to be compared.
 * @param[in] iLen  The length of the string to be compared.
 * @return 0 means equal, and non-0 means not equal
 */
INT32 Hv_Drv_Typec_MemCmp(void *pc1, void *pc2, INT32 iLen);

/**
 * @brief The implementation of the memory copy function in type-c.
 * @param[in] pDest  the pointer to block of destination memory region.
 * @param[in] pSrc  the pointer to block of source memory region.
 * @param[in] iLen  the number of bytes to be copied.
 * @return void
 */
void Hv_Drv_Typec_MemCopy(void *pDest, const void *pSrc, INT32 iLen);

/**
 * @brief The implementation of the memory copy function in type-c
          from byte pointer to word pointer.
 * @param[in] pu32Dst  the pointer to block of destination memory region.
 * @param[in] pu32Src  the pointer to block of source memory region.
 * @param[in] iLength  the number of words to be copied.
 * @return void
 */
void Hv_Drv_Typec_MemCopyWordFromByte(UINT32 * pu32Dst, const UCHAR8 *pucSrc, INT32 iLength);

/**
 * @brief The implementation of the memory copy function in type-c
          from word pointer to byte pointer.
 * @param[in] pu8Dst  the pointer to block of destination memory region.
 * @param[in] pu32Src  the pointer to block of source memory region.
 * @param[in] iLength  the number of bytes to be copied.
 * @return void
 */
void Hv_Drv_Typec_MemCopyByteFromWord(UCHAR8 * pu8Dst, const UINT32 *pu32Src, INT32 iLength);

/**
 * @brief Print char through the serial port in type-c.
 * @param[in] byData the character to print.
 * @return void
 */
void Hv_Drv_Typec_UartPrintChar(UCHAR8 byData);

/**
 * @brief Print UINT32 data through the serial port in type-c.
 * @param[in] dwWriteInt the UINT32 data to print.
 * @return void
 */
void Hv_Drv_Typec_UartPrintDec(UINT32 dwWriteInt);

/**
 * @brief Print string through the serial port in type-c.
 * @param[in] pbyMessage the string to print.
 * @return void
 */
void Hv_Drv_Typec_UartPrint(CHAR8 *pbyMessage);

/**
 * @brief The interrupt initialization of type-c.
 * @return void
 */
void Hv_Drv_Typec_IntInit(void);

/**
 * @brief The software timer initialization of type-c.
 * @return void
 */
void Hv_Drv_Typec_SwTimerInit(void);

/**
 * @brief Processing when signal loss of display port.
 * @return void
 */
void Hv_Drv_Typec_DpSignalLoss(void);

/**
 * @brief Simulate the action of type-c plugging and unplugging.
 * @return void
 */
void Hv_Drv_Typec_SimulateUnplugPlug(void);

/**
 * @brief The debug memory initialization of type-c.
 * @return void
 */
void Hv_Drv_Typec_DebugMemInit(void);

/**
 * @brief Set the task priority of type-c.
 * @param[in] u8Priority  task priority to set.
 * @return void
 */
void Hv_Drv_Typec_SetTaskPriority(UCHAR8 u8Priority);

/**
 * @brief Get the task priority of type-c.
 * @return The task priority of type-c
 */
UCHAR8 Hv_Drv_Typec_GetTaskPriority(void);

/**
 * @brief Send the event to queue of type-c.
 * @param[in] usEventId  the event id to send.
 * @param[in] usValue  the value to send.
 * @return  Status, 0:HV_SUCCESS, 1:HV_FAILURE.
 */
Status Hv_Drv_Typec_SendEventToTypecQueue(USHORT16 usEventId, USHORT16 usValue);

/**
 * @brief Send the event to queue of type-c from ISR.
 * @param[in] usEventId  the event id to send.
 * @param[in] usValue  the value to send.
 * @return Status, 0:HV_SUCCESS, 1:HV_FAILURE.
 */
Status Hv_Drv_Typec_SendEventToTypecQueueFromISR(USHORT16 usEventId, USHORT16 usValue);

/**
 * @brief Obtain the number of events in the message queue of type-c.
 * @return the number of events in the message queue of type-c
 */
ULONG32 Hv_Drv_Typec_QueueMessagesWaiting(void);

/**
 * @brief Obtain the number of events in the message queue of type-c from ISR.
 * @return the number of events in the message queue of type-c
 */
ULONG32 Hv_Drv_Typec_QueueMessagesWaitingFromISR(void);

/**
 * @brief The platform callback function initialization of type-c.
 * @param[in] pstTypecPlatformCB  the pointer to structure of platform callback function.
 * @return Status, 0:HV_SUCCESS, 1:HV_FAILURE.
 */
Status Hv_Drv_Typec_FlatformCbInit(TypecPlatformCB *pstTypecPlatformCB);

/**
 * @brief Get the pointer of platform callback structure of type-c.
 * @return the pointer of platform callback structure.
 */
TypecPlatformCB* Hv_Drv_Typec_GetFlatformCbPointer(void);

#endif
