/**
 * \file    prl_hr_state.h
 * \brief   Protocol - USB Type-C Port Manager
 *
 * \par     Copyright (c) 2017 UWE Technologies Corp., Ltd. All Rights Reserved.
 * \author  James
 * \date    2017-02-03
 * \version 
 * 
 * \history 
 *  Date        Note
 *  2017-02-03  Original Creation
 * 
 */
 
#ifndef __PRL_HR_STATE_H_
#define __PRL_HR_STATE_H_


#include "types.h"
#include "usbpd_timer_defs.h"
#include "prl_tcpm.h"

#pragma pack(1)


/** \name Type-C Protocol Hard Reset State definitions
 * \{ 
 */
#define PRL_HR_IDLE                             0x00
#define PRL_HR_RESET_LAYER                      0x01
#define PRL_HR_REQUEST_HARD_RESET               0x02
#define PRL_HR_WAIT_FOR_PHY_HARD_RESET_COMPLETE 0x03
#define PRL_HR_PHY_HARD_RESET_REQUESTED         0x04
#define PRL_HR_INDICATE_HARD_RESET              0x05
#define PRL_HR_WAIT_FOR_PE_HARD_RESET_COMPLETE  0x06
#define PRL_HR_PE_HARD_RESET_COMPLETE           0x07
/** \}*/

#pragma pack()


/** Get current protocol hard reset state */
#define prl_hr_state_get() \
    (g_prl_state_info.hr_state)

/** Set current protocol hard reset state */
#define prl_hr_state_set(v) \
    do { \
        g_prl_state_info.hr_state = v; \
    } while(0)


/** Get exit from hard reset state */
#define prl_hr_exit_from_hard_reset_get() \
    (g_prl_state_info.hr_exit_from_hard_reset)

/** Set exit from hard reset state */
#define prl_hr_exit_from_hard_reset_set(st) \
    do { \
        g_prl_state_info.hr_exit_from_hard_reset = st; \
    } while(0)



/** Protocol soft reset get */
#define prl_reset_get() \
    (g_prl_state_info.prl_reset)

/** Protocol soft reset set */
#define prl_reset_set(flg) \
    do { \
        g_prl_state_info.prl_reset = flg; \
    } while(0)


/** Protocol local hard reset get */
#define prl_local_hw_reset_get() \
    (g_prl_state_info.local_hw_reset)

/** Protocol local hard reset set */
#define prl_local_hw_reset_set(flg) \
    do { \
        g_prl_state_info.local_hw_reset = flg; \
    } while(0)


/** Protocol hard reset request from PE get */
#define prl_hrst_req_frm_pe_get() \
    (g_prl_state_info.hrst_req_frm_pe)

/** Protocol hard reset request from PE set */
#define prl_hrst_req_frm_pe_set(flg) \
    do { \
        g_prl_state_info.hrst_req_frm_pe = flg; \
    } while(0)


/** Protocol hard reset complete from PE get */
#define prl_hrst_cmplt_frm_pe_get() \
    (g_prl_state_info.hrst_cmplt_frm_pe)

/** Protocol hard reset complete from PE set */
#define prl_hrst_cmplt_frm_pe_set(flg) \
    do { \
        g_prl_state_info.hrst_cmplt_frm_pe = flg; \
    } while(0)


/** Protocol cable reset request from PE get */
#define prl_cbl_rst_req_frm_pe_get() \
    (g_prl_state_info.cbl_rst_req_frm_pe)

/** Protocol cable reset request from PE set */
#define prl_cbl_rst_req_frm_pe_set(flg) \
    do { \
        g_prl_state_info.cbl_rst_req_frm_pe = flg; \
    } while(0)

/** Protocol cable reset complete from PE get */
#define prl_cbl_rst_cmplt_frm_pe_get() \
    (g_prl_state_info.cbl_rst_cmplt_frm_pe)

/** Protocol cable reset complete from PE set */
#define prl_cbl_rst_cmplt_frm_pe_set(flg) \
    do { \
        g_prl_state_info.cbl_rst_cmplt_frm_pe = flg; \
    } while(0)


/** Protocol pe informed cable reset get */
#define prl_pe_informed_cab_rst_get() \
    (g_prl_state_info.pe_informed_cab_rst)


/** Protocol pe informed cable reset clear */
#define prl_pe_informed_cab_rst_clear() \
    do { \
        g_prl_state_info.pe_informed_cab_rst = FALSE; \
    } while(0)


/** Protocol pe informed hard reset get */
#define prl_pe_informed_hrst_get() \
    (g_prl_state_info.pe_informed_hrst)


/** Protocol pe informed hard reset clear */
#define prl_pe_informed_hrst_clear() \
    do { \
        g_prl_state_info.pe_informed_hrst = FALSE; \
    } while(0)


/** Protocol reset complete get */
#define prl_reset_complete_get() \
    (g_prl_state_info.prl_reset_complete)


/** Protocol reset complete clear */
#define prl_reset_complete_clear() \
    do { \
        g_prl_state_info.prl_reset_complete = FALSE; \
    } while(0)


/** Protocol hard_reset_sig_frm_phy get */
#define prl_hard_reset_sig_frm_phy_get() \
    (g_prl_state_info.hard_reset_sig_frm_phy)


/** Protocol hard_reset_sig_frm_phy clear */
#define prl_hard_reset_sig_frm_phy_clear() \
    do { \
        g_prl_state_info.hard_reset_sig_frm_phy = FALSE; \
    } while(0)


/** Protocol cable_reset_sig_frm_phy get */
#define prl_cable_reset_sig_frm_phy_get() \
    (g_prl_state_info.cable_reset_sig_frm_phy)

/** Protocol cable_reset_sig_frm_phy set */
#define prl_cable_reset_sig_frm_phy_set(flg) \
    do { \
        g_prl_state_info.cable_reset_sig_frm_phy = flg; \
    } while(0)


/** Protocol cable_reset_sig_frm_phy clear */
#define prl_cable_reset_sig_frm_phy_clear() \
    do { \
        g_prl_state_info.cable_reset_sig_frm_phy = FALSE; \
    } while(0)



void prl_hr_state_init();
void prl_hr_state_machine();


#endif /* #ifndef __PRL_HR_STATE_H_ */

