/**
 * @file hv_comm_Utilities.h
 * @brief Header file of Utilities module.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 *
 * @endverbatim
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-08-22
 */

#ifndef __SDK_COMMON_UTIL_UTILITIES_INC_HSUTILITIES_H__
#define __SDK_COMMON_UTIL_UTILITIES_INC_HSUTILITIES_H__


#include "hv_comm_DataType.h"
#include "hv_vos_Conn.h"
#include "hv_comm_Define.h"

        
typedef struct SettingData_Tag
{
   UINT32 uiAddr;                                ///< register address want to read or write
   UCHAR8  ubStartBit;                            ///< register start bit
   UCHAR8  ubEndBit;                                ///< register end bit
   UCHAR8  ubResv1;                              ///< reserve byte 1
   UCHAR8  ubResv2;                              ///< reserve byte 2
   UINT32 uiVal;                                ///< register write value
 }SettingData, *PSettingData;

typedef struct _HDBF_TAG
{
    CHAR8	HDB_Magic[4];
    CHAR8	HDB_ChipName[8];
    CHAR8	HDB_ModuleName[16];
    UINT32	HDB_RegCount;
    UCHAR8	HDB_Expand;
    UCHAR8	HDB_DefIndx;
    USHORT16	HDB_AttrItem;
    USHORT16	HDB_AttrVer;
    UCHAR8	HDB_Resv[26];
}HDBF_Header, *PHDBF_Header;


// INT32 Hv_Common_Log2 (UINT32 uiParam);

BOOL HDB_Init(UINT32 *uiDBAddr, UINT32 arrIdx);

UINT32 Hv_Common_GetEven(UINT32 uiParam);
VOID Hv_Common_BinConfigInit(const UINT32 *uiConfigAddr, UINT32 uiLen);

/**
 * @brief Read bytes reg.
 * @param[in] uiRegAdrr Reg addr to read.
 * @param[out] pucData the data write to reg.
 * @param[in] uwLen the length of write data.
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
VOID Hv_Common_WriteRegBytes(const UCHAR8 *pucData, UINT32 uiRegAdrr,  UINT32 uiLen);

/**
 * @brief Read bytes reg.
 * @param[in] uwRegAdrr Reg addr to read.
 * @param[out] pucData the data read from reg.
 * @param[in] uwLen the length of read data.
 * @return Status, 0-HV_SUCCESS, 1-HV_FAILURE.
 */
Status Hv_Common_ReadRegBytes(UCHAR8 *pucData, UINT32 uiRegAdrr, UINT32 uiLen);

/**
 * @brief Compute the sqrt of the float value.
 * @param[in] Value need to be caculate.
 * @return Float value of the sqrt result.
 */
FLOAT32 Hv_Common_Sqrt(FLOAT32 fValue);

#endif
