form_RFReg.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:22k
源码类别:

MTK

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #ifndef _FORM_MAIN_H_
  5. #include "form_main.h"
  6. #endif
  7. #ifndef _FORM_RFREG_H_
  8. #include "form_RFReg.h"
  9. #endif
  10. // misc
  11. #ifndef  _FILE_UTILS_H_
  12. #include "file_utils.h"
  13. #endif
  14. #ifndef  _MISC_H_
  15. #include "misc.h"
  16. #endif
  17. #ifndef  _MISC_BB_H_
  18. #include "misc_bb.h"
  19. #endif
  20. //---------------------------------------------------------------------------
  21. #pragma package(smart_init)
  22. #pragma resource "*.dfm"
  23. TfrmRFReg *frmRFReg;
  24. //==========================================================================
  25. static void CNF_RF_ReadRegister( void )
  26. {
  27.     frmRFReg->RF_ReadRegister_Done();
  28. }
  29. //--------------------------------------------------------------------------
  30. static void CNF_RF_WriteRegister( void )
  31. {
  32.     frmRFReg->RF_WriteRegister_Done();
  33. }
  34. //---------------------------------------------------------------------------
  35. __fastcall TfrmRFReg::TfrmRFReg(TComponent* Owner)
  36.         : TForm(Owner)
  37. {
  38.     m_pvRfReg   = NULL;
  39.     m_pvRfRegUI = NULL;
  40. }
  41. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. void  TfrmRFReg::AllocateVector(void)
  43. {
  44.     if (NULL == m_pvRfRegUI)
  45.     {
  46.         m_pvRfRegUI = new vector<S_RF_REG_UI_T>;
  47.     }
  48. }
  49. //--------------------------------------------------------------------------
  50. void  TfrmRFReg::DeAllocateVector(void)
  51. {
  52.     if (NULL != m_pvRfRegUI)
  53.     {
  54.         delete m_pvRfRegUI;
  55.         m_pvRfRegUI = NULL;
  56.     }
  57. }
  58. //--------------------------------------------------------------------------
  59. void  TfrmRFReg::EraseVector(void)
  60. {
  61.     if (NULL != m_pvRfRegUI)
  62.     {
  63.         if (! m_pvRfRegUI->empty())
  64.         {
  65.             vector<S_RF_REG_UI_T>:: iterator iter;
  66.             for (iter = m_pvRfRegUI->begin(); iter != m_pvRfRegUI->end(); iter++)
  67.             {
  68.                 if (iter->lblRFRegName)
  69.                 {
  70.                     delete iter->lblRFRegName;
  71.                     iter->lblRFRegName = NULL;
  72.                 }
  73.                 if (iter->stRFRegName)
  74.                 {
  75.                     delete iter->stRFRegName;
  76.                     iter->stRFRegName = NULL;
  77.                 }
  78. //                if (iter->lblRFRegValue0X)
  79. //                {
  80. //                    delete iter->lblRFRegValue0X;
  81. //                    iter->lblRFRegValue0X = NULL;
  82. //                }
  83.                 if (iter->edtRFReadBsiData)
  84.                 {
  85.                     delete iter->edtRFReadBsiData;
  86.                     iter->edtRFReadBsiData = NULL;
  87.                 }
  88.                 if (iter->edtRFReadBsiData)
  89.                 {
  90.                     delete iter->edtRFReadBsiData;
  91.                     iter->edtRFReadBsiData = NULL;
  92.                 }
  93.                 if (iter->btnRFRegRead)
  94.                 {
  95.                     delete iter->btnRFRegRead;
  96.                     iter->btnRFRegRead = NULL;
  97.                 }
  98.                 if (iter->btnRFRegWrite)
  99.                 {
  100.                     delete iter->btnRFRegWrite;
  101.                     iter->btnRFRegWrite = NULL;
  102.                 }    
  103.             }
  104.             m_pvRfRegUI->erase(m_pvRfRegUI->begin(), m_pvRfRegUI->end());
  105.         }
  106.     }    
  107. }
  108. //---------------------------------------------------------------------------
  109. void __fastcall TfrmRFReg::FormCreate(TObject *Sender)
  110. {
  111.     m_bInit = true;
  112. }
  113. //---------------------------------------------------------------------------
  114. void __fastcall TfrmRFReg::FormActivate(TObject *Sender)
  115. {
  116.     if (m_bInit)
  117.     {
  118.         m_bInit = false;
  119.         m_ui2GRfId = frmMainSel->Get_FinalRFID();
  120.         if (RF_ID_A60111A == m_ui2GRfId)
  121.         {
  122.             frmRFReg->Caption = "A60111A RF transceiver Register Setting";
  123.             AnsiString as = ::Get_WorkingDirectory();
  124.             as += "\A60111A_reg.ini";
  125.             m_cRF_REG_Obj.REQ_Read_From_File(as.c_str());
  126.             Display_RfRegister();
  127.         }
  128.     }    
  129. }
  130. //---------------------------------------------------------------------------
  131. void __fastcall TfrmRFReg::FormDestroy(TObject *Sender)
  132. {
  133.     EraseVector();
  134.     DeAllocateVector();
  135. }
  136. //---------------------------------------------------------------------------
  137. void TfrmRFReg::Init(void)
  138. {
  139. }
  140. //===========================================================================
  141. void TfrmRFReg::Display_RfRegister(void)
  142. {
  143.     AllocateVector();
  144.     EraseVector();
  145.     m_pvRfReg = m_cRF_REG_Obj.Get_RfRegVector();
  146.     int i_lblRFRegName_top     =  40;
  147.     int i_lblRFRegName_left    =   8;
  148.     int i_stRFRegName_top      =  60;
  149.     int i_stRFRegName_left     =   8;
  150.     int i_lblRFRegAddr_top     =  40;
  151.     int i_lblRFRegAddr_left    =  40;
  152.     int i_stRFRegAddr_top      =  60;
  153.     int i_stRFRegAddr_left     =  50;
  154.     //int i_lblRFRegValue0X_top  =  60;
  155.     //int i_lblRFRegValue0X_left = 114;
  156.     //int i_lblRFRegValue_top    =  40;
  157.     //int i_lblRFRegValue_left = 152;
  158.     int i_lblRFBsiRead_top     =  40;
  159.     int i_lblRFBsiRead_left    =  80;
  160.     int i_edtRFBsiRead_top     =  56;
  161.     int i_edtRFBsiRead_left    =  80;
  162.     int i_lblRFBsiWrite_top    =  40;
  163.     int i_lblRFBsiWrite_left   = 180;
  164.     int i_edtRFBsiWrite_top    =  56;
  165.     int i_edtRFBsiWrite_left   = 180;
  166.     int i_btnRFRegRead_top     =  56;
  167.     int i_btnRFRegRead_left    = 276;
  168.     int i_btnRFRegWrite_top    =  56;
  169.     int i_btnRFRegWrite_left   = 318;
  170.     int i_vertical_offset        =  50;
  171.     int i_horizontal_offset      = 360;
  172.     vector<S_RF_REG_T>:: iterator iter;
  173.     int i=0;
  174.     for (iter = m_pvRfReg->begin(); iter != m_pvRfReg->end(); iter++)
  175.     {
  176.         S_RF_REG_UI_T rf_reg_ui;
  177.         if (0 == i%2)
  178.         {
  179.             if (0 == i)
  180.             {
  181.                 rf_reg_ui.lblRFRegName = new TLabel(this);
  182.                 rf_reg_ui.lblRFRegName->Parent = frmRFReg;
  183.                 rf_reg_ui.lblRFRegName->Caption = "Name";
  184.                 rf_reg_ui.lblRFRegName->Top = i_lblRFRegName_top + i/2 * i_vertical_offset;
  185.                 rf_reg_ui.lblRFRegName->Left = i_lblRFRegName_left;
  186.                 rf_reg_ui.lblRFRegAddr = new TLabel(this);
  187.                 rf_reg_ui.lblRFRegAddr->Parent = frmRFReg;
  188.                 rf_reg_ui.lblRFRegAddr->Caption = "Address";
  189.                 rf_reg_ui.lblRFRegAddr->Top = i_lblRFRegAddr_top + i/2 * i_vertical_offset;
  190.                 rf_reg_ui.lblRFRegAddr->Left = i_lblRFRegAddr_left;
  191.             }
  192.             rf_reg_ui.stRFRegName = new TStaticText(this);
  193.             rf_reg_ui.stRFRegName->Parent = frmRFReg;
  194.             rf_reg_ui.stRFRegName->Caption = iter->as_name;
  195.             rf_reg_ui.stRFRegName->Tag = i;
  196.             rf_reg_ui.stRFRegName->Top = i_stRFRegName_top + i/2 * i_vertical_offset;
  197.             rf_reg_ui.stRFRegName->Left = i_stRFRegName_left;
  198.             rf_reg_ui.stRFRegAddr = new TStaticText(this);
  199.             rf_reg_ui.stRFRegAddr->Parent = frmRFReg;
  200.             char str[5];
  201.             sprintf(str, "0x%X", iter->ui_addr);
  202.             rf_reg_ui.stRFRegAddr->Caption = (AnsiString) str;
  203.             rf_reg_ui.stRFRegAddr->Tag = i;
  204.             rf_reg_ui.stRFRegAddr->Top = i_stRFRegAddr_top + i/2 * i_vertical_offset;
  205.             rf_reg_ui.stRFRegAddr->Left = i_stRFRegAddr_left;
  206.            // rf_reg_ui.lblRFRegValue0X = new TLabel(this);
  207.            // rf_reg_ui.lblRFRegValue0X->Parent = frmRFReg;
  208.            // rf_reg_ui.lblRFRegValue0X->Caption = "0x";
  209.            // rf_reg_ui.lblRFRegValue0X->Tag = i;
  210.            // rf_reg_ui.lblRFRegValue0X->Top = i_lblRFRegValue0X_top + i/2 * i_vertical_offset;
  211.            // rf_reg_ui.lblRFRegValue0X->Left = i_lblRFRegValue0X_left;
  212.             rf_reg_ui.lblRFReadBsiData = new TLabel(this);
  213.             rf_reg_ui.lblRFReadBsiData->Parent = frmRFReg;
  214.             rf_reg_ui.lblRFReadBsiData->Caption = "Read BSI data(Hex)";
  215.             rf_reg_ui.lblRFReadBsiData->Tag = i;
  216.             rf_reg_ui.lblRFReadBsiData->Top = i_lblRFBsiRead_top + i/2 * i_vertical_offset;
  217.             rf_reg_ui.lblRFReadBsiData->Left = i_lblRFBsiRead_left;
  218.             rf_reg_ui.edtRFReadBsiData = new TEdit(this);
  219.             rf_reg_ui.edtRFReadBsiData->Parent = frmRFReg;
  220.             rf_reg_ui.edtRFReadBsiData->Text = iter->ui_read_bsi_data;
  221.             rf_reg_ui.edtRFReadBsiData->Tag = i;
  222.             rf_reg_ui.edtRFReadBsiData->Top = i_edtRFBsiRead_top + i/2 * i_vertical_offset;
  223.             rf_reg_ui.edtRFReadBsiData->Left = i_edtRFBsiRead_left;
  224.             rf_reg_ui.edtRFReadBsiData->Width = 81;
  225.             rf_reg_ui.lblRFWriteBsiData = new TLabel(this);
  226.             rf_reg_ui.lblRFWriteBsiData->Parent = frmRFReg;
  227.             rf_reg_ui.lblRFWriteBsiData->Caption = "Write BSI data(Hex)";
  228.             rf_reg_ui.lblRFWriteBsiData->Tag = i;
  229.             rf_reg_ui.lblRFWriteBsiData->Top = i_lblRFBsiWrite_top + i/2 * i_vertical_offset;
  230.             rf_reg_ui.lblRFWriteBsiData->Left = i_lblRFBsiWrite_left;
  231.             rf_reg_ui.edtRFWriteBsiData = new TEdit(this);
  232.             rf_reg_ui.edtRFWriteBsiData->Parent = frmRFReg;
  233.             rf_reg_ui.edtRFWriteBsiData->Text = iter->ui_write_bsi_data;
  234.             rf_reg_ui.edtRFWriteBsiData->Tag = i;
  235.             rf_reg_ui.edtRFWriteBsiData->Top = i_edtRFBsiWrite_top + i/2 * i_vertical_offset;
  236.             rf_reg_ui.edtRFWriteBsiData->Left = i_edtRFBsiWrite_left;
  237.             rf_reg_ui.edtRFWriteBsiData->Width = 81;
  238.             rf_reg_ui.btnRFRegRead = new TButton(this);
  239.             rf_reg_ui.btnRFRegRead->Parent = frmRFReg;
  240.             rf_reg_ui.btnRFRegRead->Caption = "Read";
  241.             rf_reg_ui.btnRFRegRead->Tag = i;
  242.             rf_reg_ui.btnRFRegRead->Top = i_btnRFRegRead_top + i/2 * i_vertical_offset;
  243.             rf_reg_ui.btnRFRegRead->Left = i_btnRFRegRead_left;
  244.             rf_reg_ui.btnRFRegRead->Width = 40;
  245.             rf_reg_ui.btnRFRegRead->OnClick = btnRfRegReadClick;
  246.             rf_reg_ui.btnRFRegWrite = new TButton(this);
  247.             rf_reg_ui.btnRFRegWrite->Parent = frmRFReg;
  248.             rf_reg_ui.btnRFRegWrite->Caption = "Write";
  249.             rf_reg_ui.btnRFRegWrite->Tag = i;
  250.             rf_reg_ui.btnRFRegWrite->Top = i_btnRFRegWrite_top + i/2 * i_vertical_offset;
  251.             rf_reg_ui.btnRFRegWrite->Left = i_btnRFRegWrite_left;
  252.             rf_reg_ui.btnRFRegWrite->Width = 40;
  253.             rf_reg_ui.btnRFRegWrite->OnClick = btnRfRegWriteClick;
  254.         }
  255.         else
  256.         {
  257.             if (1 == i)
  258.             {
  259.                 rf_reg_ui.lblRFRegName = new TLabel(this);
  260.                 rf_reg_ui.lblRFRegName->Parent = frmRFReg;
  261.                 rf_reg_ui.lblRFRegName->Caption = "Name";
  262.                 rf_reg_ui.lblRFRegName->Top = i_lblRFRegName_top + i/2 * i_vertical_offset;
  263.                 rf_reg_ui.lblRFRegName->Left = i_lblRFRegName_left + i_horizontal_offset;
  264.                 rf_reg_ui.lblRFRegAddr = new TLabel(this);
  265.                 rf_reg_ui.lblRFRegAddr->Parent = frmRFReg;
  266.                 rf_reg_ui.lblRFRegAddr->Caption = "Address (Hex)";
  267.                 rf_reg_ui.lblRFRegAddr->Top = i_lblRFRegAddr_top + i/2 * i_vertical_offset;
  268.                 rf_reg_ui.lblRFRegAddr->Left = i_lblRFRegAddr_left + i_horizontal_offset;
  269.             }
  270.             rf_reg_ui.stRFRegName = new TStaticText(this);
  271.             rf_reg_ui.stRFRegName->Parent = frmRFReg;
  272.             rf_reg_ui.stRFRegName->Caption = iter->as_name;
  273.             rf_reg_ui.stRFRegName->Tag = i;
  274.             rf_reg_ui.stRFRegName->Top = i_stRFRegName_top + i/2 * i_vertical_offset;
  275.             rf_reg_ui.stRFRegName->Left = i_stRFRegName_left + i_horizontal_offset;
  276.             rf_reg_ui.stRFRegAddr = new TStaticText(this);
  277.             rf_reg_ui.stRFRegAddr->Parent = frmRFReg;
  278.             char str[5];
  279.             sprintf(str, "0x%X", iter->ui_addr);
  280.             rf_reg_ui.stRFRegAddr->Caption = (AnsiString) str;
  281.             rf_reg_ui.stRFRegAddr->Tag = i;
  282.             rf_reg_ui.stRFRegAddr->Top = i_stRFRegAddr_top + i/2 * i_vertical_offset;
  283.             rf_reg_ui.stRFRegAddr->Left = i_stRFRegAddr_left + i_horizontal_offset;
  284.            // rf_reg_ui.lblRFRegValue0X = new TLabel(this);
  285.            // rf_reg_ui.lblRFRegValue0X->Parent = frmRFReg;
  286.            // rf_reg_ui.lblRFRegValue0X->Caption = "0x";
  287.            // rf_reg_ui.lblRFRegValue0X->Tag = i;
  288.            // rf_reg_ui.lblRFRegValue0X->Top = i_lblRFRegValue0X_top + i/2 * i_vertical_offset;
  289.            // rf_reg_ui.lblRFRegValue0X->Left = i_lblRFRegValue0X_left + i_horizontal_offset;
  290.             rf_reg_ui.lblRFReadBsiData = new TLabel(this);
  291.             rf_reg_ui.lblRFReadBsiData->Parent = frmRFReg;
  292.             rf_reg_ui.lblRFReadBsiData->Caption = "Read BSI data(Hex)";
  293.             rf_reg_ui.lblRFReadBsiData->Tag = i;
  294.             rf_reg_ui.lblRFReadBsiData->Top = i_lblRFBsiRead_top + i/2 * i_vertical_offset;
  295.             rf_reg_ui.lblRFReadBsiData->Left = i_lblRFBsiRead_left + i_horizontal_offset;
  296.             rf_reg_ui.edtRFReadBsiData = new TEdit(this);
  297.             rf_reg_ui.edtRFReadBsiData->Parent = frmRFReg;
  298.             rf_reg_ui.edtRFReadBsiData->Text = iter->ui_read_bsi_data;
  299.             rf_reg_ui.edtRFReadBsiData->Tag = i;
  300.             rf_reg_ui.edtRFReadBsiData->Top = i_edtRFBsiRead_top + i/2 * i_vertical_offset;
  301.             rf_reg_ui.edtRFReadBsiData->Left = i_edtRFBsiRead_left + i_horizontal_offset;
  302.             rf_reg_ui.edtRFReadBsiData->Width = 81;
  303.             rf_reg_ui.lblRFWriteBsiData = new TLabel(this);
  304.             rf_reg_ui.lblRFWriteBsiData->Parent = frmRFReg;
  305.             rf_reg_ui.lblRFWriteBsiData->Caption = "Write BSI data(Hex)";
  306.             rf_reg_ui.lblRFWriteBsiData->Tag = i;
  307.             rf_reg_ui.lblRFWriteBsiData->Top = i_lblRFBsiWrite_top + i/2 * i_vertical_offset;
  308.             rf_reg_ui.lblRFWriteBsiData->Left = i_lblRFBsiWrite_left + i_horizontal_offset;
  309.             rf_reg_ui.edtRFWriteBsiData = new TEdit(this);
  310.             rf_reg_ui.edtRFWriteBsiData->Parent = frmRFReg;
  311.             rf_reg_ui.edtRFWriteBsiData->Text = iter->ui_write_bsi_data;
  312.             rf_reg_ui.edtRFWriteBsiData->Tag = i;
  313.             rf_reg_ui.edtRFWriteBsiData->Top = i_edtRFBsiWrite_top + i/2 * i_vertical_offset;
  314.             rf_reg_ui.edtRFWriteBsiData->Left = i_edtRFBsiWrite_left + i_horizontal_offset;
  315.             rf_reg_ui.edtRFWriteBsiData->Width = 81;
  316.             rf_reg_ui.btnRFRegRead = new TButton(this);
  317.             rf_reg_ui.btnRFRegRead->Parent = frmRFReg;
  318.             rf_reg_ui.btnRFRegRead->Caption = "Read";
  319.             rf_reg_ui.btnRFRegRead->Tag = i;
  320.             rf_reg_ui.btnRFRegRead->Top = i_btnRFRegRead_top + i/2 * i_vertical_offset;
  321.             rf_reg_ui.btnRFRegRead->Left = i_btnRFRegRead_left + i_horizontal_offset;
  322.             rf_reg_ui.btnRFRegRead->Width = 40;
  323.             rf_reg_ui.btnRFRegRead->OnClick = btnRfRegReadClick;
  324.             rf_reg_ui.btnRFRegWrite = new TButton(this);
  325.             rf_reg_ui.btnRFRegWrite->Parent = frmRFReg;
  326.             rf_reg_ui.btnRFRegWrite->Caption = "Write";
  327.             rf_reg_ui.btnRFRegWrite->Tag = i;
  328.             rf_reg_ui.btnRFRegWrite->Top = i_btnRFRegWrite_top + i/2 * i_vertical_offset;
  329.             rf_reg_ui.btnRFRegWrite->Left = i_btnRFRegWrite_left + i_horizontal_offset;
  330.             rf_reg_ui.btnRFRegWrite->Width = 40;
  331.             rf_reg_ui.btnRFRegWrite->OnClick = btnRfRegWriteClick;
  332.         }
  333.         m_pvRfRegUI->push_back(rf_reg_ui);
  334.         i++;
  335.     }
  336. }
  337. //---------------------------------------------------------------------------
  338. bool  TfrmRFReg::CheckFields(E_RF_REG_OP_T e_op, int tag)
  339. {
  340.     AnsiString  text;
  341.     unsigned int uidata;
  342.     vector<S_RF_REG_UI_T>:: iterator iter;
  343.     if (RF_REG_OP_READ == e_op)
  344.     {
  345.         for (iter = m_pvRfRegUI->begin(); iter != m_pvRfRegUI->end(); iter++)
  346.         {
  347.             if (iter->edtRFReadBsiData->Tag == tag)
  348.             {
  349.                 break;
  350.             }
  351.         }
  352.         m_uiBsiAddr = iter->stRFRegAddr->Caption.ToInt();
  353.     }
  354.     else // write
  355.     {
  356.         for (iter = m_pvRfRegUI->begin(); iter != m_pvRfRegUI->end(); iter++)
  357.         {
  358.             if (iter->edtRFWriteBsiData->Tag == tag)
  359.             {
  360.                 break;
  361.             }
  362.         }
  363.         text = iter->edtRFWriteBsiData->Text;
  364.        // text = text.SubString(3, text.Length()-2);
  365.         if (!IsValidHexBsiData(text, uidata))
  366.         {
  367.             return false;
  368.         }
  369.         m_uiBsiData = uidata;
  370.     }
  371.     return true;
  372. }
  373. //---------------------------------------------------------------------------
  374. void  TfrmRFReg::ReDrawFields(int tag)
  375. {
  376.     char str[256];
  377.     vector<S_RF_REG_UI_T>:: iterator iter;
  378.     for (iter = m_pvRfRegUI->begin(); iter != m_pvRfRegUI->end(); iter++)
  379.     {
  380.         if ((int)iter->edtRFReadBsiData->Tag == tag)
  381.         {
  382.             break;
  383.         }
  384.     }
  385.    // if (DEC_FORMAT == btnPMICRegValue->Tag)  // Dec
  386.    // {
  387.    //     iter->edtRFReadBsiData->Caption = "Value (Dec)";
  388.    //     iter->lblRFRegValue0X->Visible = false;
  389.    //     iter->edtRFReadBsiData->Text = IntToStr(m_uiBsiData);
  390.    // }
  391.    // else  // Hex
  392.     {
  393.         //iter->lblRFReadBsiData->Caption = "Value (Hex)";
  394.         //iter->lblRFRegValue0X->Visible = true;
  395.         sprintf( str, "%X", (int)m_uiBsiData );
  396.         iter->edtRFReadBsiData->Text = str;
  397.     }
  398. }
  399. //---------------------------------------------------------------------------
  400. void __fastcall TfrmRFReg::edtRfValueCheck(TObject *Sender)
  401. {
  402.     AnsiString  text;
  403.     unsigned int uidata;
  404.     int  band;
  405.     TEdit *edit = (TEdit*)Sender;
  406.     char  hint[] = " character is not valid ";
  407.     text = edit->Text;
  408.     if (! IsValidHexBsiData(text, uidata))
  409.     {
  410.         ShowHintLabel(edit, hint);
  411.         edit->SetFocus();
  412.         return;
  413.     }
  414.     m_uiBsiData = uidata;
  415. }
  416. //---------------------------------------------------------------------------
  417. void __fastcall TfrmRFReg::btnRfRegReadClick(TObject *Sender)
  418. {
  419.     TButton* btn = (TButton*) Sender;
  420.     m_iTag = btn->Tag;
  421.     if (!CheckFields(RF_REG_OP_READ, btn->Tag))
  422.     {
  423.         Application->MessageBox("Read RF trasceiver register fail", "FAIL", MB_OK);
  424.         Application->MessageBox("Execution Failure : Read RF trasceiver register", "FAILURE", MB_OK );
  425.         return;
  426.     }
  427.     m_cRF_REG_Obj.ConfirmCallback = ::CNF_RF_ReadRegister;
  428.     m_cRF_REG_Obj.REQ_ReadRegister_Start(m_uiBsiAddr);
  429.     m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Read RF trasceiver register progressing";
  430. }
  431. //-----------------------------------------------
  432. void  TfrmRFReg::RF_ReadRegister_Done(void)
  433. {
  434.     E_METAAPP_RESULT_T state = m_cRF_REG_Obj.Get_ConfirmState();
  435.     switch (state)
  436.     {
  437.         case METAAPP_SUCCESS:
  438.         {
  439.             m_uiBsiData = m_cRF_REG_Obj.Get_BsiData();
  440.             ReDrawFields(m_iTag);
  441.             m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Read RF trasceiver register successfully";
  442.         }
  443.         break;
  444.         case METAAPP_FAIL:
  445.         {
  446.             m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Read RF trasceiver register fail";
  447.             Application->MessageBox( "Execution Failure : Read RF trasceiver register", "FAILURE", MB_OK );
  448.         }
  449.         break;
  450.         case METAAPP_TIMEOUT:
  451.         {
  452.             m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Read RF trasceiver register timeout";
  453.             Application->MessageBox( "Execution Timeout : Read RF trasceiver register", "TIMEOUT", MB_OK );
  454.         }
  455.         break;
  456.         case METAAPP_STOP:
  457.         {
  458.             m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Read RF trasceiver register stop";
  459.         }
  460.         break;
  461.         default:
  462.         break;
  463.     }
  464. }
  465. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  466. void __fastcall TfrmRFReg::btnRfRegWriteClick(TObject *Sender)
  467. {
  468.     TButton* btn = (TButton*) Sender;
  469.     m_iTag = btn->Tag;
  470.     if (!CheckFields(RF_REG_OP_WRITE, btn->Tag))
  471.     {
  472.         m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Write RF trasceiver register fail";
  473.         Application->MessageBox("Execution Failure : Write RF trasceiver register", "FAILURE", MB_OK);
  474.         return;
  475.     }
  476.     m_cRF_REG_Obj.ConfirmCallback = ::CNF_RF_WriteRegister;
  477.     m_cRF_REG_Obj.REQ_WriteRegister_Start(m_uiBsiData);
  478.     m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Write RF trasceiver register progressing";
  479. }
  480. //-----------------------------------------------
  481. void TfrmRFReg::RF_WriteRegister_Done(void)
  482. {
  483.     E_METAAPP_RESULT_T state = m_cRF_REG_Obj.Get_ConfirmState();
  484.     switch (state)
  485.     {
  486.         case METAAPP_SUCCESS:
  487.         {
  488.             m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Write baseband register successfully";
  489.         }
  490.         break;
  491.         case METAAPP_FAIL:
  492.         {
  493.             m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Write baseband register fail";
  494.             Application->MessageBox( "Execution Failure : Write Baseband register", "FAILURE", MB_OK );
  495.         }
  496.         break;
  497.         case METAAPP_TIMEOUT:
  498.         {
  499.             m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Write baseband register timeout";
  500.             Application->MessageBox( "Execution Timeout : Write Baseband register", "TIMEOUT", MB_OK );
  501.         }
  502.         break;
  503.         case METAAPP_STOP:
  504.         {
  505.             m_sbRfReg->Panels->Items[0]->Text = (AnsiString) "  Write baseband register stop";
  506.         }
  507.         break;
  508.         default:
  509.         break;
  510.     }
  511. }
  512. //---------------------------------------------------------------------------
  513. void  TfrmRFReg::ShowHintLabel(TControl *sender, char* hint)
  514. {
  515.    TPoint pt0 = this->ClientOrigin;
  516.    TPoint pt1 = sender->ClientOrigin;
  517.    lblHint->Left = (pt1.x-pt0.x);
  518.    lblHint->Top  = (pt1.y-pt0.y)+sender->Height+3;
  519.    lblHint->Caption = hint;
  520.    lblHint->Visible = true;
  521.    HintTimer->Enabled = true;
  522. }
  523. //---------------------------------------------------------------------------
  524. void __fastcall TfrmRFReg::HintTimerTimer(TObject *Sender)
  525. {
  526.     HintTimer->Enabled = false;
  527.     lblHint->Visible = false;
  528. }
  529. //---------------------------------------------------------------------------