BTT_ctrl.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:
- * ---------
- * BTT_ctrl.cpp
- *
- * Project:
- * --------
- * Maui META APP
- *
- * Description:
- * ------------
- * BT Tester control function 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 <vcl.h>
- #pragma hdrstop
- // equipment
- #ifndef _CMU200_BT_SIG_H_
- #include "cmu200_bt_sig.h"
- #endif
- #ifndef _BTT_COMMON_H_
- #include "btt_common.h"
- #endif
- #ifndef _BTT_CTRL_H_
- #include "btt_ctrl.h"
- #endif
- #ifndef _CBT_BT_SIG_H_
- #include "cbt_bt_sig.h"
- #endif
- //===========================================================================
- CBTTCTRL::CBTTCTRL( void )
- {
- }
- //---------------------------------------------------------------------------
- CBTTCTRL::~CBTTCTRL()
- {
- }
- //=============================================================================
- bool CBTTCTRL::BTT_Init(S_BTT *p_btt)
- {
- //-----------------------------------------------------------------------
- // CMU
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_init(&(p_btt->cmu), p_btt->bReset))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_init(&(p_btt->s_cbt), p_btt->bReset))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Close(S_BTT *p_btt)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_close(&(p_btt->cmu)))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_close(&(p_btt->s_cbt)))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Config_Slave_Parameter(S_BTT *p_btt, unsigned short ch)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_config_slave_parameter(&(p_btt->cmu), ch))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_config_slave_parameter(&(p_btt->s_cbt), ch))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Config_Downlink_Power(S_BTT *p_btt, double d_dn_power)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_config_downlink_power(&(p_btt->cmu), d_dn_power))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_config_downlink_power(&(p_btt->s_cbt), d_dn_power))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Config_BD_Address(S_BTT *p_btt, AnsiString as_bd_addr)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_config_address(&(p_btt->cmu), as_bd_addr))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_config_address(&(p_btt->s_cbt), as_bd_addr))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Config_Inquiry(S_BTT *p_btt, S_BTT_INQUIRY s_inquiry)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_config_inquiry(&(p_btt->cmu), s_inquiry)) //unit of timeout: 1.28s
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_config_inquiry(&(p_btt->s_cbt), s_inquiry)) //unit of timeout: 1.28s
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Inquiry(S_BTT *p_btt)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_inquiry(&(p_btt->cmu)))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_inquiry(&(p_btt->s_cbt)))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Connect_Test(S_BTT *p_btt)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_connect_test(&(p_btt->cmu)))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_connect_test(&(p_btt->s_cbt)))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Query_State(S_BTT *p_btt, E_BTT_STATE_T &e_state)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_query_state(&(p_btt->cmu), &e_state))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_query_state(&(p_btt->s_cbt), &e_state))
- {
- return false;
- }
- }
-
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Release(S_BTT *p_btt)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_release(&(p_btt->cmu)))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_release(&(p_btt->s_cbt)))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Config_MPR(S_BTT *p_btt, S_BTT_POWER bt_mpr)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_config_mpr(&(p_btt->cmu), bt_mpr))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_config_mpr(&(p_btt->s_cbt), bt_mpr))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Config_MOD(S_BTT *p_btt, S_BTT_MOD bt_mod)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_config_mod(&(p_btt->cmu), bt_mod))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_config_mod(&(p_btt->s_cbt), bt_mod))
- {
- return false;
- }
- }
- return true;
- }
- //----------------------------------------------------------------------------
- bool CBTTCTRL::BTT_Read_Average_Freq_Error(S_BTT *p_btt, double &freq_err)
- {
- if (BT_DEVICE_CMU_200 == p_btt->e_device_type)
- {
- if (!cmu_sig_bt_read_average_freq_error(&(p_btt->cmu), &freq_err))
- {
- return false;
- }
- }
- else if (BT_DEVICE_CBT == p_btt->e_device_type)
- {
- if (!cbt_sig_bt_read_average_freq_error(&(p_btt->s_cbt), &freq_err))
- {
- return false;
- }
- }
- return true;
- }