PRAGMA_END_COMPILER_OPTIMIZE_TIME 
#endif
#endif

#if !defined(AST_HIF_HW_REG_EINT_BY_PROJECT)
AST_HIF_HW_RESULT ast_hif_hw_reg_eint(AST_HIF_HW_EINT_T* pEintParam)
{
    DCL_HANDLE gpio_handle;
    // register interrupt

    EINT_Set_Sensitivity(AST_EINT_NO, LEVEL_SENSITIVE);
    EINT_Set_Polarity(AST_EINT_NO, KAL_FALSE);
    EINT_Registration(AST_EINT_NO, KAL_FALSE, KAL_FALSE, pEintParam->fINTCB/*ast_hif_hw_eint_isr*/, KAL_TRUE);

    EINT_Set_Sensitivity(AST_WAKEUP_EINT_NO, EDGE_SENSITIVE);
    EINT_Set_Polarity(AST_WAKEUP_EINT_NO, KAL_TRUE);
    EINT_Registration(AST_WAKEUP_EINT_NO, KAL_FALSE, KAL_TRUE, pEintParam->fWakeUpCB, KAL_TRUE);

    EINT_Set_Sensitivity(AST_RFCONF_EINT_NO, LEVEL_SENSITIVE);
    EINT_Set_Polarity(AST_RFCONF_EINT_NO, KAL_TRUE);
	/* clear original debounce value */
	EINTaddr(AST_RFCONF_EINT_NO) &= ~EINT_CON_DEBOUNCE;
	/* set new debounce value */
	EINTaddr(AST_RFCONF_EINT_NO) |= (1 | EINT_CON_DEBOUNCE_EN);
    EINT_Registration(AST_RFCONF_EINT_NO, KAL_TRUE, KAL_TRUE, pEintParam->fRFConfCB, KAL_TRUE);
    return AST_HIF_HW_RESULT_OK;
}
void chrdet_level_config(kal_uint8 state)
{
	#if defined(__DRV_EXT_CHARGER_DETECTION__)
	return ;  // For external charger detection mechanism, we leave the setting in det driver
	#endif // #if defined(__DRV_EXT_CHARGER_DETECTION__)

	if (state != DETECTCHRIN)
	{
		/*lint -e64*/
#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)		
		EINT_Set_Polarity(gCHRDET_EINT_NO,LEVEL_LOW);
#else
		EINT_Set_Polarity(gCHRDET_EINT_NO,LEVEL_HIGH);
#endif //#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)	
		/*lint +e64*/
	}
	else
	{
		/*lint -e64*/
#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)		
		EINT_Set_Polarity(gCHRDET_EINT_NO,LEVEL_HIGH);
#else
		EINT_Set_Polarity(gCHRDET_EINT_NO,LEVEL_LOW);
#endif //#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)	
		/*lint +e64*/
	}
	#if defined(PMIC_6326_REG_API)
	ASSERT(0);	// For MT6326, we should ASSERT
	#endif // #if defined(PMIC_6326_REG_API)
}
static void GPSLocateVibSensorHISR(void)
{
	//disable this interrupt
	/*
	* Hongji fix me:
	*	This external interrupt has already been disabled by EINT_LISR before activating this 
	*	HISR. So don't disable it one more time.
	*/
	//EINT_Mask(GPS_VIBSENSOR_EINT_NO);
	if (gGPSVibSensorStart != KAL_TRUE)
	{
		//change the sensitive polarity
		gbCurrentPolarity = !gbCurrentPolarity;
		EINT_Set_Polarity(GPS_VIBSENSOR_EINT_NO, gbCurrentPolarity);

		return;
	}

	if (!GPS_APP_CheckGPSModuleOn())
	{
		GPSLocateVibSensorStatusIndStruct_t *pStatusInd;

		//post vibration message
		pStatusInd = (GPSLocateVibSensorStatusIndStruct_t*)construct_local_para(sizeof(GPSLocateVibSensorStatusIndStruct_t), TD_UL);
		pStatusInd->Status = GPSLOCATE_VIBSENSORSTATUS_VIBRATING;
		SendMsg2GPSApp(
			stack_int_get_active_module_id(),
			MSG_ID_GPSLOCATE_VIBSENSORSTATUS_IND,
			(void*)pStatusInd
			);
	}

	if (gGPSVibSensorTimer != NULL)
	{
		GPSAppTimer_Reset(gGPSVibSensorTimer, 
						GPSLocateVibSensorExpireProc,
						GPSLOCATE_VIBSENSOR_SILENCETHRESHOLD_DEFAULT*KAL_TICKS_1_MIN,
						GPSLOCATE_VIBSENSOR_SILENCETHRESHOLD_DEFAULT*KAL_TICKS_1_MIN,
						KAL_TRUE
						);
	}
	else
	{
		gGPSVibSensorTimer = GPSAppTimer_Create(
									GENERAL_GPSAPP_TIMERID,
									GPSLocateVibSensorExpireProc,
									GPSLOCATE_VIBSENSOR_SILENCETHRESHOLD_DEFAULT*KAL_TICKS_1_MIN,
									GPSLOCATE_VIBSENSOR_SILENCETHRESHOLD_DEFAULT*KAL_TICKS_1_MIN,
									KAL_TRUE
									);
	}

	//change the sensitive polarity
	gbCurrentPolarity = !gbCurrentPolarity;
	EINT_Set_Polarity(GPS_VIBSENSOR_EINT_NO, gbCurrentPolarity);

	//enable this interrupt
	//EINT_UnMask(GPS_VIBSENSOR_EINT_NO);
}
示例#4
0
void Jogball_Init(void)
{
   /*****we will register the EINT interrupt callback functions****************************************/
   
   eint_chans_up=custom_eint_get_channel(jogball_up_eint_chann);
   EINT_Registration(eint_chans_up,KAL_FALSE,0,JogBall_UP_HISR, KAL_TRUE);	
   EINT_Set_Sensitivity(eint_chans_up, EDGE_SENSITIVE);/*******we should set the trigger by EDGE********/
   EINT_Set_Polarity(eint_chans_up, KAL_FALSE); //false -> 0, negative polarity   
   
   eint_chans_down=custom_eint_get_channel(jogball_down_eint_chann);
   EINT_Registration(eint_chans_down,KAL_FALSE,0,JogBall_DOWN_HISR, KAL_TRUE);
   EINT_Set_Sensitivity(eint_chans_down, EDGE_SENSITIVE);
   EINT_Set_Polarity(eint_chans_down, KAL_FALSE); //false -> 0, negative polarity
   
   eint_chans_left=custom_eint_get_channel(jogball_left_eint_chann);
   EINT_Registration(eint_chans_left,KAL_FALSE,0,JogBall_LEFT_HISR, KAL_TRUE);	
   EINT_Set_Sensitivity(eint_chans_left, EDGE_SENSITIVE);
   EINT_Set_Polarity(eint_chans_left, KAL_FALSE); //false -> 0, negative polarity
   
   eint_chans_right=custom_eint_get_channel(jogball_right_eint_chann);
   EINT_Registration(eint_chans_right,KAL_FALSE,0,JogBall_RIGHT_HISR, KAL_TRUE);
   EINT_Set_Sensitivity(eint_chans_right, EDGE_SENSITIVE);
   EINT_Set_Polarity(eint_chans_right, KAL_FALSE); //false -> 0, negative polarity
}
示例#5
0
/****************************************************************************
* FUNCTION
*  JogBall_RIGHT_HISR
* DESCRIPTION
*  Register the call back functions
*  
*  
* PARAMETERS
*  void
* RETURNS
*  void
*****************************************************************************/
void JogBall_RIGHT_HISR(void)
{		
   jogball_right_state = !jogball_right_state;
   EINT_Set_Polarity(eint_chans_right,jogball_right_state); 
   if (jogball_right_state == LEVEL_LOW)
   {
      if(JBXY == KEY_RIGHT_EVENT)
      {
         kbd_SendKey(DEVICE_KEY_RIGHT);
         JBXY=KEY_DIRECTION_EVENT_NUll;
      }
   		else
      {
         JBXY=KEY_RIGHT_EVENT;
      }
   }
}
示例#6
0
void JogBall_DOWN_HISR(void)
{		
   jogball_down_state= !jogball_down_state;
   EINT_Set_Polarity(eint_chans_down,jogball_down_state); 
   if (jogball_down_state == LEVEL_LOW)
   {
      if(JBXY == KEY_DOWN_EVENT)
      {
         kbd_SendKey(DEVICE_KEY_DOWN);
         JBXY=KEY_DIRECTION_EVENT_NUll;
      }
      else
      {
         JBXY=KEY_DOWN_EVENT;
      }
   }
}
示例#7
0
void Direct_Sensor_H_EINT_HISR(void)
{
	if (direct_sensor_h_inturrupt_priority == LEVEL_LOW)
	{
		direct_sensor_h_state = LEVEL_LOW;
		//noke_dbg(" Interrupt: Direct_Sensor_H Level_LOW \n\r");
	}
	else
	{
		direct_sensor_h_state = LEVEL_HIGH;
		//noke_dbg(" Interrupt: Direct_Sensor_H Level_HIGH \n\r");
	}
	//noke_dbg(" \rInterrupt: Direct_Sensor_H  \n");

	Direction_Sensor_state_Filter();


	//EINT_SW_Debounce_Modify(DIRECTION_SENSOR_H_EINT_NO,DIRECT_SENSOR_DEBOUNCE_TIME);
	direct_sensor_h_inturrupt_priority = !direct_sensor_h_inturrupt_priority;
	EINT_Set_Polarity(DIRECTION_SENSOR_H_EINT_NO,  direct_sensor_h_inturrupt_priority);
}
/*************************************************************************
* FUNCTION
*	CHRDET_USB_HISR
*
* DESCRIPTION
*	1. HISR of charger and usb external interrupt
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
static void CHR_USB_EINT_HISR(void)
{
#ifdef __OTG_ENABLE__
	static kal_bool g_usb_host_turn_on_vbus = KAL_FALSE;
#endif // #ifdef __OTG_ENABLE__

//#if defined(PMIC_6305_REG_API) || defined(PMIC_6318_REG_API) || defined(PMIC_6238_REG_API) || defined(PMIC_6326_REG_API) || defined(PMIC_6253_REG_API) || defined(PMIC_6236_REG_API) || defined(PMIC_6276_REG_API) || defined(PMIC_6255_REG_API)

	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)
	EINT_Set_Polarity(chr_usb_detect.chr_usb_eint, (kal_bool)(chr_usb_detect.chr_usb_state));
	#endif // #if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)

	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)
	EINT_Set_Polarity(chr_usb_detect.chr_usb_eint, (kal_bool)(!chr_usb_detect.chr_usb_state));
	#endif // #if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)

	#if defined(PMIC_6326_REG_API)
	//if (pmic_chrdet_status() == chr_usb_detect.chr_usb_state){
	//	ASSERT(0);	// There is problem!!!! Because whenever the program goes here, we should get invert state
	//					// In => Out => In => Out
	//}
	{
		PMU_CTRL_CHR_GET_CHR_DET_STATUS chrStatus;
		DclPMU_Control(chrDet_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chrStatus);
	
		if (chrStatus.enable== chr_usb_detect.chr_usb_state)
		{
			// When the detected status is same as the current state, do nothing!
			//kal_prompt_trace(MOD_BMT,"CHRDet status is same as chr_usb_state");
			EINT_UnMask(chr_usb_detect.chr_usb_eint); // unmask eint here, otherwise it never comes interrupt again.
			//CHR_USB_EINT_Owner_SetMask(CHR_DET_EINT_OWNER_BMT); // Set owner mask flag of BMT
			//CHR_USB_EINT_UnMask(CHR_DET_EINT_OWNER_BMT); // EINT_UnMask(chr_usb_detect.chr_usb_eint);
			return;
		}
	}
	#endif // #if defined(PMIC_6326_REG_API)

	

	chr_usb_detect.chr_usb_state = (kal_bool)(!((kal_uint8)chr_usb_detect.chr_usb_state));
	if (chr_usb_detect.chr_usb_state)
	{
		//kal_prompt_trace(MOD_BMT,"CHR_USB IN");
		kal_brief_trace( TRACE_STATE,BMT_CABLE_IN_TRC);

		#ifdef __USB_UART_MULTIPLEXED_WITH_EXT_SWITCH__
		GPIO_WriteIO(1, gpio_usb_uart_switch_pin);	//switch to usb mode
		#endif

		#ifdef __OTG_ENABLE__
		{
			DCL_HANDLE  otg_dcl_handle;
			DCL_BOOL dcl_data;
			kal_bool b_is_host_on_vbus;
			otg_dcl_handle = DclOTG_DRV_Open(DCL_USB, FLAGS_NONE);
			DclOTG_DRV_Control(otg_dcl_handle, OTG_DRV_CMD_IS_HOST_TURN_ON_VBUS, (DCL_CTRL_DATA_T  *)&dcl_data);
			b_is_host_on_vbus = (kal_bool)dcl_data;
			DclOTG_DRV_Close(otg_dcl_handle);
			
			if (b_is_host_on_vbus== KAL_TRUE)
		{
			g_usb_host_turn_on_vbus = KAL_TRUE;
			// Force to unmask EINT for OTG case
			CHR_USB_EINT_UnMask(USB_DET_EINT_OWNER_FORCE_UNMASK); // EINT_UnMask(chr_usb_detect.chr_usb_eint);
			return;
		}
		}
		#endif // #ifdef __OTG_ENABLE__

		// Clear EINT owner bit mask
		CHR_USB_EINT_Owner_ClrMask();

		ASSERT(chr_usb_det_mgr.pw_is_charger_usb_det_eint != NULL);
		chr_usb_det_mgr.pw_is_charger_usb_det_eint();


	}
	else
	{

		#ifdef __USB_UART_MULTIPLEXED_WITH_EXT_SWITCH__
		GPIO_WriteIO(0, gpio_usb_uart_switch_pin);	//switch to uart mode
		#endif

		#ifdef __OTG_ENABLE__
		if (g_usb_host_turn_on_vbus == KAL_TRUE)
		{
			g_usb_host_turn_on_vbus = KAL_FALSE;
			// Force to unmask EINT for OTG case
			CHR_USB_EINT_UnMask(USB_DET_EINT_OWNER_FORCE_UNMASK); // EINT_UnMask(chr_usb_detect.chr_usb_eint);
			return;
		}
		#endif // #ifdef __OTG_ENABLE__

			CHR_USB_PLUG_OUT();
	}


}
示例#9
0
void EINT_Registration_and_mask(kal_uint8 eintno, kal_bool Dbounce_En, kal_bool ACT_Polarity, void (reg_hisr)(void), kal_bool auto_umask)
{
//	PDN_CLR(PDN_GPIO);
	kal_uint32 savedMask;

	/* If EINT Number is out of range, get return address and send it to exception handler */
	if(eintno >= EINT_TOTAL_CHANNEL)
	{
	   kal_uint32 retaddr;
	   
	   GET_RETURN_ADDRESS(retaddr);
	   kal_fatal_error_handler(KAL_ERROR_DRV_EINT_INVALID_INDEX, retaddr);
	}
   
	/*disable eint interrupt*/
	eint_set_irqen(eintno, EINT_DISABLE);

	/*register LISR*/
	/*dispatch for dedicated eint*/
	if (eint_is_dedicated & (1<<eintno))
	{
		switch(eint_is_dedicated_map[eintno])
		{
			case DEDICATED_EINT0:
			{
				eint_set_l1_eint_enable(DEDICATED_EINT0, EINT_DISABLE);
				IRQ_Register_LISR(DEDICATED_EINT_IRQ0, DEINT0_LISR, "DEINT0 handler");
			}
			break;
			case DEDICATED_EINT1:
			{
				eint_set_l1_eint_enable(DEDICATED_EINT1, EINT_DISABLE);
				IRQ_Register_LISR(DEDICATED_EINT_IRQ1, DEINT1_LISR, "DEINT1 handler");
			}
			break;
			case DEDICATED_EINT2:
			{
				eint_set_l1_eint_enable(DEDICATED_EINT2, EINT_DISABLE);
				IRQ_Register_LISR(DEDICATED_EINT_IRQ2, DEINT2_LISR, "DEINT2 handler");
			}
			break;
			case DEDICATED_EINT3:
			{
				eint_set_l1_eint_enable(DEDICATED_EINT3, EINT_DISABLE);
				IRQ_Register_LISR(DEDICATED_EINT_IRQ3, DEINT3_LISR, "DEINT3 handler");
			}
			break;
			default:
			break;
		}
	}
	else
	{
		IRQ_Register_LISR(IRQ_EIT_CODE, EINT_LISR, "EINT handler");
	}

   /* Save and set MCU's I,F bits to disable interrupts */
//   savedMask = LockIRQ();

   /* Set external interrupt polarity */
   EINT_Set_Polarity(eintno,ACT_Polarity);
#if !defined(MT6290)
	  gpio_set_eint_src(eintno,eint_src_map[eintno]);
#endif

   if (Dbounce_En)
   {
   	 //eint_set_debounce_duration(eintno,EINT_DB_DUR_DEFAULT);
	 eint_set_debounce_enable(eintno,EINT_ENABLE);
   }
   else
   {
     /*disable debounce */
     eint_set_debounce_enable(eintno,EINT_DISABLE);
   }

   /* Save and set MCU's I,F bits to disable interrupts */
   savedMask = SaveAndSetIRQMask();

   /* Register external interrupt's HISR */
   EINT_FUNC.eint_func[eintno] = reg_hisr;
   EINT_FUNC.eint_active[eintno] = KAL_FALSE;
   EINT_FUNC.eint_auto_umask[eintno] = auto_umask;

	if (eint_is_dedicated & (1<<eintno))
	{
		/* register HISR */
		DRV_Register_HISR(DRV_DEINT_HISR_ID, DEINT_HISR_Entry);
		EINT_L2_ACK(eintno);
		//EINT_UnMask(eintno);
		RestoreIRQMask(savedMask);
	}
	else
	{
		/* register HISR */
		DRV_Register_HISR(DRV_EINT_HISR_ID, EINT_HISR_Entry);
		EINT_L2_ACK(eintno);
		//EINT_UnMask(eintno);
		IRQSensitivity( IRQ_EIT_CODE, LEVEL_SENSITIVE );
		/* Enable external interrupt */
		IRQUnmask( IRQ_EIT_CODE );
		RestoreIRQMask(savedMask);
	}
}