
/**
 * @file        hv_cal_Mailbox.c
 * @brief       hv_cal_Mailbox source file.
 * @details     This file provides the following functions: \n
 * @author      HiView SoC Software Team
 * @version     1.0.0
 * @date        2022-09-06
 * @copyright   Copyright(c),2022-8, Hiview Software. All rights reserved.
 * @par         History:
 * <table>
 * <tr><th>Author                        <th>Date         <th>Change Description
 * <tr><td>HiView SoC Software Team      <td>2022-09-06   <td>create
 * </table>
*/
#include "hv_cal_Mailbox.h"
#include "hv_chip_Config.h"
#include "hv_vos_Comm.h"
#include "hv_comm_Assert.h"
#include "hv_comm_Define.h"

VOID Hv_Cal_Mailbox_RecvMsgHeader(VOID *pvMsgHeader)
{
     HV_ASSERT_VALID_PTR_VOID(pvMsgHeader);
     *(UINT32 *)pvMsgHeader = HV_R32(STANDBY_STANDBY_MCU_REG_STBY_MCU6);
}

VOID Hv_Cal_Mailbox_RecvMsgBody(VOID *pvMsgBody)
{
     HV_ASSERT_VALID_PTR_VOID(pvMsgBody);
     UINT32 *pu32Val = (UINT32 *)pvMsgBody;
     *pu32Val       = HV_R32(STANDBY_STANDBY_MCU_REG_STBY_MCU7);
     *(pu32Val + 1) = HV_R32(STANDBY_STANDBY_MCU_REG_STBY_MCU8);
     *(pu32Val + 2) = HV_R32(STANDBY_STANDBY_MCU_REG_STBY_MCU9);
}

VOID Hv_Cal_Mailbox_RecvMsgFinish(VOID)
{
    /* clear msg header reg means read finish */
     HV_W32(STANDBY_STANDBY_MCU_REG_STBY_MCU6, 0);
}

VOID Hv_Cal_Mailbox_SendMsgHeader(VOID *pvMsgHeader)
{
     HV_W32(STANDBY_STANDBY_MCU_REG_STBY_MCU10, *(UINT32 *)pvMsgHeader);
}

VOID Hv_Cal_Mailbox_SendMsgBody(VOID *pvMsgBody)
{
     UINT32 *pu32Val = (UINT32 *)pvMsgBody;
     HV_W32(STANDBY_STANDBY_MCU_REG_STBY_MCU11, *pu32Val);
     HV_W32(STANDBY_STANDBY_MCU_REG_STBY_MCU12, *(pu32Val + 1));
     HV_W32(STANDBY_STANDBY_MCU_REG_STBY_MCU13, *(pu32Val + 2));
}

VOID Hv_Cal_Mailbox_GetSendStatus(VOID *pvMsg)
{
     *(UINT32 *)pvMsg = HV_R32(STANDBY_STANDBY_MCU_REG_STBY_MCU10);
}

VOID Hv_Cal_Mailbox_EnableInterrupt(VOID)
{
     HV_W32(STANDBY_STANDBY_MCU_REG_STBY_MCU15, 1);
}

UINT32 Hv_Cal_Mailbox_GetPQToolCmdPort(VOID)
{
    return HV_R32(SW_DUMMY_PQTOOL_CMD);
}

UINT32 Hv_Cal_Mailbox_GetSwIntStatus(VOID)
{
    return HV_R32(STANDBY_STANDBY_COMM_REG_FIELD1_INTR_STS);
}

VOID Hv_Cal_Mailbox_ClearSwIntStatus(UINT32 uiSwintStatus)
{
    HV_W32(STANDBY_STANDBY_COMM_REG_FIELD1_INTR_CLR, uiSwintStatus);
}
