/*
 * @file hv_pm51_app_Sys.h
 * @brief Header file of system module.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-03-01
 */

#ifndef __HV_PM51_APP_SYS_H__
#define __HV_PM51_APP_SYS_H__

#include "hv_pm51_Base.h"
#include "hv_pm51_Setting.h"

#define MIPS_BOOT_TIMEOUT         6000    /* 6s for Chip */
#define STANDBY_TIMEOUT           60000   /* 60s for standby timeout check. */
#define MIPS_BOOT_RETRY_COUNTS    2

/**
 * @brief System initialization.
 * @return None.
 */
void Hv_PM51_Sys_Init(void);

/**
 * @brief System Delay(ms) Function.
 * @param[in] ms: The required delay time (in milliseconds).
 * @return None.
 */
void Hv_PM51_Sys_DelayMs(USHORT16 ms);

/**
 * @brief Set Key working state.
 * @param[in] bState: Key working state(HV_TRUE or HV_FALSE).
 * @return None.
 */
void Hv_PM51_Sys_SetKeyState(BOOL bState);

/**
 * @brief Get Key working state.
 * @param[in] None.
 * @return HV_TRUE: Key worked, HV_FALSE: Key not worked.
 */
BOOL Hv_PM51_Sys_GetKeyState(void);

/**
 * @brief Set MIPS boot state.
 * @param[in] bState: MIPS boot state(HV_TRUE or HV_FALSE).
 * @return None.
 */
void Hv_PM51_Sys_SetMipsBootState(BOOL bState);

/**
 * @brief Get MIPS boot state.
 * @return HV_TRUE: MIPS boot successfully, HV_FALSE: MIPS boot failed
 */
BOOL Hv_PM51_Sys_GetMipsBootState(void);

/**
 * @brief Set Mips boot timer start state.
 * @param[in] bState: Mips boot timer start state(HV_TRUE or HV_FALSE).
 * @return None.
 */
void Hv_PM51_Sys_SetMipsBootTimerState(BOOL bState);

/**
 * @brief Set factory mode timer start state.
 * @param[in] bState: Factory mode timer start state(HV_TRUE or HV_FALSE).
 * @return None.
 */
void Hv_PM51_Sys_SetFactoryModeTimerState(BOOL bState);
/**
 * @brief Set standby 2 dc mode timer start state.
 * @param[in] bState: standby 2 d mode timer start state(HV_TRUE or HV_FALSE).
 * @return None.
 */
void Hv_PM51_Sys_SetStandby2DCTimerState(BOOL bState);
/**
 * @brief Reset MIPS boot retry conters to default.
 * @return None.
 */
void Hv_PM51_Sys_ResetMipsBootRetry(void);

/**
 * @brief Handle interrupt flags in the main loop.
 * @return None.
 */
void Hv_PM51_Sys_IntHandler(void);

/**
 * @brief Update HDMI edid data.
 * @param[in] ucIndex: EDID index.
 * @param[in] usLength: The length of EDID data.
 * @param[in] pucEdidData: point to EDID data array.
 * @return None.
 */
void Hv_PM51_Sys_UpdateHdmiEdidData(UCHAR8 ucIndex, USHORT16 usLength, const UCHAR8 *pucEdidData);
    
#endif
