rf_a60111a_reg.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:10k
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * rf_a60111a_reg.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * A60111a register read/write source
- *
- * Author:
- * -------
- * Andy Ueng (mtk00490)
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * $Revision$
- * $Modtime$
- * $Log$
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #include <IniFiles.hpp>
- #pragma hdrstop
- #ifndef _RF_A60111A_REG_H_
- #include "rf_a60111a_reg.h"
- #endif
- #ifndef _MAN_ACTIVE_H_
- #include "man_active.h"
- #endif
- #ifndef _MAN_FDM_H_
- #include "man_fdm.h"
- #endif
- #define ADDR_A60111A_CW11 0x0B
- #define ADDR_A60111A_CW26 0x1A
- //===========================================================================
- static CRFA60111AREG* rf_a60111a_reg_ptr;
- static bool g_bIsRunning;
- //------------------------------------------------------------------------------
- static void CNF_ReadFromNVRAM(void)
- {
- rf_a60111a_reg_ptr->CNF_ReadFromNVRAM();
- }
- //------------------------------------------------------------------------------
- static void CNF_WriteToNVRAM(void)
- {
- rf_a60111a_reg_ptr->CNF_WriteToNVRAM();
- }
- //===========================================================================
- CRFA60111AREG::CRFA60111AREG(void)
- {
- g_bIsRunning = false;
- ConfirmCallback = NULL;
- m_iBufSize = 0;
- m_cBuf = NULL;
- }
- //---------------------------------------------------------------------------
- CRFA60111AREG::~CRFA60111AREG()
- {
- g_bIsRunning = false;
- ConfirmCallback = NULL;
- if (m_cBuf)
- {
- delete [] m_cBuf;
- m_cBuf = NULL;
- }
- }
- //---------------------------------------------------------------------------
- void CRFA60111AREG::Confirm(E_METAAPP_RESULT_T confirm_state)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- g_bIsRunning = false;
- if (NULL == ConfirmCallback)
- {
- return;
- }
- m_eConfirmState = confirm_state;
- ActiveMan->SetActiveFunction(ConfirmCallback);
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFA60111AREG::Enter_Factory_Cal(void)
- {
- unsigned int ui_bsi_data;
- META_RESULT MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_A60111A_CW11, &ui_bsi_data);
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- ui_bsi_data &= 0xFFFFFFFE;
- ui_bsi_data |= (ADDR_A60111A_CW11 << 20);
- MetaResult = META_Rf_SetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ui_bsi_data);
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- return true;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- bool CRFA60111AREG::Read_CW26(void)
- {
- unsigned int ui_bsi_data;
- META_RESULT MetaResult = META_Rf_GetRFImmediateBSI_r(m_META_HANDLE_Obj.Get_MainHandle(), 500, ADDR_A60111A_CW26, &ui_bsi_data);
- if (MetaResult != META_SUCCESS)
- {
- return false;
- }
- m_ucRefTemp = (unsigned char) ui_bsi_data & 0x0000001F;
- return true;
- }
- //===========================================================================
- void CRFA60111AREG::REQ_Read_From_NVRAM_Start(void)
- {
- rf_a60111a_reg_ptr = this;
- g_bIsRunning = true;
- m_bDownloadTrigger = false;
- REQ_Read_From_NVRAM();
- }
- //--------------------------------------------------------------------------
- void CRFA60111AREG::REQ_Read_From_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- if (NULL == m_cBuf)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RFSPECIALCOEF_LID", &m_iBufSize );
- if (MetaResult!=META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_cBuf = new char[m_iBufSize];
- }
- NVRAMMan->ConfirmCallback = ::CNF_ReadFromNVRAM;
- NVRAMMan->REQ_ReadNVRAM_Start("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1,
- m_iBufSize,
- m_cBuf
- );
- }
- //-------------------------------------
- void CRFA60111AREG::CNF_ReadFromNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- switch (state)
- {
- case METAAPP_SUCCESS:
- {
- if (m_bDownloadTrigger)
- {
- REQ_Write_To_NVRAM();
- }
- else
- {
- META_RESULT MetaResult = META_NVRAM_GetRecFieldValue("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- "RFSpecialCoef.tx.a60111atx.ref_temp",
- m_cBuf,
- m_iBufSize,
- &m_ucRefTemp,
- sizeof(m_ucRefTemp));
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- Confirm(METAAPP_SUCCESS);
- }
- }
- break;
- default:
- {
- Confirm(state);
- }
- break;
- }
- }
- //===========================================================================
- void CRFA60111AREG::REQ_Write_To_NVRAM_Start(void)
- {
- rf_a60111a_reg_ptr = this;
- g_bIsRunning = true;
- m_bDownloadTrigger = true;
- REQ_Read_From_NVRAM();
- }
- //---------------------------------------------------------------------------
- void CRFA60111AREG::REQ_Write_To_NVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- META_RESULT MetaResult;
- if (m_cBuf == NULL)
- {
- META_RESULT MetaResult = META_NVRAM_GetRecLen("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- &m_iBufSize);
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- m_cBuf = new char[m_iBufSize];
- }
- MetaResult = META_NVRAM_SetRecFieldValue("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- "RFSpecialCoef.tx.a60111atx.ref_temp",
- m_cBuf,
- m_iBufSize,
- &m_ucRefTemp,
- sizeof(m_ucRefTemp));
- if (MetaResult != META_SUCCESS)
- {
- Confirm(METAAPP_FAIL);
- return;
- }
- NVRAMMan->ConfirmCallback = ::CNF_WriteToNVRAM;
- NVRAMMan->REQ_WriteNVRAM_Start("NVRAM_EF_L1_RFSPECIALCOEF_LID",
- 1, // only 1 record
- m_iBufSize,
- m_cBuf
- );
- }
- //-------------------------------------
- void CRFA60111AREG::CNF_WriteToNVRAM(void)
- {
- if (!g_bIsRunning)
- {
- return;
- }
- E_METAAPP_RESULT_T state = NVRAMMan->Get_ConfirmState();
- Confirm(state);
- }
- //===========================================================================
- ///////////////////////////// Export information /////////////////////////
- //===========================================================================
- E_METAAPP_RESULT_T CRFA60111AREG::Get_ConfirmState(void)
- {
- return m_eConfirmState;
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- unsigned char CRFA60111AREG::Get_RefTemp(void)
- {
- return m_ucRefTemp;
- }
- //---------------------------------------------------------------------------
- void CRFA60111AREG::Set_RefTemp(unsigned char ref_temp)
- {
- m_ucRefTemp = ref_temp;
- }