/**
 * @file hv_mw_TypecTask.h
 * @brief Header file of TYPEC task module.
 * 
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use Hv_Mw_TypecTaskHandle(...) s a task function handle. 
 * 
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-08-10
 */
#ifndef __SDK_MIDDLEWARE_RUNTIME_TYPECTASK_INC_TYPECTASK_H__
#define __SDK_MIDDLEWARE_RUNTIME_TYPECTASK_INC_TYPECTASK_H__

#include "hv_comm_DataType.h"
#include "hv_comm_Event.h"

typedef enum  _TypecState
{
    TYPEC_STATE_IDLE,
    TYPEC_STATE_RUNNING,
    TYPEC_STATE_INVAILD = 0xFFFF,
}TypecState;

typedef struct _TypecStateMachine
{
    USHORT16        usAcceptStates;
    TypecEventId    enEventId;
    Status          (*pfActionHandle)(TypecEvent *pstEvent);
    TypecState      enNextState;
} __attribute__((aligned(4)))TypecStateMachine;

/**
 * @brief Simulate Typec unplug and plug.
 * @return VOID
 */
VOID Hv_Mw_Typec_SimulateUnplugPlug(VOID);

/**
 * @brief Set DP Hot plug.
 * @param[in] ucTypecPortNum  Typec port numbuer.
 * @param[in] bHpdEn  Set DP HPD high(true) or low(false). 
 * @return VOID
 */
VOID Hv_Mw_Typec_AMESetDpHpd(UCHAR8 ucTypecPortNum, BOOL bHpdEn);

/**
 * @brief Set DP IRQ Hot plug.
 * @param[in] ucTypecPortNum  Typec port numbuer.
 * @return VOID
 */
VOID Hv_Mw_Typec_AMESetDpIrqHpd(UCHAR8 ucTypecPortNum);

/**
 * @brief Get status that if in DP ALT Mode.
 * @param[in] ucTypecPortNum  Typec port numbuer.
 * @return HV_TRUE: entered DP ALT Mode HV_FALSE: exited DP ALT Mode
 */
BOOL Hv_Mw_Typec_AMEGetStatus(UCHAR8 ucTypecPortNum);

/**
 * @brief Typec task init.
 * @return VOID
 */
VOID Hv_Mw_Typec_TaskStartInit(VOID);

/**
 * @brief Typec task function handle.
 * @param[in] arg  not used!.
 * @return VOID
 */
VOID Hv_Mw_TypecTaskHandle(  VOID *arg  );

/**
 * @brief Typec will do something when DP signal loss.
 * @return VOID
 */
VOID Hv_Mw_Typec_DpSignalLoss(VOID);

/**
 * @brief Get Typec source capabilities.
 * @param[in] ucTypecPortNum  Typec port numbuer.
 * @param[out] pucSrcPDOCnt  return pointer that points to the counts of src PDOs.
 * @param[out] puiDataObj  return pointer that points to data object of src PDOs.
 * @return VOID
 */
VOID Hv_Mw_Typec_GetSourceCapabilities(UCHAR8 ucTypecPortNum, UCHAR8 *pucSrcPDOCnt, UINT32 *puiDataObj);

#if (HV_PROJECT_CONFIG_SMART_POWER == HV_CONFIG_ON)
VOID Hv_Mw_Typec_UpdateHighPower(UCHAR8 u8HighPower);
#endif
#endif
