void DclPW_charger_usb_det_eint_PMU_BC11(void)
{

#if defined(__USB_ENABLE__)
       if (INT_IsBootForUSBAT()==KAL_TRUE)
       {
		pw_chr_type = PW_USB_CHR;  
		CHR_USB_Det_EINT_Return(PW_USB_CHR);
		return;
       }
#endif //#if defined(__USB_ENABLE__)

	if (pmu_bc11_usb_charger_detect_handle == 0x7F)
	{
		pmu_bc11_usb_charger_detect_handle=DclSGPT_Open(DCL_GPT_CB,0);
	}


	{   	  
		SGPT_CTRL_START_T start;	  
		start.u2Tick=1;	  
		start.pfCallback=pmu_bc11_check_charger_or_usb_step1;	  
		start.vPara=NULL;	  
		DclSGPT_Control(pmu_bc11_usb_charger_detect_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);		
	}

}
Exemplo n.º 2
0
/*************************************************************************
* FUNCTION
*  EINT_TIMER_CALLBACK
*
* DESCRIPTION
*   This function implements main external interrupt LISR registered in
*  global ISR jump table.
*
* CALLS
*
* PARAMETERS
*
* RETURNS
*  No return
*
* GLOBALS AFFECTED
*
*************************************************************************/
void DEINT_TIMER_CALLBACK(void *data)
{
   EINT_SW_DEBOUNCE_STRUCT *sw_debounce = (EINT_SW_DEBOUNCE_STRUCT *)data;

   EINT_Mask(sw_debounce->eint_no);

   if(sw_debounce->eint_sw_debounce_handle != 0x7f)
   {
      DclSGPT_Control(sw_debounce->eint_sw_debounce_handle,SGPT_CMD_STOP,0);
      DclSGPT_Close(&(sw_debounce->eint_sw_debounce_handle));
   }

   sw_debounce->eint_intr_allow = (sw_debounce->eint_intr_allow == KAL_TRUE)? KAL_FALSE: KAL_TRUE;

   /*
    * This timer is to avoid if interrupt status is changed but 
    * sw_debounce->eint_intr_allow is still in KAL_TRUE state
    * because of no interrupt
    */
   if (sw_debounce->eint_intr_allow) 
   {
      SGPT_CTRL_START_T start;

      start.u2Tick= eint_sw_debounce_time_delay[sw_debounce->eint_no];

      start.pfCallback=DEINT_TIMER_CALLBACK;
      start.vPara=data;
      sw_debounce->eint_sw_debounce_handle=DclSGPT_Open(DCL_GPT_CB,0);
      DclSGPT_Control(sw_debounce->eint_sw_debounce_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
   }
   EINT_UnMask(sw_debounce->eint_no);
}
void DclPW_charger_usb_det_eint_USB(void)
{
#if defined(__USB_ENABLE__)

       if (INT_IsBootForUSBAT()==KAL_TRUE)
       {
		pw_chr_type = PW_USB_CHR;  
		CHR_USB_Det_EINT_Return(PW_USB_CHR);
		return;
       }

	if (usb_charger_detect_handle == 0x7F)
	{
		usb_charger_detect_handle=DclSGPT_Open(DCL_GPT_CB,0);
	}

	// Init setting for detecting
	USB_Charger_Detect_Init();

	// After init setting, we need debounce time
	// Perform USB/Charger detection after 10ms
	{
   	  SGPT_CTRL_START_T start;
	  start.u2Tick=1;
	  start.pfCallback=USB_IP_V3_check_charger_or_usb;
	  start.vPara=USB_IP_V3_DETECT_ITEM_USB_CHARGER;
	  DclSGPT_Control(usb_charger_detect_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);	
	}
	
#else
	ASSERT(0); // Assert here, need to check whether the configuration is correct or NOT
#endif // #if defined(__USB_ENABLE__)
}
Exemplo n.º 4
0
/*
* FUNCTION
*      bmt_charge_enable_wdt
*
* DESCRIPTION
*      Enable/disable charging wdt functionality for safety
*
* PARAMETERS
*      KAL_TRUE: Enable charging WDT
*      KAL_TRUE: Disable charging WDT
*
*/
void bmt_charge_enable_wdt(kal_bool enable)
{
	// Don't need IRQMask protection, 
	// bmt_charge_start(), bmt_charge_end() are called in task level
	DCL_STATUS status;
	SGPT_CTRL_START_T start;

	if (enable)
	{
		if (bmt_wdt_handle == 0xFF)
		{
			bmt_wdt_handle = DclSGPT_Open(DCL_GPT_CB,0);

	        start.u2Tick = BMT_CHARGE_CLEAR_WDT_PERIOD;
	        start.pfCallback = bmt_charge_clear_wdt;
	        start.vPara = NULL;
			//this is for handle type transfer between new and old API.
			status = DclSGPT_Control(bmt_wdt_handle, SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
            
            if(status != STATUS_OK)
            {
            	ASSERT(0);  		
            }  	             
		}
	}
	else
	{
		if (bmt_wdt_handle != 0xFF)
		{
		 	DclSGPT_Control(bmt_wdt_handle, SGPT_CMD_STOP, 0);
			DclSGPT_Close(&bmt_wdt_handle);
		}
		bmt_wdt_handle = 0xFF;
	}
}
Exemplo n.º 5
0
void DEINT_Process(kal_uint8 deintno)
{
	kal_uint8 eintno;

	eintno = gpio_get_l1_eint_src(deintno);

	if ( EINT_CheckHWDebounce(eintno) )
	{
	  if(eint_sw_debounce[eintno].eint_sw_debounce_handle != 0x7f)
	  {
	     DclSGPT_Control(eint_sw_debounce[eintno].eint_sw_debounce_handle,SGPT_CMD_STOP,0);
	     DclSGPT_Close(&(eint_sw_debounce[eintno].eint_sw_debounce_handle));
	  }
	  if ( (eint_sw_debounce[eintno].eint_intr_allow == KAL_FALSE) && 
	       (eint_sw_debounce_time_delay[eintno] > 0) 
	     )
	  {
	     SGPT_CTRL_START_T start;
		 //EINT_PRINT("\tDEINT start timer, eint_sw_debounce_time_delay[index] = %d",eint_sw_debounce_time_delay[deintno]);
	     eint_sw_debounce[eintno].eint_sw_debounce_handle=DclSGPT_Open(DCL_GPT_CB,0);

	     start.u2Tick=eint_sw_debounce_time_delay[eintno];
	     start.pfCallback=DEINT_TIMER_CALLBACK;
	     start.vPara=&eint_sw_debounce[eintno];
	     DclSGPT_Control(eint_sw_debounce[eintno].eint_sw_debounce_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);

	     EINT_Mask(eintno);
	  }
	  else
	  {
	     eint_sw_debounce[eintno].eint_intr_allow = KAL_FALSE;
	     // disable interrupt
	     //EINT_PRINT("\tDEINT trigger HISR");
	     EINT_Mask(eintno);
	     ASSERT(EINT_FUNC.eint_func[eintno]!=NULL);
	     if ( EINT_FUNC.eint_func[eintno] )
	     {
	        EINT_FUNC.eint_active[eintno] = KAL_TRUE;

	        drv_active_hisr(DRV_DEINT_HISR_ID);
	     }
	  }
	}
	else
	{
	    EINT_Mask(eintno);
	    ASSERT(EINT_FUNC.eint_func[eintno]!=NULL);
	    if ( EINT_FUNC.eint_func[eintno] )
	    { 
	       EINT_FUNC.eint_active[eintno] = KAL_TRUE;

	       drv_active_hisr(DRV_DEINT_HISR_ID);
	    }
	}
}
Exemplo n.º 6
0
static void mmi_em_misc_rf_desense_mode_no_lcm_update(void) {
#if 1 // delay 30s stop lcm
    rf_desense_em_gpt_handle = DclSGPT_Open(DCL_GPT_CB, 0);    
    
    rf_desense_em_gpt_start.u2Tick = 3000; //30s
    rf_desense_em_gpt_start.pfCallback = mmi_em_misc_rf_desense_mode_no_lcm_update_cb;
    rf_desense_em_gpt_start.vPara = NULL;
    DclSGPT_Control(rf_desense_em_gpt_handle, SGPT_CMD_START, (DCL_CTRL_DATA_T*)&rf_desense_em_gpt_start);     
#else      
/* under construction !*/
#endif
}
Exemplo n.º 7
0
static void _IspVsyncTimeOutReportStart(ISP_VSYNC_TIME_OUT_UNIT TimeUnit)
{
    SGPT_CTRL_START_T start;
    
    if (IspVsyncGptHandle == NULL)
    {
        //GPTI_GetHandle(&IspVsyncGptHandle);
        IspVsyncGptHandle = DclSGPT_Open(DCL_GPT_CB,0);
        if (IspVsyncGptHandle!=NULL)
        {
            //GPTI_StartItem(IspVsyncGptHandle, TimeUnit,   
            //_IspVsyncTimeOutReportHandler, NULL);
            start.u2Tick=TimeUnit;
            start.pfCallback=_IspVsyncTimeOutReportHandler;
            start.vPara=NULL;
            DclSGPT_Control(IspVsyncGptHandle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start); 				
        }
    }
    IspVsyncGptTimeOut = KAL_FALSE; 
}
/*************************************************************************
* FUNCTION
*  DclBMT_Control
*
* DESCRIPTION
*  This function is to send command to control the BMT module.
*
* PARAMETERS
*  handle: The handle value returned from DclBMT_Open
*  cmd: A control command for BMT module
*           1. BMT_CMD_CALLSTATE: to nodify talk/idle state to BMT task
*           2. BMT_CMD_SET_EXT_CHARGER: to control the external charger
*           3. BMT_CMD_IS_BAT_ON: to check is battery exist or not
*       	4. BMT_CMD_SENDMES2UEM: to send message from BMT to UEM
*           5. BMT_CMD_SET_CHR_STATUS: to set charger status
*           6. BMT_CMD_VBATINHISR: to save the Battery voltage in HISR
*
*  data: The data of the control command
*           1. BMT_CMD_CALLSTATE: pointer to a BMT_CTRL_CALLSTATE_T structure
*           2. BMT_CMD_SET_EXT_CHARGER: pointer to a BMT_CTRL_SET_EXT_CHARGER_T structure
*           3. BMT_CMD_IS_BAT_ON: pointer to a BMT_CTRL_IS_BAT_ON_T structure
*           4. BMT_CMD_SENDMES2UEM: pointer to a BMT_CTRL_SENDMES2UEM_T structure
*           5. BMT_CMD_SET_CHR_STATUS: pointer to a BMT_CTRL_SET_CHR_STATUS_T structure
*           6. BMT_CMD_VBATINHISR: A null pointer   
*
* RETURNS
*  STATUS_OK: command is executed successfully.
*  STATUS_FAIL: command is failed.
*  STATUS_INVALID_CMD: It's a invalid command.
*
*************************************************************************/
DCL_STATUS DclBMT_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data)
{
    DCL_STATUS return_status = STATUS_INVALID_CMD;

	// Check magic number
	if ((handle & DCL_BMT_DEV_MAGIC_NUM) != DCL_BMT_DEV_MAGIC_NUM){
		ASSERT(0);
		return STATUS_INVALID_DCL_HANDLE;
	}

	// Error check
	if (dcl_bmt_handle_count == 0){
		ASSERT(0);
		return STATUS_NOT_OPENED;
	}

	switch (cmd)
	{
#ifdef __BACKUP_DOWNLOAD_RESTORE_WITHOUT_BATTERY__
	case BMT_CMD_WDT_INIT:
	{

		if (bmt_without_battery_handle == 0x7F)
		{
			bmt_without_battery_handle=DclSGPT_Open(DCL_GPT_CB,0);
		}


		{   	  
			SGPT_CTRL_START_T start;	  
			start.u2Tick=1000;	  // 10 secs
			start.pfCallback=bmt_without_battery_callback;	  
			start.vPara=NULL;	  
			DclSGPT_Control(bmt_without_battery_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);		
		}


		

	}
	break;
#endif //#ifdef __BACKUP_DOWNLOAD_RESTORE_WITHOUT_BATTERY__	
	
        case BMT_CMD_CALLSTATE:
        {
			BMT_CTRL_CALLSTATE_T *prCallState;
			prCallState = &(data->rCallState);
			BMT_CallState(prCallState->call_state);            
            return_status = STATUS_OK;
        }
        break;
        
        case BMT_CMD_CHARGE:
        {
			BMT_CTRL_CHARGE_T *prChargeControl;
			prChargeControl = &(data->rChargeControl);

			if(INT_GetSysStaByCmd(CHK_USB_META_WO_BAT, NULL)==KAL_TRUE && prChargeControl->bEnable==DCL_TRUE)
			{
				return_status = STATUS_OK;
				break;
			}
			
			BMT_Charge((kal_bool)prChargeControl->bEnable);            
            return_status = STATUS_OK;
        }
        break;
        
        case BMT_CMD_GET_CUSTOMIZED_PARA:
        {
            BMT_CTRL_GET_CUSTOMIZED_PARA_T *prGetCustomizedPara;
            prGetCustomizedPara = &(data->rGetCustomizedPara);
            return_status = bmt_get_customized_para(prGetCustomizedPara);            
        }
        break;

        case BMT_CMD_SET_EXT_CHARGER:
        {
            return_status = STATUS_UNSUPPORTED;
        }
        break;
                
		case BMT_CMD_INITIALIZE:
		{
			bmt_initialize();
			return_status = STATUS_OK;
		}
		break;        
                
        case BMT_CMD_IS_BAT_ON:
        {
			BMT_CTRL_IS_BAT_ON_T *prIsBatOn;
			prIsBatOn = &(data->rIsBatOn);
			prIsBatOn->fgBatIsOn = (DCL_BOOLEAN)bmt_is_bat_on();
            return_status = STATUS_OK;
        }        
        break;
        
		case BMT_CMD_SENDMES2UEM:
		{
			BMT_CTRL_SENDMES2UEM_T  *prSendMes2Uem;
			prSendMes2Uem = &(data->rSendMes2Uem);
			BMT_sendMes2UEM((BMT_CHR_STAT)prSendMes2Uem->ChargerMsg);
			return_status = STATUS_OK;
		}
		break;
		
		case BMT_CMD_SET_CHR_STATUS:
		{
			BMT_CTRL_SET_CHR_STATUS_T  *prSetChrStatus;
			prSetChrStatus = &(data->rSetChrStatus);
			bmt_set_chr_status((Charger_Status)prSetChrStatus->ChargerStat);
			
			return_status = STATUS_OK;
		}
		break;  
		      
		case BMT_CMD_VBATINHISR:
		{
#if defined( __DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
			BMT_VbatInHISR();
			return_status = STATUS_OK;
#else
			return_status = STATUS_UNSUPPORTED;
#endif
		}
		break;
		default:
			return_status = STATUS_INVALID_CMD;
		break;
	}
    return return_status;
//	return STATUS_FAIL;
}
Exemplo n.º 9
0
/*************************************************************************
* FUNCTION
*   EINT_LISR
*
* DESCRIPTION
*   Entry function of External Interrupt Service Routine
*
* CALLS
*
* PARAMETERS
*
* RETURNS
*  No return
*
* GLOBALS AFFECTE
*
*************************************************************************/
void EINT_LISR(void)
{
   kal_uint8 index;
   kal_uint32 status,mask_bits;

   status = EINT_L2_STA();
   
   if (EINT_Internal_LISR_Handler(&status))
   {
      return;
   }

   // for conventional external interrupt!
   for(index=0;index<EINT_TOTAL_CHANNEL;index++)
   {
   	  //EINT_PRINT("\tEINT triggered!");
      if ( EINT_CheckHWDebounce(index) )
      {
      	 mask_bits = EINT_Get_Mask_Bits();
         if (status & EINT_STATUS_EINT(index) && !BU_G_BIT(mask_bits, index)) 
         {
            if(eint_sw_debounce[index].eint_sw_debounce_handle != 0x7f)
            {
               DclSGPT_Control(eint_sw_debounce[index].eint_sw_debounce_handle,SGPT_CMD_STOP,0);
               DclSGPT_Close(&(eint_sw_debounce[index].eint_sw_debounce_handle));
            }
            if ( (eint_sw_debounce[index].eint_intr_allow == KAL_FALSE) && 
                 (eint_sw_debounce_time_delay[index] > 0) 
               )
            {
               SGPT_CTRL_START_T start;
			   //EINT_PRINT("\tstart timer, eint_sw_debounce_time_delay[%d] = %d",index,eint_sw_debounce_time_delay[index]);
               eint_sw_debounce[index].eint_sw_debounce_handle=DclSGPT_Open(DCL_GPT_CB,0);

               start.u2Tick=eint_sw_debounce_time_delay[index];
               start.pfCallback=EINT_TIMER_CALLBACK;
               start.vPara=&eint_sw_debounce[index];
               DclSGPT_Control(eint_sw_debounce[index].eint_sw_debounce_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);

               EINT_Mask(index);
            }
            else
            {
               eint_sw_debounce[index].eint_intr_allow = KAL_FALSE;
               // disable interrupt
               EINT_Mask(index);
                //EINT_PRINT("\tEINT trigger HISR");
               ASSERT(EINT_FUNC.eint_func[index]!=NULL);
               if ( EINT_FUNC.eint_func[index] )
               {
                  EINT_FUNC.eint_active[index] = KAL_TRUE;

                  drv_active_hisr(DRV_EINT_HISR_ID);
               }
            }
            EINT_L2_ACK(index);
         }
      }
      else
      {
	     mask_bits = EINT_Get_Mask_Bits();
         if (status & EINT_STATUS_EINT(index)  && !BU_G_BIT(mask_bits, index)) 
         {
            EINT_Mask(index);
            ASSERT(EINT_FUNC.eint_func[index]!=NULL);
            if ( EINT_FUNC.eint_func[index] )
            { 
               EINT_FUNC.eint_active[index] = KAL_TRUE;

               drv_active_hisr(DRV_EINT_HISR_ID);
            }
            EINT_L2_ACK(index);
         }
      }
   }
}