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

MTK

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include <stdio.h>
  4. #pragma hdrstop
  5. #ifndef  _METAAPP_COMMON_H_
  6. #include "METAAPP_common.h"
  7. #endif
  8. // form
  9. #ifndef _FORM_PMICREG_H_
  10. #include "form_PMICReg.h"
  11. #endif
  12. #ifndef _FORM_BASEBAND_H_
  13. #include "form_BaseBand.h"
  14. #endif
  15. // misc
  16. #ifndef  _FILE_UTILS_H_
  17. #include "file_utils.h"
  18. #endif
  19. #ifndef  _MISC_BB_H_
  20. #include "misc_bb.h"
  21. #endif
  22. //---------------------------------------------------------------------------
  23. #pragma package(smart_init)
  24. #pragma resource "*.dfm"
  25. TfrmPMICReg *frmPMICReg;
  26. //==========================================================================
  27. static void CNF_PMIC_ReadRegister( void )
  28. {
  29.     frmPMICReg->PMIC_ReadRegister_Done();
  30. }
  31. //--------------------------------------------------------------------------
  32. static void CNF_PMIC_WriteRegister( void )
  33. {
  34.     frmPMICReg->PMIC_WriteRegister_Done();
  35. }
  36. //---------------------------------------------------------------------------
  37. __fastcall TfrmPMICReg::TfrmPMICReg(TComponent* Owner)
  38.         : TForm(Owner)
  39. {
  40.     m_pvPmicReg   = NULL;
  41.     m_pvPmicRegUI = NULL;
  42. }
  43. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  44. void  TfrmPMICReg::AllocateVector(void)
  45. {
  46.     if (NULL == m_pvPmicRegUI)
  47.     {
  48.         m_pvPmicRegUI = new vector<S_PMIC_REG_UI_T>;
  49.     }
  50. }
  51. //--------------------------------------------------------------------------
  52. void  TfrmPMICReg::DeAllocateVector(void)
  53. {
  54.     if (NULL != m_pvPmicRegUI)
  55.     {
  56.         delete m_pvPmicRegUI;
  57.         m_pvPmicRegUI = NULL;
  58.     }
  59. }
  60. //--------------------------------------------------------------------------
  61. void  TfrmPMICReg::EraseVector(void)
  62. {
  63.     if (NULL != m_pvPmicRegUI)
  64.     {
  65.         if (! m_pvPmicRegUI->empty())
  66.         {
  67.             vector<S_PMIC_REG_UI_T>:: iterator iter;
  68.             for (iter = m_pvPmicRegUI->begin(); iter != m_pvPmicRegUI->end(); iter++)
  69.             {
  70.                 //delete iter->lblPMICRegAddr0X;
  71.                 if (iter->lblPMICRegAddr)
  72.                 {
  73.                     delete iter->lblPMICRegAddr;
  74.                     iter->lblPMICRegAddr = NULL;
  75.                 }
  76.                 if (iter->stPMICRegAddr)
  77.                 {
  78.                     delete iter->stPMICRegAddr;
  79.                     iter->stPMICRegAddr = NULL;
  80.                 }
  81.                 if (iter->lblPMICRegValue0X)
  82.                 {
  83.                     delete iter->lblPMICRegValue0X;
  84.                     iter->lblPMICRegValue0X = NULL;
  85.                 }
  86.                 if (iter->lblPMICRegValue)
  87.                 {
  88.                     delete iter->lblPMICRegValue;
  89.                     iter->lblPMICRegValue = NULL;
  90.                 }
  91.                 if (iter->edtPMICValue)
  92.                 {
  93.                     delete iter->edtPMICValue;
  94.                     iter->edtPMICValue = NULL;
  95.                 }
  96.                 if (iter->btnPMICRegRead)
  97.                 {
  98.                     delete iter->btnPMICRegRead;
  99.                     iter->btnPMICRegRead = NULL;
  100.                 }
  101.                 if (iter->btnPMICRegWrite)
  102.                 {
  103.                     delete iter->btnPMICRegWrite;
  104.                     iter->btnPMICRegWrite = NULL;
  105.                 }    
  106.             }
  107.             m_pvPmicRegUI->erase(m_pvPmicRegUI->begin(), m_pvPmicRegUI->end());
  108.         }
  109.     }    
  110. }
  111. //---------------------------------------------------------------------------
  112. void __fastcall TfrmPMICReg::FormCreate(TObject *Sender)
  113. {
  114.     m_bInit = true;
  115. }
  116. //---------------------------------------------------------------------------
  117. void __fastcall TfrmPMICReg::FormActivate(TObject *Sender)
  118. {
  119.     if (m_bInit)
  120.     {
  121.         m_bInit = false;
  122.         PMIC_ID* psPmicId;
  123.         psPmicId = frmBaseBand->Get_PMIC_ID();
  124.         m_sPmicId = *psPmicId;
  125.         if (FT_MT6318 == m_sPmicId.id)
  126.         {
  127.             frmPMICReg->Caption = "MT6318 PMIC Register Setting";
  128.             AnsiString as = ::Get_WorkingDirectory();
  129.             as += "\MT6318.ini";
  130.             m_cBB_PMIC_REG_Obj.REQ_Read_From_File(as.c_str());
  131.             Display_PMICRegister();
  132.         }
  133.     }
  134. }
  135. //---------------------------------------------------------------------------
  136. void __fastcall TfrmPMICReg::FormDestroy(TObject *Sender)
  137. {
  138.     EraseVector();
  139.     DeAllocateVector();
  140. }
  141. //---------------------------------------------------------------------------
  142. void TfrmPMICReg::Init( void )
  143. {
  144.     //m_bInit = true;
  145. }
  146. //===========================================================================
  147. void TfrmPMICReg::Display_PMICRegister(void)
  148. {
  149.     AllocateVector();
  150.     EraseVector();
  151.     m_pvPmicReg = m_cBB_PMIC_REG_Obj.Get_PMICRegVector();
  152.     //int i_lblPMICRegName_top     =  40;
  153.     //int i_lblPMICRegName_left    =   8;
  154.     //int i_stPMICRegName_top      =  60;
  155.     //int i_stPMICRegName_left     =   8;
  156.     int i_lblPMICRegAddr_top     =  40;
  157.     int i_lblPMICRegAddr_left    =  32;
  158.     int i_stPMICAddr_top         =  56;
  159.     int i_stPMICAddr_left        =  24;
  160.     int i_lblPMICRegValue0X_top  =  60;
  161.     int i_lblPMICRegValue0X_left = 114;
  162.     //int i_lblPMICRegValue_top    =  40;
  163.     //int i_lblPMICRegValue_left   = 152;
  164.     int i_edtPMICValue_top       =  56;
  165.     int i_edtPMICValue_left      = 128;
  166.     int i_btnPMICRegRead_top     =  56;
  167.     int i_btnPMICRegRead_left    = 216;
  168.     int i_btnPMICRegWrite_top    =  56;
  169.     int i_btnPMICRegWrite_left   = 288;
  170.     int i_vertical_offset        =  50;
  171.     int i_horizontal_offset      = 360;
  172.     vector<S_BB_PMIC_REG_T>:: iterator iter;
  173.     int i=0;
  174.     for (iter = m_pvPmicReg->begin(); iter != m_pvPmicReg->end(); iter++)
  175.     {
  176.         S_PMIC_REG_UI_T pmic_reg_ui;
  177.         if (0 == i%2)
  178.         {
  179.             //pmic_reg_ui.lblPMICRegName = new TLabel(this);
  180.             //pmic_reg_ui.lblPMICRegName->Parent = frmPMICReg;
  181.             //pmic_reg_ui.lblPMICRegName->Caption = "Name";
  182.             //pmic_reg_ui.lblPMICRegName->Top = i_lblPMICRegName_top + i/2 * i_vertical_offset;
  183.             //pmic_reg_ui.lblPMICRegName->Left = i_lblPMICRegName_left;
  184.             //pmic_reg_ui.stPMICRegName = new TStaticText(this);
  185.             //pmic_reg_ui.stPMICRegName->Parent = frmPMICReg;
  186.             //pmic_reg_ui.stPMICRegName->Caption = iter->as_name;
  187.             //pmic_reg_ui.stPMICRegName->Tag = i;
  188.             //pmic_reg_ui.stPMICRegName->Top = i_stPMICRegName_top + i/2 * i_vertical_offset;
  189.             //pmic_reg_ui.stPMICRegNamer->Left = i_stPMICRegName_left;
  190.             pmic_reg_ui.lblPMICRegAddr = new TLabel(this);
  191.             pmic_reg_ui.lblPMICRegAddr->Parent = frmPMICReg;
  192.             pmic_reg_ui.lblPMICRegAddr->Caption = "Address (Hex)";
  193.             pmic_reg_ui.lblPMICRegAddr->Top = i_lblPMICRegAddr_top + i/2 * i_vertical_offset;
  194.             pmic_reg_ui.lblPMICRegAddr->Left = i_lblPMICRegAddr_left;
  195.             pmic_reg_ui.stPMICRegAddr = new TStaticText(this);
  196.             pmic_reg_ui.stPMICRegAddr->Parent = frmPMICReg;
  197.             char str[5];
  198.             sprintf(str, "0x%X", iter->us_index);
  199.             pmic_reg_ui.stPMICRegAddr->Caption = (AnsiString) str;
  200.             pmic_reg_ui.stPMICRegAddr->Tag = i;
  201.             pmic_reg_ui.stPMICRegAddr->Top = i_stPMICAddr_top + i/2 * i_vertical_offset;
  202.             pmic_reg_ui.stPMICRegAddr->Left = i_stPMICAddr_left;
  203.             pmic_reg_ui.lblPMICRegValue0X = new TLabel(this);
  204.             pmic_reg_ui.lblPMICRegValue0X->Parent = frmPMICReg;
  205.             pmic_reg_ui.lblPMICRegValue0X->Caption = "0x";
  206.             pmic_reg_ui.lblPMICRegValue0X->Tag = i;
  207.             pmic_reg_ui.lblPMICRegValue0X->Top = i_lblPMICRegValue0X_top + i/2 * i_vertical_offset;
  208.             pmic_reg_ui.lblPMICRegValue0X->Left = i_lblPMICRegValue0X_left;
  209.             pmic_reg_ui.lblPMICRegValue = new TLabel(this);
  210.             pmic_reg_ui.lblPMICRegValue->Parent = frmPMICReg;
  211.             pmic_reg_ui.lblPMICRegValue->Caption = "Value(Hex)";
  212.             pmic_reg_ui.lblPMICRegValue->Tag = i;
  213.             pmic_reg_ui.lblPMICRegValue->Top = i_edtPMICValue_top + i/2 * i_vertical_offset;
  214.             pmic_reg_ui.lblPMICRegValue->Left = i_edtPMICValue_left;
  215.             pmic_reg_ui.edtPMICValue = new TEdit(this);
  216.             pmic_reg_ui.edtPMICValue->Parent = frmPMICReg;
  217.             pmic_reg_ui.edtPMICValue->Text = iter->uc_value;
  218.             pmic_reg_ui.edtPMICValue->Tag = i;
  219.             pmic_reg_ui.edtPMICValue->Top = i_edtPMICValue_top + i/2 * i_vertical_offset;
  220.             pmic_reg_ui.edtPMICValue->Left = i_edtPMICValue_left;
  221.             pmic_reg_ui.edtPMICValue->Width = 81;
  222.             pmic_reg_ui.btnPMICRegRead = new TButton(this);
  223.             pmic_reg_ui.btnPMICRegRead->Parent = frmPMICReg;
  224.             pmic_reg_ui.btnPMICRegRead->Caption = "Read";
  225.             pmic_reg_ui.btnPMICRegRead->Tag = i;
  226.             pmic_reg_ui.btnPMICRegRead->Top = i_btnPMICRegRead_top + i/2 * i_vertical_offset;
  227.             pmic_reg_ui.btnPMICRegRead->Left = i_btnPMICRegRead_left;
  228.             pmic_reg_ui.btnPMICRegRead->Width = 65;
  229.             pmic_reg_ui.btnPMICRegRead->OnClick = btnPMICRegReadClick;
  230.             pmic_reg_ui.btnPMICRegWrite = new TButton(this);
  231.             pmic_reg_ui.btnPMICRegWrite->Parent = frmPMICReg;
  232.             pmic_reg_ui.btnPMICRegWrite->Caption = "Write";
  233.             pmic_reg_ui.btnPMICRegWrite->Tag = i;
  234.             pmic_reg_ui.btnPMICRegWrite->Top = i_btnPMICRegWrite_top + i/2 * i_vertical_offset;
  235.             pmic_reg_ui.btnPMICRegWrite->Left = i_btnPMICRegWrite_left;
  236.             pmic_reg_ui.btnPMICRegWrite->Width = 65;
  237.             pmic_reg_ui.btnPMICRegWrite->OnClick = btnPMICRegWriteClick;
  238.         }
  239.         else
  240.         {
  241.             //pmic_reg_ui.lblPMICRegName = new TLabel(this);
  242.             //pmic_reg_ui.lblPMICRegName->Parent = frmPMICReg;
  243.             //pmic_reg_ui.lblPMICRegName->Caption = "Name";
  244.             //pmic_reg_ui.lblPMICRegName->Top = i_lblPMICRegName_top + i/2 * i_vertical_offset;
  245.             //pmic_reg_ui.lblPMICRegName->Left = i_lblPMICRegName_left + i_horizontal_offset;
  246.             //pmic_reg_ui.stPMICRegName = new TStaticText(this);
  247.             //pmic_reg_ui.stPMICRegName->Parent = frmPMICReg;
  248.             //pmic_reg_ui.stPMICRegName->Caption = iter->as_name;
  249.             //pmic_reg_ui.stPMICRegName->Tag = i;
  250.             //pmic_reg_ui.stPMICRegName->Top = i_stPMICRegName_top + i/2 * i_vertical_offset;
  251.             //pmic_reg_ui.stPMICRegNamer->Left = i_stPMICRegName_left + i_horizontal_offset;
  252.             pmic_reg_ui.lblPMICRegAddr = new TLabel(this);
  253.             pmic_reg_ui.lblPMICRegAddr->Parent = frmPMICReg;
  254.             pmic_reg_ui.lblPMICRegAddr->Caption = "Address (Hex)";
  255.             pmic_reg_ui.lblPMICRegAddr->Top = i_lblPMICRegAddr_top + i/2 * i_vertical_offset;
  256.             pmic_reg_ui.lblPMICRegAddr->Left = i_lblPMICRegAddr_left + i_horizontal_offset;
  257.             pmic_reg_ui.stPMICRegAddr = new TStaticText(this);
  258.             pmic_reg_ui.stPMICRegAddr->Parent = frmPMICReg;
  259.             char str[5];
  260.             sprintf(str, "0x%X", iter->us_index);
  261.             pmic_reg_ui.stPMICRegAddr->Caption = (AnsiString) str;
  262.             pmic_reg_ui.stPMICRegAddr->Tag = i;
  263.             pmic_reg_ui.stPMICRegAddr->Top = i_stPMICAddr_top + i/2 * i_vertical_offset;
  264.             pmic_reg_ui.stPMICRegAddr->Left = i_stPMICAddr_left + i_horizontal_offset;
  265.             pmic_reg_ui.lblPMICRegValue0X = new TLabel(this);
  266.             pmic_reg_ui.lblPMICRegValue0X->Parent = frmPMICReg;
  267.             pmic_reg_ui.lblPMICRegValue0X->Caption = "0x";
  268.             pmic_reg_ui.lblPMICRegValue0X->Tag = i;
  269.             pmic_reg_ui.lblPMICRegValue0X->Top = i_lblPMICRegValue0X_top + i/2 * i_vertical_offset;
  270.             pmic_reg_ui.lblPMICRegValue0X->Left = i_lblPMICRegValue0X_left + i_horizontal_offset;
  271.             pmic_reg_ui.lblPMICRegValue = new TLabel(this);
  272.             pmic_reg_ui.lblPMICRegValue->Parent = frmPMICReg;
  273.             pmic_reg_ui.lblPMICRegValue->Caption = "Value(Hex)";
  274.             pmic_reg_ui.lblPMICRegValue->Tag = i;
  275.             pmic_reg_ui.lblPMICRegValue->Top = i_edtPMICValue_top + i/2 * i_vertical_offset;
  276.             pmic_reg_ui.lblPMICRegValue->Left = i_edtPMICValue_left + i_horizontal_offset;
  277.             pmic_reg_ui.edtPMICValue = new TEdit(this);
  278.             pmic_reg_ui.edtPMICValue->Parent = frmPMICReg;
  279.             pmic_reg_ui.edtPMICValue->Text = iter->uc_value;
  280.             pmic_reg_ui.edtPMICValue->Tag = i;
  281.             pmic_reg_ui.edtPMICValue->Top = i_edtPMICValue_top + i/2 * i_vertical_offset;
  282.             pmic_reg_ui.edtPMICValue->Left = i_edtPMICValue_left + i_horizontal_offset;
  283.             pmic_reg_ui.edtPMICValue->Width = 81;
  284.             pmic_reg_ui.btnPMICRegRead = new TButton(this);
  285.             pmic_reg_ui.btnPMICRegRead->Parent = frmPMICReg;
  286.             pmic_reg_ui.btnPMICRegRead->Caption = "Read";
  287.             pmic_reg_ui.btnPMICRegRead->Tag = i;
  288.             pmic_reg_ui.btnPMICRegRead->Top = i_btnPMICRegRead_top + i/2 * i_vertical_offset;
  289.             pmic_reg_ui.btnPMICRegRead->Left = i_btnPMICRegRead_left + i_horizontal_offset;
  290.             pmic_reg_ui.btnPMICRegRead->Width = 65;
  291.             pmic_reg_ui.btnPMICRegRead->OnClick = btnPMICRegReadClick;
  292.             pmic_reg_ui.btnPMICRegWrite = new TButton(this);
  293.             pmic_reg_ui.btnPMICRegWrite->Parent = frmPMICReg;
  294.             pmic_reg_ui.btnPMICRegWrite->Caption = "Write";
  295.             pmic_reg_ui.btnPMICRegWrite->Tag = i;
  296.             pmic_reg_ui.btnPMICRegWrite->Top = i_btnPMICRegWrite_top + i/2 * i_vertical_offset;
  297.             pmic_reg_ui.btnPMICRegWrite->Left = i_btnPMICRegWrite_left + i_horizontal_offset;
  298.             pmic_reg_ui.btnPMICRegWrite->Width = 65;
  299.             pmic_reg_ui.btnPMICRegWrite->OnClick = btnPMICRegWriteClick;
  300.         }
  301.         m_pvPmicRegUI->push_back(pmic_reg_ui);
  302.         i++;
  303.     }
  304. }
  305. //---------------------------------------------------------------------------
  306. bool  TfrmPMICReg::CheckFields(int tag)
  307. {
  308.     AnsiString  text;
  309.     unsigned int idata;
  310.     unsigned short sdata;
  311.     vector<S_PMIC_REG_UI_T>:: iterator iter;
  312.     for (iter = m_pvPmicRegUI->begin(); iter != m_pvPmicRegUI->end(); iter++)
  313.     {
  314.         if (iter->stPMICRegAddr->Tag == tag)
  315.         {
  316.             break;
  317.         }
  318.     }
  319.     text = iter->stPMICRegAddr->Caption;
  320.     text = text.SubString(3, text.Length()-2);
  321.     if ( ! IsValidHexRegAddr(text, idata))
  322.     {
  323.         return false;
  324.     }
  325.     m_uiPMICRegAddr = idata;
  326.     text = iter->edtPMICValue->Text;
  327.    // if (DEC_FORMAT == iter->edtPMICValue->Tag)  // Dec
  328.    // {
  329.    //     if (!IsValidDecRegValue(text, sdata))
  330.    //     {
  331.    //         edtPMICValueCheck(iter->edtPMICValue);
  332.    //         return false;
  333.    //     }
  334.    // }
  335.    // else  // Hex
  336.     {
  337.         if (!IsValidHexRegValue(text, sdata))
  338.         {
  339.             edtPMICValueCheck(iter->edtPMICValue);
  340.             return false;
  341.         }
  342.     }
  343.     m_usPMICRegValue = sdata;
  344.     return true;
  345. }
  346. //---------------------------------------------------------------------------
  347. void  TfrmPMICReg::ReDrawFields(int tag)
  348. {
  349.     char str[256];
  350.     vector<S_PMIC_REG_UI_T>:: iterator iter;
  351.     for (iter = m_pvPmicRegUI->begin(); iter != m_pvPmicRegUI->end(); iter++)
  352.     {
  353.         if ((int)iter->lblPMICRegValue->Tag == tag)
  354.         {
  355.             break;
  356.         }
  357.     }
  358.    // if (DEC_FORMAT == btnPMICRegValue->Tag)  // Dec
  359.    // {
  360.    //     iter->lblPMICRegValue->Caption = "Value (Dec)";
  361.    //     iter->lblPMICRegValue0X->Visible = false;
  362.    //     iter->edtPMICValue->Text = IntToStr(m_usPMICRegValue);
  363.    // }
  364.    // else  // Hex
  365.     {
  366.         iter->lblPMICRegValue->Caption = "Value (Hex)";
  367.         iter->lblPMICRegValue0X->Visible = true;
  368.         sprintf( str, "%X", (int)m_usPMICRegValue );
  369.         iter->edtPMICValue->Text = str;
  370.     }
  371. }
  372. //---------------------------------------------------------------------------
  373. void __fastcall TfrmPMICReg::edtPMICValueCheck(TObject *Sender)
  374. {
  375.     AnsiString  text;
  376.     unsigned short  data;
  377.     int  band;
  378.     TEdit *edit = (TEdit*)Sender;
  379.     char  hint[] = " character is not valid ";
  380.     text = edit->Text;
  381.     if (! IsValidHexRegValue(text, data))
  382.     {
  383.         ShowHintLabel(edit, hint);
  384.         edit->SetFocus();
  385.         return;
  386.     }
  387.     m_usPMICRegValue = data;
  388. }
  389. //---------------------------------------------------------------------------
  390. void __fastcall TfrmPMICReg::btnPMICRegReadClick(TObject *Sender)
  391. {
  392.     TButton* btn = (TButton*) Sender;
  393.     m_iTag = btn->Tag;
  394.     if ( ! CheckFields(btn->Tag))
  395.     {
  396.         sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Read PMIC register fail";
  397.         return;
  398.     }
  399.     m_cBB_PMIC_REG_Obj.ConfirmCallback = ::CNF_PMIC_ReadRegister;
  400.     m_cBB_PMIC_REG_Obj.REQ_ReadRegister_Start( m_uiPMICRegAddr );
  401.     sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Read PMIC register progressing";
  402. }
  403. //-----------------------------------------------
  404. void  TfrmPMICReg::PMIC_ReadRegister_Done(void)
  405. {
  406.     E_METAAPP_RESULT_T state = m_cBB_PMIC_REG_Obj.Get_ConfirmState();
  407.     switch (state)
  408.     {
  409.         case METAAPP_SUCCESS:
  410.         {
  411.             m_usPMICRegValue = m_cBB_PMIC_REG_Obj.Get_RegValue();
  412.             ReDrawFields(m_iTag);
  413.             sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Read PMIC register successfully";
  414.         }
  415.         break;
  416.         case METAAPP_FAIL:
  417.         {
  418.             sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Read PMIC register fail";
  419.             Application->MessageBox( "Execution Failure : Read PMIC register", "FAILURE", MB_OK );
  420.         }
  421.         break;
  422.         case METAAPP_TIMEOUT:
  423.         {
  424.             sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Read PMIC register timeout";
  425.             Application->MessageBox( "Execution Timeout : Read PMIC register", "TIMEOUT", MB_OK );
  426.         }
  427.         break;
  428.         case METAAPP_STOP:
  429.         {
  430.             sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Read PMIC register stop";
  431.         }
  432.         break;
  433.         default:
  434.         break;
  435.     }
  436. }
  437. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  438. void __fastcall TfrmPMICReg::btnPMICRegWriteClick(TObject *Sender)
  439. {
  440.     TButton* btn = (TButton*) Sender;
  441.     m_iTag = btn->Tag;
  442.     if (!CheckFields(btn->Tag))
  443.     {
  444.         sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Write PMIC register fail";
  445.         Application->MessageBox( "Execution Failure : Write PMIC register", "FAILURE", MB_OK );
  446.         return;
  447.     }
  448.     m_cBB_PMIC_REG_Obj.ConfirmCallback = ::CNF_PMIC_WriteRegister;
  449.     m_cBB_PMIC_REG_Obj.REQ_WriteRegister_Start( m_uiPMICRegAddr, m_usPMICRegValue );
  450.     sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Write PMIC register progressing";
  451. }
  452. //-----------------------------------------------
  453. void TfrmPMICReg::PMIC_WriteRegister_Done(void)
  454. {
  455.     E_METAAPP_RESULT_T state = m_cBB_PMIC_REG_Obj.Get_ConfirmState();
  456.     switch (state)
  457.     {
  458.         case METAAPP_SUCCESS:
  459.         {
  460.             sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Write baseband register successfully";
  461.         }
  462.         break;
  463.         case METAAPP_FAIL:
  464.         {
  465.             sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Write baseband register fail";
  466.             Application->MessageBox( "Execution Failure : Write Baseband register", "FAILURE", MB_OK );
  467.         }
  468.         break;
  469.         case METAAPP_TIMEOUT:
  470.         {
  471.             sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Write baseband register timeout";
  472.             Application->MessageBox( "Execution Timeout : Write Baseband register", "TIMEOUT", MB_OK );
  473.         }
  474.         break;
  475.         case METAAPP_STOP:
  476.         {
  477.             sbPMICReg->Panels->Items[0]->Text = (AnsiString) "  Write baseband register stop";
  478.         }
  479.         break;
  480.         default:
  481.         break;
  482.     }
  483. }
  484. void __fastcall TfrmPMICReg::HintTimerTimer(TObject *Sender)
  485. {
  486.     HintTimer->Enabled = false;
  487.     lblHint->Visible = false;
  488. }
  489. //---------------------------------------------------------------------------
  490. void  TfrmPMICReg::ShowHintLabel(TControl *sender, char* hint)
  491. {
  492.    TPoint pt0 = this->ClientOrigin;
  493.    TPoint pt1 = sender->ClientOrigin;
  494.    lblHint->Left = (pt1.x-pt0.x);
  495.    lblHint->Top  = (pt1.y-pt0.y)+sender->Height+3;
  496.    lblHint->Caption = hint;
  497.    lblHint->Visible = true;
  498.    HintTimer->Enabled = true;
  499. }