void pmu_bc11_check_charger_or_usb_step4(void *parameter) { if (BC11_Status == BC11_STEP_A_RESULT_GROUP_B) { // Step B pw_chr_type = pmu_bc11_get_stepB_result(); } else if (BC11_Status == BC11_STEP_A_RESULT_GROUP_C) { // Step C pw_chr_type = pmu_bc11_get_stepC_result(); } else { ASSERT(0); } pmu_bc11_detect_deinit(); // Stop GPT DclSGPT_Control(pmu_bc11_usb_charger_detect_handle,SGPT_CMD_STOP,0); DclSGPT_Close(&pmu_bc11_usb_charger_detect_handle); // handle race condition by this function . CHR_USB_Det_EINT_Return(pw_chr_type); }
/************************************************************************* * 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); }
/* * 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; } }
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); } } }
static void _IspVsyncTimeOutReportRelease(void) { if(IspVsyncGptHandle != NULL) { //GPTI_StopItem(IspVsyncGptHandle); DclSGPT_Control(IspVsyncGptHandle,SGPT_CMD_STOP,0); //GPTI_ReleaseHandle(&IspVsyncGptHandle); DclSGPT_Close(&IspVsyncGptHandle); IspVsyncGptHandle = NULL; } IspVsyncGptTimeOut = KAL_TRUE; }
static void USB_IP_V3_check_charger_or_usb(void *parameter) { CHR_DET_TYPE_ENUM state = PW_NO_CHR; if (parameter == USB_IP_V3_DETECT_ITEM_USB_CHARGER) { // Detect USB/Charger if (USB_Detect_Is_Charger_In()) { // Standard/Non-standard charger detection init setting USB_Check_Standard_Charger(); // After init setting, we need debounce time // Perform Standard/Non-standard charger detection after 10ms { SGPT_CTRL_START_T start; start.u2Tick=1; start.pfCallback=USB_IP_V3_check_charger_or_usb; start.vPara=(void *)USB_IP_V3_DETECT_ITEM_CHARGER; DclSGPT_Control(usb_charger_detect_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start); } return; } else { // USB state = PW_USB_CHR; // Finish detection USB_Charger_Detect_Release(); // Stop GPT DclSGPT_Control(usb_charger_detect_handle,SGPT_CMD_STOP,0); DclSGPT_Close(&usb_charger_detect_handle); } } else //if ((kal_uint32)parameter == USB_IP_V3_DETECT_ITEM_CHARGER) { // Detect standard/non-standard charger if (USB_Detect_Is_Standard_Charger_In()) { // Standard charger state = PW_AC_CHR; } else { // Non-standard charger state = PW_AC_NON_STD_CHR; } // Finish detection USB_Charger_Detect_Release(); // Stop GPT DclSGPT_Control(usb_charger_detect_handle,SGPT_CMD_STOP,0); DclSGPT_Close(&usb_charger_detect_handle); } pw_chr_type = state; CHR_USB_Det_EINT_Return(state); }
/************************************************************************* * 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); } } } }