DCL_STATUS DclBMT_Initialize(void){

#if defined(DRV_BMT_HIGH_VCHG_ADAPTIVE_CHARGE_CURRENT_SUPPORT)
    bmt_high_vchg_para=bmt_get_customized_high_vchg_para();
#endif

	#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
	BMT_VbatInHISR_Init();
	#endif //#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)

#ifdef __BACKUP_DOWNLOAD_RESTORE_WITHOUT_BATTERY__
	if (INT_GetSysStaByCmd(CHK_USB_META_WO_BAT, NULL)==KAL_TRUE)
	{

		DCL_HANDLE handle;
		handle = DclBMT_Open(DCL_BMT, FLAGS_NONE);
		DclBMT_Control(handle, BMT_CMD_WDT_INIT, NULL);
		DclBMT_Close(handle);

	}
#endif //#ifdef __BACKUP_DOWNLOAD_RESTORE_WITHOUT_BATTERY__


	return STATUS_OK;
}
Esempio n. 2
0
/*if add more measure parameters, just need modify bmt_adc_init*/
void bmt_adc_init(void)
{
   ADC_CTRL_GET_PHYSICAL_CHANNEL_T adc_ch;
   ADC_CTRL_CREATE_OBJECT_T adc_create;   
   DCL_STATUS adc_status;
   ADC_CTRL_REGISTER_MEASURE_CB_T registerMeasCB;
   DCL_MULTI_CHANNEL_PARA_T adc_multi_channel_para;
	
   #ifdef MTK_SLEEP_ENABLE
   bmt_sm_handle = L1SM_GetHandle();
   #endif
   bmt_stop_timer_init();
#ifdef __BMT_CHARGE_GUARD_TIME__
   bmt_guardtimer_init();
#endif
#if defined(__DRV_BMT_ESTIMATIVE_TIMER_ON_TOPOFF__)
		bmt_estimativetimer_init();
#endif //#if defined(__DRV_BMT_ESTIMATIVE_TIMER_ON_TOPOFF__)

   BMT.VBAT_UEM = VBAT_UEM_CHR_OUT;
   /*to get customized ADC channel*/

  
   bmt_adc_handle = DclSADC_Open(DCL_ADC, FLAGS_NONE);
   if(bmt_adc_handle == DCL_HANDLE_INVALID)
   {
      ASSERT(0);   
   }

   adc_ch.u2AdcName = DCL_VBAT_ADC_CHANNEL;
   DclSADC_Control(bmt_adc_handle, ADC_CMD_GET_CHANNEL, (DCL_CTRL_DATA_T *)&adc_ch);       
   bmt_multi_channel[BMT_ADC_VBAT] = adc_ch.u1AdcPhyCh;


   adc_ch.u2AdcName = DCL_VISENSE_ADC_CHANNEL;
   DclSADC_Control(bmt_adc_handle, ADC_CMD_GET_CHANNEL, (DCL_CTRL_DATA_T *)&adc_ch);    
   bmt_multi_channel[BMT_ADC_VISENSE] = adc_ch.u1AdcPhyCh;	


   adc_ch.u2AdcName = DCL_VBATTMP_ADC_CHANNEL;
   DclSADC_Control(bmt_adc_handle, ADC_CMD_GET_CHANNEL, (DCL_CTRL_DATA_T *)&adc_ch);      
   bmt_multi_channel[BMT_ADC_VBATTMP] = adc_ch.u1AdcPhyCh;	   


   adc_ch.u2AdcName = DCL_VCHARGER_ADC_CHANNEL;
   DclSADC_Control(bmt_adc_handle, ADC_CMD_GET_CHANNEL, (DCL_CTRL_DATA_T *)&adc_ch);      
   bmt_multi_channel[BMT_ADC_VCHARGER] = adc_ch.u1AdcPhyCh;	

   adc_create.u4Period = 10; // Measurement period (Uint is in Tick)
   adc_create.u1OwnerId = MOD_BMT; // Indicate the module to for ADC driver to notify the result
   //adc_create.u1AdcChannel = ADC_VBAT_channel; // To be measured physical ADC channel
   adc_create.u1EvaluateCount = BMT_EVALUATE_VALUE; // Measurement count
   adc_create.fgSendPrimitive = KAL_FALSE; // Whether to send message to owner module or NOT
   adc_status = DclSADC_Control(bmt_adc_handle, ADC_CMD_CREATE_OBJECT, (DCL_CTRL_DATA_T *)&adc_create);
   if(adc_status != STATUS_OK)
   {
		ASSERT(0);   
   }
 
   registerMeasCB.pfMeasure_cb = adc_sche_measure;	
   adc_status = DclSADC_Control(bmt_adc_handle, ADC_CMD_REGISTER_MEASURE_CB, (DCL_CTRL_DATA_T *)&registerMeasCB);	
   if(adc_status != STATUS_OK)
   {
	   ASSERT(0);
   }	   

   adc_multi_channel_para.bEnable = KAL_TRUE;
   adc_multi_channel_para.u4ADC_ch_number = bmt_multi_channel;
   adc_multi_channel_para.u4Adc_max_ch_number = BMT_ADC_MAX_CHANNEL_TOTAL;
   adc_multi_channel_para.complete_multi_cb = bmt_measure_complete;
   adc_status = DclSADC_Control(bmt_adc_handle, ADC_CMD_SET_MULTI_CHANNEL_READ, (DCL_CTRL_DATA_T *)&adc_multi_channel_para);
   if(adc_status != STATUS_OK)
   {
	  ASSERT(0);  		
   }

   
   #if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
	   BMT_VbatInHISR_Init();
   #endif //#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
}