T_CV.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:8k
- /*****************************************************************************
- * 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:
- * ---------
- * T_CV.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * Constant voltage (CV) calibraiton 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!!
- *============================================================================
- ****************************************************************************/
- #pragma hdrstop
- #ifndef _META_FACTORY_H_
- #include "meta_factory.h"
- #endif
- #ifndef _T_META_FACTORY_CALIBRATION_H_
- #include "T_META_factory_calibration.H"
- #endif
- #ifndef _META_UTILS_H_
- #include "meta_utils.h"
- #endif
- #ifndef _RCT_COMMON_H_
- #include "rct_common.h"
- #endif
- // misc
- #ifndef _TIME_UTILS_H_
- #include "time_utils.h"
- #endif
- #ifndef _FT_UTILS_H_
- #include "ft_utils.h"
- #endif
- // callback
- #ifndef _META_FACTORY_BB_CB_H_
- #include "meta_factory_bb_cb.h"
- #endif
- extern bool is_suspend_cal;
- //===========================================================================
- bool __fastcall T_META_factory_calibration::CVCal_cal(void)
- {
- log->Add("n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " ====================== CV calibration begin ===================== "
- );
- PostMessage(ctrl.hPostMsgDestHandle,
- WM_MF_CV_BEGIN,
- 0,
- 0
- );
-
- if (!m_dcs_ctrl.DCS_Init(m_pDcs))
- {
- CalErrorHandler(WM_MF_ADC_DCS_INIT_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Power supply initialize ");
- return false;
- }
- // set output voltage = 4.2V
- if (!m_dcs_ctrl.DCS_outputVoltCurr( m_pDcs, 4.2, i_CURRENT_LIMIT/1000.0))
- {
- CalErrorHandler(WM_MF_ADC_DCS_SET_VOLTAGE_CURRENT_FAIL );
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: power supply set vlotage = " +
- Double_To_AnsiString(i_ADC_V1/1000.0)
- );
- return false;
- }
- log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " Set power supply vlotage = " +
- Double_To_AnsiString(4.2)
- );
- CHECK_TERMINATE_BY_USER
- Sleep (50);
- // set CV calibration register
- m_cBB_CV_Obj.ConfirmCallback = ::CNF_BB;
- m_cBB_CV_Obj.REQ_Set_CV_Cal_Register_Start(m_pCal->e_bb_chip);
- RestartTimerCal(WM_MF_BB_REG_SET_FAIL);
- SUSPEND_CAL_THREAD
- E_METAAPP_RESULT_T state = m_cBB_CV_Obj.Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_BB_REG_SET_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set CV calibration register fail "
- );
- return false;
- }
- char c_pmu = m_cBB_CV_Obj.Get_PMU();
- char c_step = m_cBB_CV_Obj.Get_CvStep();
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " PMU = " + IntToStr(c_pmu) +
- ", step = " + IntToStr(c_step)
- );
- CHECK_TERMINATE_BY_USER
- // write NVRAM
- m_cBB_CV_Obj.ConfirmCallback = ::CNF_BB;
- m_cBB_CV_Obj.REQ_Write_To_NVRAM_Start();
- RestartTimerCal(WM_MF_NVRAM_CV_WRITE_FAIL);
- SUSPEND_CAL_THREAD
- state = m_cBB_CV_Obj.Get_ConfirmState();
- if (state != METAAPP_SUCCESS)
- {
- CalErrorHandler(WM_MF_NVRAM_CV_WRITE_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL : Target < set CV calibration register fail "
- );
- return false;
- }
- log->Add("n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " ====================== CV calibration end ===================== "
- );
- return true;
- }
- //---------------------------------------------------------------------------
- bool __fastcall T_META_factory_calibration::CVCal_check(void)
- {
- log->Add("n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " ====================== CV check begin ===================== "
- );
- char step = m_cBB_CV_Obj.Get_CvStep();
- if ((step > m_cMAX_CV_STEP) || (step < m_cMIN_CV_STEP))
- {
- CalErrorHandler(WM_MF_CV_CHECK_FAIL);
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Fail: CV check ." + " CV step = " + IntToStr(step) +
- ", min CV step = " + IntToStr(m_cMIN_CV_STEP) +
- ", max CV step = " + IntToStr(m_cMAX_CV_STEP)
- );
- return false;
- }
- log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " Pass: CV check ." + " CV step = " + IntToStr(step) +
- ", min CV step = " + IntToStr(m_cMIN_CV_STEP) +
- ", max CV step = " + IntToStr(m_cMAX_CV_STEP)
- );
- PostMessage(
- ctrl.hPostMsgDestHandle,
- WM_MF_CV_CALIBRATION_DONE,
- 0,
- 0
- );
- frmFatcory->DisableAllCalTimer();
- log->Add("n" +DateToStr(Date()) + " " + CurrentTimeStr() +
- " ====================== CV check end ===================== "
- );
- return true;
- }