/**
 * @file hv_chip_config.h
 * @brief include debug interface, define irq,memory,clk
 * @details anyware
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-09-05
 * @copyright Copyright(c),2022-9, Hiview Software. All rights reserved.
*/
#ifndef _HV_CHIP_CONFIG_H
#define _HV_CHIP_CONFIG_H



#include "regs/HV_REGS_HT7315.h"
#include "hv_chip_Clk.h"
#include "hv_chip_Irq.h"
#include "hv_chip_Memory.h"
#include "hv_chip_Debug.h"


#define HV_IRQ_FUNCTION void __attribute__ ((interrupt, keep_interrupts_masked))
#define HV_WT32(addr, value) (*(volatile unsigned int*)((addr) | 0xA0000000) = (value))
#define HV_RD32(addr) (*(volatile unsigned int*)((addr) | 0xA0000000))

/**
 * @brief interface to set io group usermode.
 * @param[in] none.
 * @return none.
 */
static void Hv_Chip_SetIOUserMode(void)
{
    unsigned int uVal = HV_RD32(RX_SH08_TOP_RX_0X40);

    /* set system io group usermode */
    uVal |= 1 << 18;
    HV_WT32(RX_SH08_TOP_RX_0X40, uVal);
    /* set standy io group usermode */
    uVal = HV_RD32(STANDBY_SH08_TOP_STBY_CTRL_24);
    uVal |= 1 << 18;
    HV_WT32(STANDBY_SH08_TOP_STBY_CTRL_24, uVal);
}


#ifdef HV_CONFIG_ENABLE_PRINT
#include "hv_chip_DebugUart.h"
#else
/* 关掉打印编译使用 */
#define Hv_Chip_DebugUartInit(baudrate)
#define Hv_Chip_DebugUartWrite(fd, buf, int)
#define Hv_Chip_DebugUartPuts(c)
static int Hv_Chip_DebugUartGetc(char *ch){return 0;}
#define Hv_Chip_DebugUartPutc(c)
static void Hv_Chip_SwitchQspiRsic(void){return;}
static void Hv_Chip_DebugUartConfig(void){return;}
static inline int Hv_Chip_DebugUartKbhit(){
    return 0;
}
#endif

#endif
