/*
************************************************************************************************************
*
*                                             function
*
*    函数名称:
*
*    参数列表:
*
*    返回值  :
*
*    说明    :
*
*
************************************************************************************************************
*/
static int eGon2_standby_detect(void)
{
	int   i;
	__u32 dcin_exist, battery_exist;
	__u8  power_int_status[5];

	//开启24M晶振
	standby_clock_24m_op(1);
	//切换apb1到24M
	standby_clock_apb1_to_source(24000000);
	//设置频率到24M
	standby_clock_to_source(24000000);
	standby_clock_divsetback();
	for(i=0;i<2000;i++);
	//检查中断触发
	eGon2_power_int_query(power_int_status);
	//清除中断控制器的pending
//	standby_int_query();
//	if(eGon2_key_get_status() == 1)			//普通ADC按键按下
//	{
//		return 1;
//	}
//	eGon2_power_vbus_unlimit();
	if(power_int_status[2] & 0x02)			//电源按键短按
	{
		return 2;
	}
	if(power_int_status[2] & 0x01)			//电源按键长按
	{
		return 3;
	}
	dcin_exist = 100;
	battery_exist = 100;
	eGon2_power_get_dcin_battery_exist(&dcin_exist, &battery_exist);
	if(!dcin_exist)							//外部电源移除
	{
		return 4;
	}
//	if((power_int_status[1] & 0x04) && (battery_exist==1))			//充电完成
//	{
//		return 5;
//	}
	if(power_int_status[0] & 0x08)			//usb火牛接入
	{
		return 8;
	}
	if(power_int_status[0] & 0x04)			//usb火牛移除
	{
		return 9;
	}

	//还原到32K
	standby_clock_divsetto0();
	standby_clock_apb1_to_source(32000);
	standby_clock_to_source(32000);
	standby_clock_24m_op(0);

	return 0;
}
Пример #2
0
static void power_int_handler(void)
{
    char sp0[5];

    eGon2_power_int_query(sp0);
    if(sp0[0] & 4) {
        wlibc_uprintf("vbus remove\n");
        *L4280A408 = 0;
        usb_detect_exit();
        power_set_usbpc();
    } else { 
        if(sp0[0] & 8) {
            wlibc_uprintf("vbus insert\n");
            *L4280A3A8 |= 4;
            usb_detect_enter();
        }
    }
    if(sp0[2] & 2) {
        *L4280A3A8 |= 2;
    }else if(sp0[2] & 1)
        *L4280A3A8 |= 1;
}