Exemplo n.º 1
0
/*----------------------------------------------------------------------------*/
void music_info_init(void)
{
#ifdef NO_REM_LAST_DEV
	given_device = NO_DEVICE;
#else
     given_device = read_info(MEM_ACTIVE_DEV);
#endif

    if (given_device == DEVICE_SDMMC0)
    {
	 Set_Curr_Func(SYS_MP3DECODE_SD);
        given_file_method = PLAY_FIRST_FILE;
        given_device = DEVICE_SDMMC0;
        put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
    }
    else if (given_device == DEVICE_UDISK)
    {
    	 Set_Curr_Func(SYS_MP3DECODE_USB);
        given_file_method = PLAY_FIRST_FILE;
        given_device = DEVICE_UDISK;
        put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
    }
    else
    {
    	 Set_Curr_Func(SYS_MP3DECODE_USB);
        given_file_method = PLAY_FIRST_FILE;
        given_device = DEVICE_UDISK;
        put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
    }
}
Exemplo n.º 2
0
/*----------------------------------------------------------------------------*/
static void aux_check(void)
{
    static u8 aux_cnt_online;


    P3DIR |= BIT(4); //linein check port
    P3PU |= BIT(4);
    _nop_();
    _nop_();
    //_nop_();
    if (P34)
    {
        aux_cnt_online = 0;

        if (aux_online)
        {
            put_msg_lifo(MSG_AUX_OUT);
            aux_online = 0;
        }
    }
    else
    {
        aux_cnt_online++;
        if (aux_cnt_online > 6)
        {
            if (!aux_online)
            {
                put_msg_lifo(MSG_AUX_IN);
                aux_online = 1;
            }
        }
    }
    //P0DIR &= ~BIT(7); //linein check port

}
Exemplo n.º 3
0
/*----------------------------------------------------------------------------*/
void aux_check(void)
{
    static u8 aux_cnt_online;

#ifdef AUX_DETECT_SHARE_WITH_IIC_SCL
    if (iic_busy)
    {
        return;
    }
#endif	

#if defined(INDEPENDENT_AUX_DETECT_GPIO)
	AUX_DETECT_GPIO=1;
#elif defined(AUX_DETECT_USE_VPP)

#elif defined(LINE_IN_DETECT_SHARE_LED_STATUS_PORT)
	if(AUX_DETECT_GPIO==0)return;
#else
	AUX_DETECT_GPIO=1;
#endif

    aux_detect_in();
	
    //DACCON0 |= 0x80;
    _nop_();
    _nop_();
    _nop_();

    if (AUX_DETECT_GPIO)
    {
        aux_cnt_online = 0;

        if (aux_online)
        {
            put_msg_lifo(MSG_AUX_OUT);
            aux_online = 0;
        }
    }
    else
    {
        aux_cnt_online++;
        if (aux_cnt_online > 20)
        {
            if (!aux_online)
            {
                put_msg_lifo(MSG_AUX_IN);
                aux_online = 1;
            }
        }
    }
    aux_detect_in_off(); //linein check port
}
Exemplo n.º 4
0
/*----------------------------------------------------------------------------*/
void rtc_fun(void)
{
    MAIN_POWER_PORT_INIT();	
    MAIN_POWER_PORT_DISABLE();	
    iic_gpio_set_low();
    amp_mute(1);

    if(alm_on_flag){
		if(sys_main_vol != alrm_vol_bakup)
		sys_main_vol = alrm_vol_bakup;
    		alm_on_flag = 0;
    }
    input_number_en = 0;
    vol_change_en=0;
    key_voice_en=0;
    main_menu = MENU_RTC;
    close_alarm();
    dsp_set_eq_mode(0);			  //系统时钟div前需关闭eq
    SYSTEM_CLK_DIV4();
    key_table_sel(0);
    flush_all_msg();
    set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量
    dac_out_select(DAC_MUSIC, 0);
	
    rtc_mode_setting = RTC_DISPLAY;
    rtc_coordinate = 0;
    alm_coordinate = 0;
    if (alm_cnt)
    {
        put_msg_lifo(MSG_ALM_ON);
    }
    else
    {
        read_rtc(&curr_time);
        chk_date_err();
        disp_port(MENU_RTC);
    }

    MAIN_POWER_PORT_INIT();	
    MAIN_POWER_PORT_DISABLE();	
	
    deal_rtc();

    amp_mute(1);
    MAIN_POWER_PORT_ENABLE();	

    delay_10ms(3);
    key_voice_en=0;
    main_vol_set(0, CHANGE_VOL_NO_MEM);
    MAIN_POWER_PORT_ENABLE();	
    amp_mute(1);
    delay_10ms(80);
  
    snooze_en =0;
	
    PT2313_Init();
    delay_10ms(10);
    PT2313_Init();
	
}
Exemplo n.º 5
0
/*----------------------------------------------------------------------------*/
void rec_mic_fun(void)
{
#ifdef UART_ENABLE
	deg_str("encode \n");
#endif

    dac_mute_control(1,1);
    input_number_en = 0;
    //vol_change_en=1;
    main_menu = MENU_RECWORKING;
    disp_port(MENU_SCAN_DISK);
    delay_10ms(50);
    SYSTEM_CLK_DIV2();
    encode_channel = REC_MIC;
    encode_vol = 7;
    key_table_sel(0);
    flush_all_msg();
    if(RECODE_INIT == encode_status)
    {
        	put_msg_lifo(MSG_REC_FIND);
        	//put_msg_lifo(MSG_REC_START);
    }
    //put_msg_lifo(MSG_REC_START);
    set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量
    rec_mic_main();
    dac_mute_control(0,0);
    break_encode();
    lcd_clr_flash_icon();	
}
void detect_event_func_hdlr(void)
{
	u8 i=0;

	for(i=0;i<MAX_EVENT_LIST;i++){


		if(event_tab[i].event_func.gpio_protect != NULL)
			if ( event_tab[i].event_func.gpio_protect() )continue;

#if 0
	   	 my_printf(" --->main :11111 %x \r\n",(u16)event_tab[i].event_func.gpio_init);
	   	 my_printf(" --->main :22222 %x \r\n",(u16)event_tab[i].event_func.gpio_level);
	   	 my_printf(" --->main :33333 %x \r\n",(u16)event_tab[i].event_func.gpio_release);
#endif	
		if(event_tab[i].event_func.gpio_init != NULL)
		event_tab[i].event_func.gpio_init();
		_nop_();  _nop_();

		if(event_tab[i].event_func.gpio_level != NULL){
			
			if (event_tab[i].event_func.gpio_level()==event_tab[i].event_logic_level){
				
			        event_tab[i].event_deb_timer = 0;
			        if (!event_tab[i].event_valid)
			        {
			            event_tab[i].event_valid=1;
			            put_msg_lifo(event_tab[i].event_msg_in);
			        }
			}
			else{
				
			        event_tab[i].event_deb_timer++;
			        if (event_tab[i].event_deb_timer  > 6)
			        {
			            if (event_tab[i].event_valid)
			            {
			            		put_msg_lifo(event_tab[i].event_msg_out);
			                	event_tab[i].event_valid = 0;
			            }
			        }
			}
		}
		if(event_tab[i].event_func.gpio_init != NULL)
			event_tab[i].event_func.gpio_release();
	}
}
/*----------------------------------------------------------------------------*/
 bool ir_remote_set_snooze()
{
	if(alm_on_flag){
	       put_msg_lifo(MSG_SNOOZE_SETUP);
		return 1;
	}	
		return 0;
}
Exemplo n.º 8
0
/*----------------------------------------------------------------------------*/
void timer0isr(void)
{
    static xd_u8 counter0, counter1;

    PSW = 0x08;
    DPCON = 0x0;
    T0CON &= ~BIT(7);			//clear pending
#ifdef LCD_GPIO_DRV
   seg_lcd_disp_scan();
#else
   //disp_scan();
#endif
    adc_scan();
    counter0++;
    usb_polling();

#ifdef JOG_STICK_FUNC	 
    JogDetect();
#endif

    if ((counter0 % 5) == 0)			//10ms
    {
        dec_delay_counter();
//#if SDMMC_CMD_MODE
//        sd_online_check();
//#if SDMMC_CLK_MODE
        sdmmc_online_chk(1);
//#elif SDMMC_GPIO_MODE
        //sdmmc_detect();
//#endif
        keyScan();
    }

//    if ((counter0 % 50) == 0)
//    {
//        put_msg_fifo(MSG_100MS);
//    }
    if ((counter0 % 100) == 0)
    {
    	 ad_mod_sel_hdlr();
        put_msg_fifo(MSG_200MS);
        counter0 = 0;
    }
    counter1++;
    if ((counter1 % 250) == 0)
    {
        put_msg_fifo(MSG_HALF_SECOND);
        counter1 = 0;
    }
#if 0//RTC_ENABLE
    if (IRTCON & BIT(7))
    {
        alm_cnt = 1;
        last_work_mode = work_mode;
        put_msg_lifo(MSG_ALM_ON);
    }
#endif
}
Exemplo n.º 9
0
/*----------------------------------------------------------------------------*/
void timer0isr(void)
{
    static u8 counter0, counter1;

    PSW = 0x08;
    DPCON = 0x0;
    T0CON &= ~BIT(7);			//clear pending

#ifndef NO_LED_DISPLAY
    disp_scan();
#endif    
    adc_scan();
    counter0++;
    usb_polling();

   disp_dled();

    if ((counter0 % 5) == 0)			//10ms
    {
        dec_delay_counter();
//#if SDMMC_CMD_MODE
//        sd_online_check();
#if SDMMC_CLK_MODE
        sdmmc_online_chk(1);
#elif SDMMC_GPIO_MODE
        sdmmc_detect();
#endif
        keyScan();
    }

//    if ((counter0 % 50) == 0)
//    {
//        put_msg_fifo(MSG_100MS);
//    }
    if ((counter0 % 100) == 0)
    {

	 //aux_check();
        //put_msg_fifo(MSG_200MS);
        counter0 = 0;
    }
    counter1++;
    if ((counter1 % 250) == 0)
    {
        put_msg_fifo(MSG_HALF_SECOND);
        counter1 = 0;
    }
#if RTC_ENABLE
    if (IRTCON & BIT(7))
    {
        alm_cnt = 1;
        last_work_mode = work_mode;
        put_msg_lifo(MSG_ALM_ON);
    }
#endif
}
Exemplo n.º 10
0
void snooze_hdlr()
{
	if(snooze_en){
		if(snooze_cnt++>(SNOOZE_TIME*60)){
		//if(snooze_cnt++>(SNOOZE_TIME)){
			snooze_init();
        		put_msg_lifo(MSG_ALM_ON);
		}
	}
}
Exemplo n.º 11
0
/*----------------------------------------------------------------------------*/
void check_alm(void)
{
    u8 rtc_reg;
    rtc_reg = read_rtc_reg();
    if (rtc_reg & BIT(7))
    {
        alm_flag = 1;
		put_msg_lifo(INFO_ALM_BELL);
    }
}
Exemplo n.º 12
0
static void bt_check(void)
{
    static u8 bt_cnt_online;

#if defined(BT_DETECT_SHARE_WITH_IIC)
    if (iic_busy)
    {
        return;
    }
#endif	

    BT_GPIO_INIT();
    _nop_();  _nop_();

    if (!BT_GPIO_READ)
    {
        bt_cnt_online = 0;
        if (bt_online)
        {
            bt_online = 0;
            //put_msg_lifo(INFO_BT_MOD | KEY_SHORT_UP);
        }
    }
    else
    {
        bt_cnt_online++;
        if (bt_cnt_online > 6)
        {
            if (!bt_online)
            {
#ifdef BLUE_TOOTH_DETECTION_FOR_POWER_OFF
                put_msg_lifo(INFO_POWER| KEY_SHORT_UP);

#else
                put_msg_lifo(INFO_BT_MOD | KEY_SHORT_UP);
#endif
                bt_online = 1;
            }
        }
    }
    BT_GPIO_RELEASE(); //linein check port
}
Exemplo n.º 13
0
void gpio_sel_func_mode()
{

	GPIO_SEL_FUNC_GPIO_INIT();
	_nop_();
	
	if(GPIO_SEL_FUNC_GPIO_READ){

		if(work_mode!= HIGH_LEVEL_SEL_MODE){
			Set_Curr_Func(HIGH_LEVEL_SEL_MODE);
      			put_msg_lifo(INFO_NEXT_SYS_MODE);	   
		}
	}
	else{

		if(work_mode!= LOW_LEVEL_SEL_MODE){
			Set_Curr_Func(LOW_LEVEL_SEL_MODE);
      			put_msg_lifo(INFO_NEXT_SYS_MODE);	   
		}
	}
}
Exemplo n.º 14
0
void clr_alarm_func(void)
{
	if(alm_on_flag){

	}
	else{
		alm_on_flag =0;
		snooze_en =0;	
	 	work_mode= RTC_MODE;
	       put_msg_lifo(MSG_CHANGE_WORK_MODE);
	}
}
Exemplo n.º 15
0
static void mic_check(void)
{
    static u8 mic_cnt_online;

#if defined(MIC_DETECT_SHARE_WITH_IIC)
    if (iic_busy)
    {
        return;
    }
#endif	

    MICPHONE_GPIO_INIT();
    _nop_();  _nop_();
#ifdef MIC_HIGH_LEVEL_DETECT_FUNC
    if (!MICPHONE_GPIO_READ)
#else
    if (MICPHONE_GPIO_READ)
#endif		
    {
        mic_cnt_online = 0;
        if (mic_online)
        {
            mic_online = 0;
            put_msg_lifo(MSG_MIC_OUT);
        }
    }
    else
    {
        mic_cnt_online++;
        if (mic_cnt_online > 6)
        {
            if (!mic_online)
            {
                put_msg_lifo(MSG_MIC_IN);
                //mic_online = 1;
            }
        }
    }
    MICPHONE_GPIO_RELEASE(); //linein check port
}
Exemplo n.º 16
0
static void aux_check(void)
{
    static u8 aux_cnt_online;

    if(aux_detect_protect_en)return;
	
#ifdef AUX_DETECT_SHARE_IIC_GPIO
    if(iic_busy)return;
#endif

     aux_detect_gpio_init();

    if (AUX_DETECT_GPIO)
    {
        aux_cnt_online = 0;

        if (aux_online)
        {
            put_msg_lifo(MSG_AUX_OUT);
            aux_online = 0;
        }
    }
    else
    {
        aux_cnt_online++;
        if (aux_cnt_online > 10)
        {
            if (!aux_online)
            {
                put_msg_lifo(MSG_AUX_IN);
                aux_online = 1;
            }
        }
    }
     aux_detect_in_off();

}
Exemplo n.º 17
0
static void aux_check(void)
{
    static u8 aux_cnt_online;

    if(iic_busy)return;

    P0DIR |= BIT(7); //linein check port
    P0PU |= BIT(7);
    //_nop_();
    //_nop_();
    //_nop_();
    if (P07)
    {
        aux_cnt_online = 0;

        if (aux_online)
        {
            put_msg_lifo(MSG_AUX_OUT);
            aux_online = 0;
        }
    }
    else
    {
        aux_cnt_online++;
        if (aux_cnt_online > 50)
        {
            if (!aux_online)
            {
                put_msg_lifo(MSG_AUX_IN);
                aux_online = 1;
            }
        }
    }
    //P0DIR &= ~BIT(7); //linein check port

}
Exemplo n.º 18
0
void set_snooze_func(void)
{
	if(alm_on_flag){
		alm_on_flag =0;
		
		snooze_en =~snooze_en;	
	 	work_mode= RTC_MODE;
	       put_msg_lifo(MSG_CHANGE_WORK_MODE);
	}
	else{
		if(snooze_en){
			snooze_init();
		}
	}
}
Exemplo n.º 19
0
/*----------------------------------------------------------------------------*/
void decode_play(void)
{
#ifdef MP3_UART_ENABLE
	sys_printf(" SYS GO IN DECODE MODE");
#endif
	Mute_Ext_PA(MUTE);

	disp_play_filenum_timer=10;
	folder_select=0;
	folder_mode_select=0;
	rtc_setting=0;
	disp_scenario = DISP_NORMAL;
	Disp_Con(DISP_SCAN_DISK);
	sysclock_div2(1);
#ifndef NO_SD_DECODE_FUNC	
    	sd_speed_init(0, 50);
#endif
		
	decodeclock_div2(DECODE_CLK_DIV2);				//decoder分频,可以减少功耗
    	music_info_init();
    	dsp_hi_pro();
    	decodeint_hi_pro();
    	device_active = 0;
    	put_msg_lifo(SEL_GIVEN_DEVICE_GIVEN_FILE);
	set_max_vol(MAX_ANALOG_VOL-DECODE_ANALOG_VOL_CUT, MAX_DIGITAL_VOL);			//设置Music模式的音量上限
    //suspend_sdmmc();
	music_play();

	Mute_Ext_PA(MUTE);

#ifdef ADKEY_SELECT_MODE
    	mode_switch_protect_bit=1;
#endif
	disp_scenario = DISP_NORMAL;

	folder_select=0;
	folder_mode_select=0;
	
	stop_decode();
#ifdef USE_USB_PROG_PLAY_MODE	
	usb_prog_mode_cls();	
#endif
#if(MEMORY_STYLE != USE_DEVICE)
	usb_suspend();			//Entered Suspend mode
#endif
	write_playtime(&playpoint_time);				//记录断点信息(EEPROM)
	main_vol_set(0, CHANGE_VOL_NO_MEM);
}
Exemplo n.º 20
0
void DSA_if_hdlr(void)
{
	xd_u8 dsa_key=0;
	DSA_Detect();

	if(DSA_REV_OK){

		DSA_REV_OK =0;
#if 1		  
#ifdef DSA_DEBUG_REV_KEY			  
			    printf(" dsa -DSA_Rdata--->%x \r\n",DSA_Rdata);
#endif
			   if(((DSA_Rdata&0xFF00)==0x5500))
			   {
				 for (DSA_Delay=0;DSA_Delay<DSA_KEYNUM;DSA_Delay++)
				 {
					if ((u8)(DSA_Rdata&0x00ff)==DSA_Key[DSA_Delay][1]){
						dsa_key=DSA_Key[DSA_Delay][2];
#ifdef DSA_DEBUG_REV_KEY
						  printf(" dsa -DSA_Rdata  key--->%x \r\n",(u16)dsa_key);
#endif
						  put_msg_lifo(dsa_key);			  
			   		}
				 }
			   }
#endif
	}
	
	if ((DSA_Sdata)&&(DSAState==0))
	{
		DSAState=10;
		DSA_Send();
	}
	else
	{
		DSA_Send();
	}	

	//EA =1;
	if(gether_info_timer++>5){
		gether_info_timer =0;

		//if(work_mode <SYS_FMREV)
			UI_2_DSA();
	}
}
Exemplo n.º 21
0
/*----------------------------------------------------------------------------*/
void disk_remove_deal_for_music(void)
{

   // if ((device_check() == 0))//当前播放设备已经不在线,则自动选取下一个设备
    {

#if 1
    	 //Set_Curr_Func(SYS_IDLE);
       // put_msg_lifo(MSG_CHANGE_WORK_MODE);      
#else	            
        given_device = DEVICE_AUTO_NEXT;

        given_file_method = PLAY_BREAK_POINT;
        put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
#endif		

	   sys_printf(" ------------------------------------->  disk_remove_deal_for_music ");
	
        if ( (play_status == MAD_PAUSE) || (play_status == MAD_PLAY) )
            backup_music_point();								//记录断点信息
    }

}
Exemplo n.º 22
0
/*----------------------------------------------------------------------------*/
void rec_mic_fun(void)
{
    dac_mute_control(1,1);
    input_number_en = 0;
    vol_change_en=1;
    main_menu = MENU_REC;
    disp_port(MENU_REC);
    SYSTEM_CLK_DIV2();
    encode_channel = REC_MIC;
    encode_vol = 7;
    key_table_sel(0);
    flush_all_msg();
    if(RECODE_INIT == encode_status)
    {
        put_msg_lifo(MSG_REC_FIND);
        //put_msg_lifo(MSG_REC_START);
    }
    //put_msg_lifo(MSG_REC_START);
    set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量
    rec_mic_main();
    dac_mute_control(0,0);
    break_encode();
}
void erp2_func_hdlr(void)
{
	if((((((get_usb_online_status()&BIT(0))==0)&&((get_sdmmc_online_status(SDMMCA_ID))==0))||
		(Music_Play_var.bPlayStatus== MAD_PAUSE))&&((work_mode==SYS_USB_MODE)||(work_mode==SYS_SD_MODE)))||
#ifdef BLUE_TOOTH_ERP2_FUNC
		((get_blue_tooth_connect_status()==0)&&(work_mode==SYS_BLUETOOTH_MODE))
#endif		
		){

		if(erp2_timer++>=(2*60*ERP2_TIMER_UNIT_IN_MIN)){
		//if(erp2_timer++>=(20)){

			erp2_timer=0;
			 erp2_func_pwrdn=1;

			if(work_mode !=SYS_IDLE_MODE){
				
    				set_play_status_led(LED_SPARK_STOP);
				func_msg_hdlr(S_FUNC,SYS_IDLE_MODE);

	       	 	put_msg_lifo(MSG_CHANGE_WORK_MODE);

#ifdef UART_ENABLE
    					printf(" ---> erp2_func_pwrdn MSG_CHANGE_WORK_MODE\r\n");
#endif

			}    			
		}
	}
	else{
		
		erp2_func_pwrdn=0;
		erp2_timer=0;
	}

}
Exemplo n.º 24
0
void aux_check(void)
{
    static u8 aux_cnt_online;

#ifdef AUX_DETECT_SHARE_WITH_IIC_SCL
    if (iic_busy)
    {
        return;
    }
#endif	

#ifdef SYS_LED_PROTECTION_UNTILL_PWR_ON
#ifdef AUX_LED_PROTECTION_BEFORE_PWR_ON
	 if(sys_pwr_on_led_protect_bit)return;
#endif	 
#endif

#ifdef AUX_DETECT_HIGH_LEVEL
	AUX_DETECT_GPIO=0;

#else
#if defined(INDEPENDENT_AUX_DETECT_GPIO)
	AUX_DETECT_GPIO=1;
#elif defined(AUX_DETECT_USE_VPP)

#elif defined(LINE_IN_DETECT_SHARE_LED_STATUS_PORT)
	if(AUX_DETECT_GPIO==0)return;
#else
	//if(AUX_DETECT_GPIO==0)return;
#endif
#endif
    aux_detect_in();
	
    //DACCON0 |= 0x80;
    _nop_();
    _nop_();
    _nop_();

#ifdef AUX_DETECT_HIGH_LEVEL
    if (!AUX_DETECT_GPIO)
#else
    if (AUX_DETECT_GPIO)
#endif		
    {
        aux_cnt_online = 0;

        if (aux_online)
        {
            put_msg_lifo(MSG_AUX_OUT);
            aux_online = 0;
        }
    }
    else
    {
        aux_cnt_online++;
        if (aux_cnt_online > 20)
        {
            if (!aux_online)
            {
                put_msg_lifo(MSG_AUX_IN);
                aux_online = 1;
            }
        }
    }
    aux_detect_in_off(); //linein check port
}
bool ad_detect_hdlr(u16 adc_value)
{
	u8 adc_volt=0;
	
    	if (adc_value > AD_DETECT_NOKEY){
			
#ifdef USE_ADKEY_DETECT_AUX						
		 	if (aux_online)
	        	{
				det_timer_aux =0;
	            		put_msg_lifo(MSG_AUX_OUT);
	            		aux_online = 0;
	        	}
#endif	

#ifdef USE_ADKEY_DETECT_HP		
			if(earphone_plugged){
				det_timer_hp =0;
				earphone_plugged =0;
			}
#endif		
		return 1;
	}
	else{

		adc_volt = (u8)(adc_value>>8);

#if 0
		my_printf(" --->ad_detect_hdlr :  adc_volt  %x \r\n",(u16)adc_volt);
		my_printf(" --->ad_detect_hdlr :  AD_VOLT_FOR_DET  %x \r\n",(u16)AD_VOLT_FOR_DET);
		my_printf(" --->ad_detect_hdlr :  AD_VOLT_FOR_HP  %x \r\n",(u16)AD_VOLT_FOR_HP);
		my_printf(" --->ad_detect_hdlr :  AD_VOLT_FOR_AUX  %x \r\n",(u16)AD_VOLT_FOR_AUX);


		my_printf(" --->ad_detect_hdlr :  earphone_plugged  %x \r\n",(u16)earphone_plugged);
		my_printf(" --->ad_detect_hdlr :  aux_online  %x \r\n",(u16)aux_online);
#endif
			if(adc_volt>AD_VOLT_FOR_DET){

				if(adc_volt>AD_VOLT_FOR_HP){

#ifdef USE_ADKEY_DETECT_AUX						
				 	if (aux_online)
			        	{
						det_timer_aux =0;
			            		put_msg_lifo(MSG_AUX_OUT);
			            		aux_online = 0;
			        	}
#endif		
					
#ifdef USE_ADKEY_DETECT_HP
					if(det_timer_hp++>20){

						det_timer_hp =0;
						if(!earphone_plugged){
							earphone_plugged =1;
						}
					}
#endif				
				}
				else if(adc_volt>AD_VOLT_FOR_AUX){

#ifdef USE_ADKEY_DETECT_HP		
					if(earphone_plugged){
						det_timer_hp =0;
						earphone_plugged =0;
					}
#endif		
					
#ifdef USE_ADKEY_DETECT_AUX				
					if(det_timer_aux++>20){
						det_timer_aux =0;
				            if (!aux_online)
				            {
				                put_msg_lifo(MSG_AUX_IN);
				                aux_online = 1;
				            }
					}
#endif				
				}
				else{

#ifdef USE_ADKEY_DETECT_HP
					if(det_timer_hp++>10){

						det_timer_hp =0;

						if(!earphone_plugged){
							earphone_plugged =1;
						}
					}
#endif				

#ifdef USE_ADKEY_DETECT_AUX				
					if(det_timer_aux++>10){
						det_timer_aux =0;
				            if (!aux_online)
				            {
				                put_msg_lifo(MSG_AUX_IN);
				                aux_online = 1;
				            }
					}
#endif				
				}

			return 1;	// NO KEY
		}	
	}

	return 0;	// ADKEY 
}
Exemplo n.º 26
0
void   DSA_Detect(void)
{
	xd_u8 key_temp=0;
DSA_Loop:       
	switch (DSAState)
	{
	     case DSA_Ideal:
#ifdef DSA_DEBUG_REV			  		 	
		   //sys_printf(" DSA_Ideal ");
#endif
	       DSA_Timer=0;
           SET_DATA_READ;
		   SET_STB_READ;
 	       SET_ACK_WRITE;
 	       SET_ACK_HIGH;
		   //for (DSA_Delay=0;DSA_Delay<5;DSA_Delay++);
//		   DSA_Delay_us(6);
		   
		   DSA_Delay=0;
//		   while((GET_DATA)&&(DSA_Delay<20))
//		   	DSA_Delay++;

	          if(!GET_DATA) 
	          { 
	          	DSAState++;
			    SET_ACK_LOW;
			    goto DSA_Loop;
	          }
	        break;
	     case DSA_Sync:
#ifdef DSA_DEBUG_REV
		   sys_printf(" DSA_Sync ");
#endif		 	
	          if (DSA_Timer>250) 
	          {
	          	//DSAState=DSA_Ideal;
	             // break;
	          }
	         DSA_Delay_us(10);
//	          SET_ACK_WRITE;
	          
//		   DSA_Delay_us(6);


//		   DSA_Delay=0;
//		   while((!GET_DATA)&&(DSA_Delay<20))
//		   	DSA_Delay++;
	          if (GET_DATA) 
	          {
	           	DSAState++;
	           	SET_ACK_HIGH;
	           	goto	DSA_Loop;
//			DSA_Delay_us(6);				
	          }
		   else 
		   {
		   	DSA_Timer++;
		   }
		  break;
	     case DSA_Comm:
#ifdef DSA_DEBUG_REV			  
		   sys_printf(" DSA_Comm ");
#endif
                 SET_DATA_READ;
	          SET_ACK_WRITE;		   
		   SET_STB_READ;
		   //for (DSA_Delay=0;DSA_Delay<5;DSA_Delay++);
		   
	          DSA_Rdata=0;
	          for (DSA_Count=0;DSA_Count<16;DSA_Count++)
	           {
	           	DSA_Timer=0;
	           	while ((GET_STB)&&(DSA_Timer<620)){
					DSA_Delay_us(10);
	           	    DSA_Timer++;
	           	}
	           	//if (DSA_Timer>=600)
	              {
	              	//DSAState=DSA_Ideal;
	                  //      goto DSA_Loop;
	               }
	
	           	DSA_Rdata<<=1;	  
	           	if (GET_DATA)
	           	    DSA_Rdata |=0x01;         	
	                SET_ACK_LOW;
			//for (DSA_Delay=0;DSA_Delay<18;DSA_Delay++);
		   	//DSA_Delay_us(12);
			DSA_Timer=0;
			
	           	while ((!GET_STB)&&(DSA_Timer<250))
	           		{
				DSA_Timer++;
				DSA_Delay_us(10);	
	           		}
				
	           	if (DSA_Timer>=250)             
			{
		  		//EA =1;
				//DSAState=DSA_Ideal;
	                     //goto DSA_Loop;
			}
	               SET_ACK_HIGH;   
			 //DSA_Delay_us(12);
				   
	           }

		    DSA_REV_OK=1;			  
#if 0		  
#ifdef DSA_DEBUG			  
		    printf(" dsa -DSA_Rdata--->%x \r\n",DSA_Rdata);
#endif
		   if(((DSA_Rdata&0xFF00)==0x5500))
		   {
			 for (DSA_Delay=0;DSA_Delay<DSA_KEYNUM;DSA_Delay++)
			 {
				if ((u8)(DSA_Rdata&0x00ff)==DSA_Key[DSA_Delay][1]){
					key_temp=DSA_Key[DSA_Delay][2];
#ifdef DSA_DEBUG
					  printf(" dsa -DSA_Rdata  key--->%x \r\n",(u16)key_temp);
#endif
					  put_msg_lifo(key_temp);			  
		   		}
			 }
		   }
#endif
	          DSAState++; 
	          DSA_Timer=0;
//	          goto DSA_Loop;
//	          break;
	     case DSA_Ack:	      
#ifdef DSA_DEBUG_REV
		   sys_printf(" DSA_Ack ");
#endif			
	          if (DSA_Timer>250) 
		   {
		   	DSAState=DSA_Ideal;
	              break;
		   }
	          SET_ACK_READ;
		  DSA_Delay=0;
		   while ((DSA_Delay<250)&&(GET_ACK))
		   	{
		   	DSA_Delay_us(10);	
		   	DSA_Delay++; 
		   	}
	          SET_DATA_WRITE;
	          SET_DATA_HIGH;
	          //for (DSA_Delay=0;DSA_Delay<15;DSA_Delay++);
	   	   DSA_Delay_us(1);

	          SET_STB_WRITE;
	          SET_STB_LOW;
		   DSA_Delay_us(6);
			  
	          DSA_Timer=0;
	          DSAState++; 
	          goto DSA_Loop;
	          break;
	    case DSA_Ack2:      
#ifdef DSA_DEBUG_REV
		   sys_printf(" DSA_Ack2 ");
#endif			
	    	  if (DSA_Timer>250) 
	         {
	         	DSAState=DSA_Ideal;
	              break;
		  }
              	DSA_Delay=0;       
	         	while ((DSA_Delay<250)&&(!GET_ACK))
		   	{
		   	DSA_Delay_us(10);	
		   	DSA_Delay++; 
		   	}
	          SET_DATA_READ;
 	          SET_STB_READ;
 	          SET_ACK_READ;
	          DSAState=DSA_Ideal;
	          break;	          	          	     
        default:
	          DSAState=DSA_Ideal;
	          break;	          	          	     
        }
}
Exemplo n.º 27
0
/*----------------------------------------------------------------------------*/
void ap_handle_hotkey(u8 key)
{
    u8 res;
    switch (key)
    {
    case MSG_POWER_DOWN:

		if(sys_pwr_flag==0){
			sys_pwr_flag =1;
			sys_mute_flag =1;
        		dac_mute_control(sys_mute_flag,1);					//调节音量时,自动UNMUTE
			work_mode =  IDLE_MODE;		
	        	put_msg_lifo(MSG_CHANGE_WORK_MODE);
		}
		else{

			sys_mute_flag =0;
        		//dac_mute_control(sys_mute_flag,1);					//调节音量时,自动UNMUTE
			sys_pwr_flag =0;
			//work_mode =  IDLE_MODE;
		}



		break;
		
    case MSG_MUTE_UNMUTE:

		sys_mute_flag=~sys_mute_flag;
		//dac_mute_toggle();		
        	dac_mute_control(sys_mute_flag,1);					//调节音量时,自动UNMUTE

		break;		    
#if 1   
    case MSG_MUSIC_PREV_FILE:												//选择上一个文件进行播放
    case MSG_MUSIC_FR:											//启动快退
	      	if ((disp_scenario == DISP_RTC_SCEN)&&(rtc_setting_flag!=0))
            	{
                	rtc_set_cnt=30;
                	curr_time_minus();
                	write_rtc(&curr_time);
                	//write_next_alm_sec();
                	disp_port(MENU_RTC);
            	}
    		break;
    case MSG_MUSIC_NEXT_FILE:												//选择下一个文件进行播放
    case MSG_MUSIC_FF:											//启动快退

	      	if ((disp_scenario == DISP_RTC_SCEN)&&(rtc_setting_flag!=0))
            	{
                	rtc_set_cnt=30;
                	curr_time_plus();
                	write_rtc(&curr_time);
                	//write_next_alm_sec();
                	disp_port(MENU_RTC);
            	}
		break;
    case MSG_NEXT_WORKMODE:
		
		//set_brightness_all_on();
		if(work_mode==FM_RADIO_MODE)break;
		
		if(rtc_setting_flag!=0){

			rtc_coordinate++;
                	rtc_set_cnt=30;

			if(rtc_coordinate>4){
				rtc_coordinate = 3;
				rtc_setting_flag = 0x00;
			}
			break;
		}
		
		if(disp_scenario == DISP_NORMAL){

			    	input_number_en = 0;									//允许数字输入功能
				disp_scenario = DISP_RTC_SCEN;
				rtc_disp_hdlr();
		}
		else{

			if(device_online==0)break;
		    	input_number_en = 1;									//允许数字输入功能
			disp_scenario = DISP_NORMAL;
	              disp_port(MENU_MUSIC_MAIN);
		}
		break;    
		
    case MSG_TIME_SETTING:
	       //set_brightness_all_on();
		if(disp_scenario == DISP_RTC_SCEN){

	             	rtc_set_cnt=30;				
			rtc_setting_flag = 0x01;
			rtc_coordinate = 3;
		}
	break;
    case MSG_USB_DISK_OUT:
    case MSG_SDMMC_OUT:
        if((RECODE_WORKING == encode_status)||(RECODE_PAUSE == encode_status))
        {	
        
#ifdef AUTO_PLAY_RADIO_REC_FILE
		auto_play_radio_rec=0;
#endif
		rec_device_out = 1;
		api_stop_encode();
            	if(work_mode == FM_RADIO_MODE){
			main_menu = MENU_FM_MAIN;//
			disp_port(MENU_FM_MAIN);
            		break;
	     	}
        } 
#ifndef LCD_BACK_LIGHT_DUMMY						
        set_brightness_all_on();
#endif
        if((!device_check()) && (REC_MIC_MODE == work_mode))
        {
             put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN);
             break;   
        }

	    if(MUSIC_MODE != work_mode)
			break;
        //put_msg_lifo(MSG_DEVICE_REMOVED);
        disk_remove_deal_for_music();
        break;
#endif
#if USB_DEVICE_ENABLE
    case MSG_USB_PC_IN:
        break_encode();
        set_brightness_all_on();
        device_check();
        work_mode = USB_DEVICE_MODE;
        put_msg_lifo(MSG_CHANGE_WORK_MODE);
        break;

    case MSG_USB_PC_OUT:
        set_brightness_all_on();
        break;
#endif

    case MSG_SDMMC_IN :
#ifndef LCD_BACK_LIGHT_DUMMY						
        set_brightness_all_on();
#endif
	 device_check();
        if((RECODE_WORKING == encode_status)||(RECODE_PAUSE == encode_status))
        {	
            break;
        } 
        
        break_encode();

	disp_scenario = DISP_NORMAL;

#if USB_DEVICE_ENABLE
        if (work_mode == USB_DEVICE_MODE)
            break;
#endif

		given_device = read_info(MEM_ACTIVE_DEV);

		if(given_device != DEVICE_SDMMC0_REC)
		//	given_device = DEVICE_SDMMC0_REC;
		//else
			given_device = DEVICE_SDMMC0;

        given_file_method = PLAY_BREAK_POINT;
        put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN);
        break;

    case MSG_USB_DISK_IN  :
#ifndef LCD_BACK_LIGHT_DUMMY						
        set_brightness_all_on();
#endif
		device_check();
        if((RECODE_WORKING == encode_status)||(RECODE_PAUSE == encode_status))
        {
            break;
        }
        break_encode();

	disp_scenario = DISP_NORMAL;
	   
		given_device = read_info(MEM_ACTIVE_DEV);

		if(given_device != DEVICE_UDISK_REC)
		//	given_device = DEVICE_UDISK_REC;
		//else
	    	given_device = DEVICE_UDISK;

        given_file_method = PLAY_BREAK_POINT;      
        put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN);
        break;
		
#if 0
    case MSG_NEXT_WORKMODE:

#if 0//def K820_LHD_820_REC_V001
	    if(MUSIC_MODE != work_mode)
			break;
	 if(device_check()>0){
	 
	        given_device = DEVICE_AUTO_NEXT;
	        given_file_method = PLAY_BREAK_POINT;
	        put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
	        backup_music_point();
	 }
	 else{
    		//flashled(3);
              work_mode =IDLE_MODE;
        	put_msg_lifo(MSG_CHANGE_WORK_MODE);		
	 }
	break;

#endif

	break_encode();
        work_mode++;
        if (work_mode > MAX_WORK_MODE)
            work_mode = MUSIC_MODE;

        put_msg_lifo(MSG_CHANGE_WORK_MODE);
        break;
#endif		
#if 1
    case MSG_VOL_UP:
        if(vol_change_en==0)
            break;
        dac_mute_control(0,1);					//调节音量时,自动UNMUTE
        main_vol_set(0, CHANGE_VOL_INC);
        //write_info(MEM_VOL, main_vol_set(0, CHANGE_VOL_INC));
        disp_port(MENU_MAIN_VOL);
        break;

    case MSG_VOL_DOWN:
        if(vol_change_en==0)
            break;
        dac_mute_control(0,1);					//调节音量时,自动UNMUTE
        main_vol_set(0, CHANGE_VOL_DEC);
        //write_info(MEM_VOL, main_vol_set(0, CHANGE_VOL_DEC));
        disp_port(MENU_MAIN_VOL);
        break;
#endif
    case MSG_0:
    case MSG_1:
    case MSG_2:
    case MSG_3:
    case MSG_4:
    case MSG_5:
    case MSG_6:
    case MSG_7:
    case MSG_8:
    case MSG_9:
        if (!input_number_en)
            break;
		
	 if((input_number)>6553){
		input_number = 0x0000;			
	 }
        if (input_number > 9999)
            input_number = 0;

           input_number = input_number * 10 + key;
        disp_port(MENU_INPUT_NUMBER);
        break;
//2  REC FSM BEGIN
    case MSG_REC_KEY:	  //录音开始和结束

	  if(work_mode ==IDLE_MODE)
	  	break;
	  	
        if(RECODE_PLAY >= encode_status)
        {
            put_msg_lifo(MSG_REC_FIND);
#ifdef AUTO_PLAY_RADIO_REC_FILE
	    if(work_mode == FM_RADIO_MODE){
		auto_play_radio_rec=1;
	    }
#endif
			
        }
        else
        {
#ifdef AUTO_PLAY_RADIO_REC_FILE
		//auto_play_radio_rec=0;
#endif
            put_msg_lifo(MSG_REC_STOP);
        }
        break;

	case MSG_MUSIC_PP:      //录音暂停和继续录音
	//case MSG_REC_PP:      //录音暂停和继续录音

        if(RECODE_WORKING == encode_status)
        {
            put_msg_lifo(MSG_REC_PAUSE);
        }
        else if(RECODE_PAUSE == encode_status)
        {

            put_msg_lifo(MSG_REC_CONTINUE);
        }
        break;

    case MSG_ENCODE_END:   //设备写err  或 设备满
		if(rec_device_out)		//录音时活动设备拔出,在设备拔出那里处理,在此不做处理
		{
			rec_device_out =0;
			break;
		}

        api_stop_encode();		//停止录音
		put_msg_lifo(MSG_REC_PLAY);
		break;

	 case MSG_ENCODE_FAT_FULL:  //建文件时
		api_stop_encode();		//停止录音
        if((!device_check())&& (REC_MIC_MODE == work_mode))
        {
             put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN);
             break;   
        }
       // break_encode();

        disp_port(main_menu);
        break;
////////////////录音涉及的各种状态
    case MSG_REC_FIND:
//        if(RECODE_PLAY >= encode_status)
//        {
//            break;
//        }
	if(get_device_online_status()==0){
		disp_port(MENU_NODEVICE);
		break;
	}	
        encode_status = RECODE_INIT;
        if(MUSIC_MODE == work_mode)
        {
            encode_device = device_active;	 //设置录音存储设备
            work_mode = REC_MIC_MODE;
            put_msg_lifo(MSG_CHANGE_WORK_MODE);
            break;
        }
	 else if(REC_MIC_MODE == work_mode){
		given_device = encode_device;
	 }
	 else //if((MUSIC_MODE != work_mode))
        {
            if (given_device == NO_DEVICE)
            {
                given_device = read_info(MEM_ACTIVE_DEV);
            }
        }
       // if( ((given_device & (~VIRTUAL_DEVICE))  != DEVICE_SDMMC0) && ((given_device & (~VIRTUAL_DEVICE)) != DEVICE_UDISK))
        {
            //given_device = DEVICE_SDMMC0;
        }
        SYSTEM_CLK_DIV2();

        put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
        break;
    case MSG_REC_START:		//开始录音

	 rec_device_out = 0;
	 rec_sys_set(0);  //0:24M   1:48M
        init_rec_name();
        device_active |= VIRTUAL_DEVICE;
        encode_device = device_active;	 //设置录音存储设备
        write_file_info(0);
        SYSTEM_CLK_DIV2();

        set_rec_channel(encode_channel); //设置录音通道
        set_rec_vol(encode_vol);		 //设置录音音量
        if(REC_MIC == encode_channel)
        {
            set_rec_track(TRACK_LEFT);
        }
        else
        {
            set_rec_track(TRACK_ALL);
        }
        /**/
        
        CLKGAT |= MP3CLK;// | SPIURCLK;
        CLKCON0 |= DACCLK;
        if(DEVICE_SDMMC0 == (device_active & (~VIRTUAL_DEVICE)))
        {
            CLKGAT |= USBCLK;
        }
        else if(DEVICE_UDISK == (device_active & (~VIRTUAL_DEVICE)))
        {
            CLKGAT |= SDCLK;
        }

        if(1 != start_encode(IS_MP3))			 //开始录音
		{
			put_msg_lifo(MSG_ENCODE_FAT_FULL);
			break;
		}
        /*
        if(REC_MIC_MODE == work_mode)
        {
    		while(!((cmd_ctl_rec(REC_NO_OPT,0)) &  FRIST_ADC_PACKET)) //采数据前的处理
    		{
    
    		}
            delay_10ms(50);//抛弃半秒的数据
        }
		cmd_ctl_rec(ENABLE_REC_DATA,ENABLE_REC_BIT);
        */
        encode_status = RECODE_WORKING;
#if FM_MODULE 
	//	if(FM_RADIO_MODE != work_mode)
#endif
		{
		 	main_menu = MENU_RECWORKING;//
		}
		disp_port(main_menu);
        break;
    case MSG_REC_STOP:      //停止录音
        api_stop_encode();		//停止录音
        if(work_mode==REC_MIC_MODE){
	 	put_msg_lifo(MSG_REC_PLAY);
        }
#ifdef REC_PLAY_KEY_BREAK_POINT
	rec_pley_bp_flag=0;
#endif		
        break;
    case MSG_REC_PAUSE:     //暂停录音
		encode_status = RECODE_PAUSE;
	
#if FM_MODULE 
		if(FM_RADIO_MODE == work_mode)
			disp_port(MENU_FM_MAIN);
		else
#endif
		{
			//main_menu = MENU_REC_PAUSE;	
		  	disp_port(MENU_RECWORKING);
		}
		 		
        pause_encode();
        break;
    case MSG_REC_CONTINUE:  //暂停录音之后继续录音
		encode_status = RECODE_WORKING;
	
#if FM_MODULE 
		if(FM_RADIO_MODE == work_mode)
			disp_port(MENU_FM_MAIN);
		else
#endif
		{
		 	main_menu = MENU_RECWORKING;//
		    disp_port(MENU_RECWORKING);
		}
			
        continue_encode();
        break;
    case MSG_REC_PLAY:     //播放最后的录音文件

	  if(work_mode ==IDLE_MODE)
	  	break;

#ifdef REC_PLAY_KEY_BREAK_POINT
	rec_pley_bp_flag=~rec_pley_bp_flag;
	if(rec_pley_bp_flag){
		last_play_index =  given_file_number;
	}
	else{
		given_file_number=last_play_index;
              put_msg_lifo(MSG_MUSIC_PLAY_NEW_FILE);
		break;
	}
#endif
	  
        encode_status = RECODE_PLAY;
        given_device = encode_device & (~VIRTUAL_DEVICE);

        if( (given_device != DEVICE_SDMMC0) && (given_device != DEVICE_UDISK))
        {
            given_device = DEVICE_SDMMC0;
        }
        given_device |= VIRTUAL_DEVICE;
        if((MUSIC_MODE != work_mode))
        {
            put_msg_lifo(MSG_MUSIC_NEW_DEVICE_IN);
        }
        else
        {
            put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
        }
        break;

    case MSG_MUSIC_SELECT_NEW_DEVICE:					        //重新选择设备

        res = find_device(given_device);

        if ((res == DEV_INIT_ERR) ||
                (res == NO_DEFINE_DEV))                    //指定的设备不在线,或初始化失败
        {
		
            given_device = DEVICE_AUTO_NEXT;			   //自动选择下一个设备
            put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
            break;
        }
        else if ((res == NO_EFFECTIVE_DEV) ||
                 (res == NO_DEV_ONLINE))                    //无可播放的设备
        {		
            if(RECODE_STOP != encode_status)
            {
                	encode_status = RECODE_STOP;
			if(REC_MIC_MODE == work_mode)
			{
				put_msg_lifo(MSG_NEXT_WORKMODE);
			}
            }
            else
            {	
                //put_msg_lifo(MSG_NEXT_WORKMODE);
                	if(disp_scenario == DISP_NORMAL){

#ifdef PLAY_STATUS_LED_FUNC
			    	set_play_status_led_spark(PLED_ON);
#endif	
				disp_scenario = DISP_RTC_SCEN;
				rtc_disp_hdlr();
			}
            }
            break;
        }
        else
        {		
            if(RECODE_PLAY < encode_status)
            {
                put_msg_lifo(MSG_REC_START);
            }
            else
            {
                if(RECODE_PLAY == encode_status)  //4去播刚录好的文件
                {
                    encode_status = RECODE_STOP;
#if VIRTUAL_ENABLE
#if 1//defined(K820_LHD_820_REC_V001)
                    given_file_number = logic_fileTotal;
#else
			given_file_number = encode_filenum;
#endif
#else
                    given_file_number = logic_fileTotal;
                    //given_file_number = encode_filenum + encode_fristfile -1; 
#endif
                    put_msg_lifo(MSG_MUSIC_PLAY_NEW_FILE);
                }
                else
                {
                    put_msg_lifo(MSG_MUSIC_SELECT_NEW_FILE);		//找到可用设备
                }
            }
        }
        break;
//2  REC FSM END



    }
}
Exemplo n.º 28
0
void idle_mode(void)
{
    u8 key;
    //dac_out_select(DAC_MUSIC, 0);
    //clear_all_event();
#ifdef UART_ENABLE
	sys_printf(" SYS GO IN IDLE MODE");
#endif
    
#ifdef PWR_CTRL_IN_IDLE_MODE

#if defined(PWR_CTRL_WKUP)
	wkup_pin_ctrl(0);
#else
	PWR_CTRL_GPIO_INIT();
	PWR_CTRL_DIS();
#endif

#endif


    flush_all_msg();


    KT_AMFMStandby();

    sys_sleep_mode();
	
#ifdef RTC_DISP_IN_IDLE_MODE
	disp_scenario = DISP_RTC_SCEN;
	Disp_Con(DISP_RTC);
#else
    Disp_Con(DISP_POWER_OFF);
#endif

#if 0
        alm_flag = 1;
	 put_msg_lifo(INFO_ALM_BELL);
#endif	 

#ifdef ADKEY_SELECT_MODE
   mode_switch_protect_bit=0;
#endif


   while (1)
    {
	key = get_msg();
	//suspend_sdmmc();

#ifndef RTC_DISP_IN_IDLE_MODE
	if(sys_pwr_flag){
		if(key!=(INFO_POWER | KEY_SHORT_UP)){
			key = NO_KEY;
		}
	}
#endif	
        switch (key)
        {
#if 0        
	       case INFO_PLAY| KEY_SHORT_UP :	

		        alm_flag = 1;
	 put_msg_lifo(INFO_ALM_BELL);
	 	break;
#endif		
	       case INFO_POWER | KEY_SHORT_UP :	
			if(sys_pwr_flag){

				//sys_mute_flag =0;
	        		dac_mute_control(0,1);					//调节音量时,自动UNMUTE
				sys_pwr_flag =0;
				//work_mode =  SYS_IDLE;
			}
			break;
	       case INFO_HALF_SECOND :
#ifdef RTC_DISP_IN_IDLE_MODE
#if defined(USE_BAT_MANAGEMENT)
	     		bmt_hdlr();
#endif
            	    set_brightness_fade_out();

		     rtc_setting_exit();

		    if(disp_scenario == DISP_RTC_SCEN){

				if(curr_menu != DISP_RTC){
	            			return_cnt++;
	            			if (RETURN_TIME == return_cnt){
						rtc_disp_hdlr();
					}
					break;
				}
				rtc_disp_hdlr();
				break;
		     }
#ifdef USE_RTC_ALARM_FUNCTION
		    else if(disp_scenario == DISP_ALM_SCEN){

				rtc_disp_hdlr();
		     }
#endif			
#endif			
			break;
			
        	case INFO_NEXT_SYS_MODE:
            		return;
#ifdef USE_RTC_ALARM_FUNCTION
    		case INFO_ALM_BELL:
		    	sys_restore_mode();
			alm_bell_mode();
		    	//sys_sleep_mode();
#ifdef ALARM_USE_MULTI_SOURCE_FUNC
			if(get_cur_select_func()==SYS_MP3DECODE_USB){

				if(get_device_online_status()>0){
					alarm_power_on_protect =1;
					work_mode = SYS_MP3DECODE_USB;
    					flush_all_msg();					
		 			put_msg_lifo(INFO_NEXT_SYS_MODE);
					break;
				}
			}
			else if(get_cur_select_func()==SYS_FMREV){
				
				work_mode = SYS_FMREV;
				alarm_power_on_protect =1;	
    				flush_all_msg();									
		 		put_msg_lifo(INFO_NEXT_SYS_MODE);
				break;
			}
#endif			
			break;
#endif
    		case MSG_USB_DISK_IN  :
    		case MSG_SDMMC_IN :
	 		break;
	        default:
	            ap_handle_hotkey(key);        
	            break;
        }
    }
}
Exemplo n.º 29
0
void idle_mode(void)
{
    u8 key;
    input_number_en = 0;

    if(mic_plugged){	

		mic_counter=0;
    		set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量
		
		dac_out_select(DAC_MUSIC | DAC_KALAOK, 0);
		kala_dac();  
		set_rec_vol(7); 
		P3HD |=(1<<6);
		dsp_kalaok_channel();
		
    		vol_change_en=1;
    }
    else{

    	vol_change_en=0;
   }

 disp_port(MENU_NODEVICE);			

   while (1)
    {
        key = app_get_msg();

        switch (key)
        {
        case MSG_NO_DEVICE:
	    clear_all_event();
	    flush_low_msg();
	    disp_port(MENU_NODEVICE);			
		break;
		
    	case MSG_MIC_OUT:
		if(mic_plugged){	
			work_mode =  last_work_mode;
			mic_plugged = 0;
			return;
	      	 	//put_msg_lifo(MSG_CHANGE_WORK_MODE);		
		}
		break;
        case MSG_MUSIC_NEW_DEVICE_IN:							//有新设备接入	
        case MSG_CHANGE_WORK_MODE:
		break;
            work_mode = MUSIC_MODE;
            return;

        case MSG_HALF_SECOND:
////////////////////////////////////////////////////////////
//显示界面的切换
#if 0            
            set_brightness_fade_out();
            if (main_menu_conter < SUB_MENU_TIME)
            {
                main_menu_conter++;
            }
            else if (cur_menu != main_menu)
            {
                cur_menu = main_menu;
                disp_port(cur_menu);
            }
#endif

            break;
#if RTC_ENABLE
        case MSG_ALM_ON:
            write_next_alm_sec();
            work_mode = RTC_MODE;
            put_msg_lifo(MSG_CHANGE_WORK_MODE);
            break;
#endif
        default:

            ap_handle_hotkey(key);        
            break;
        }
    }

}
Exemplo n.º 30
0
void music_play(void)
{
    u8 key;
    u8 file_end_time;

#ifdef ADKEY_SELECT_MODE
    mode_switch_protect_bit=0;
#endif	
    while (1)
    {	   		
		if (play_status == MUSIC_PLAY)
		{
			dac_out_select(DAC_DECODE);
		}
		//suspend_sdmmc();

		key = get_msg();
		
#ifdef USE_USB_PROG_PLAY_MODE
		if(usb_play_prog_mode){
			
			usb_prog_hdlr(key);
			if((key==INFO_HALF_SECOND)||(key==(INFO_MODE | KEY_SHORT_UP))||(key==(INFO_NEXT_FIL | KEY_SHORT_UP))||(key==(INFO_PREV_FIL | KEY_SHORT_UP))){
				key = 0xFF;
			}		
		}
#endif	

        switch (key)
        {
        case INFO_NEXT_SYS_MODE:
		return;
		
        case INIT_PLAY:                                 //开始解码播放
            	file_end_time = 0;
            	stop_decode();
		playpoint_flag = 0;
              if(playpoint_filenum)
		{
		    playpoint_flag = 1;
			given_file_number = playpoint_filenum;
		}
#if FILE_ENCRYPTION
            password_start(0);
#endif
            	if (!fs_getfile_bynumber(given_file_number))
            	{
			put_msg_lifo(INFO_NEXT_FIL | KEY_SHORT_UP);
                	break;
            	}

            	if (!start_decode())
            	{
			put_msg_lifo(INFO_NEXT_FIL | KEY_SHORT_UP);
            	}	
#ifdef USE_USB_PROG_PLAY_MODE
		if(usb_prog_icon_bit){
			usb_prog_play=1;
		}
#endif
				
            	break;

        case SEL_GIVEN_DEVICE_GIVEN_FILE:              ///<获取指定设备的指定文件
		get_music_file2();
            	break;
        case INFO_STOP| KEY_SHORT_UP :
#ifdef USE_USB_PROG_PLAY_MODE

		if(usb_prog_play){
				
				usb_prog_play=0;
				usb_play_prog_index =0;
				
				flush_all_msg();
				stop_decode();
				Disp_Con(DISP_STOP);
   			 //printf(" ---> usb_prog_icon_bit	%x \r\n",(u16)usb_prog_icon_bit);
				play_mode  =REPEAT_OFF;
				
				break;
		}
		usb_prog_mode_cls();
#endif

		if((get_device_online_status()==0)){
			break;
		}

		Mute_Ext_PA(MUTE);            
		disp_play_filenum_timer=6;
		play_mode  =REPEAT_OFF;

		flush_all_msg();
		stop_decode();
		Disp_Con(DISP_STOP);			
		break;
        case INFO_NEXT_FIL | KEY_SHORT_UP:
			
#ifdef USE_FOLDER_SELECT_FUNC
		if(folder_select){
			
			select_folder_file(FIND_NEXT_DIR);
		       Disp_Con(DISP_DIR);	
			break;			   
		}
#endif
		disp_play_filenum_timer=10;

		get_music_file1(GET_NEXT_FILE);
            	break;

        case INFO_PREV_FIL | KEY_SHORT_UP:
			
#ifdef USE_FOLDER_SELECT_FUNC
		if(folder_select){
			
			select_folder_file(FIND_PREV_DIR);
		       Disp_Con(DISP_DIR);	
			break;
		}
#endif		

		if(rew_play_timer>0){

			rew_play_timer=0;
                	put_msg_lifo(INIT_PLAY);
		}
		else
		{
			disp_play_filenum_timer=10;
			get_music_file1(GET_PREV_FILE);
		}
            	break;
        case INFO_NEXT_FIL | KEY_HOLD:
			
		if(play_status)
		{
			ff_fr_step = FAST_FARWORD_STEP;
			play_status = MUSIC_FF_FR;
#if (FF_FR_MUSIC)
			if(0 == decode_cmd)
#endif
			{			
				analog_vol_set(0);
				decode_cmd = 0xf0;
			}
            	}
		break;
        case INFO_PREV_FIL | KEY_HOLD:
	       if(music_type == 2)    //wav文件不支持断点记忆,故可以快退
	       { 
	             playpoint_flag =0;
	       }
			
		if(!playpoint_flag) 				//读取断点信息后不支持快退
		{
			if(play_status)
			{
				ff_fr_step = -FAST_FARWORD_STEP;
				play_status = MUSIC_FF_FR;
#if (FF_FR_MUSIC)
				if(0 == decode_cmd)
#endif					
				{
					analog_vol_set(0);
					decode_cmd = 0xf1;
				}
			}    
		}
		break;

        case DECODE_MSG_DISK_ERR:
#ifdef MP3_UART_ENABLE
			sys_printf(" DECODE_MSG_DISK_ERR");
#endif
			
		get_music_file3();
            	break;

        case DECODE_MSG_FILE_END:               ////*将文件结束的消息放到半秒消息中处理,防止单曲循环遇到错误歌曲无法手动切换下一首,或遇到错误歌曲无法到上一首,每首歌曲至少播放约5S*/
		if (get_music_play_time() < 5)
		{
			file_end_time = 7 - (u8)get_music_play_time();
            	}
		else
		{	

#ifdef MP3_UART_ENABLE
			sys_printf(" DECODE_MSG_FILE_END");
#endif
		
			get_music_file1(GET_PLAY_FILE);
		}
		break;
    	case MSG_USB_DISK_IN  :
		Disp_Con(DISP_SCAN_DISK);	
        	disp_scenario = DISP_NORMAL;
	 	//Add_Func_To_List(USB_DEV);
        	given_device = BIT(USB_DISK);
        	put_msg_lifo(SEL_GIVEN_DEVICE_GIVEN_FILE);	
	break;   
	
        case INFO_NEXTMODE:                     ///<下一个模式
		//work_mode = SYS_IDLE;
            //return;
	        stop_decode();
#ifdef NO_DEV_SHOW_NO_DEV
#ifdef USE_USB_PROG_PLAY_MODE
		usb_prog_mode_cls();
#endif
		folder_select=0;
		folder_mode_select=0;
		Disp_Con(DISP_NODEVICE);
#else
             	Disp_Con(DISP_RTC);
		disp_scenario = DISP_RTC_SCEN;
#endif		
		break;
        case INFO_PLAY | KEY_SHORT_UP :
			
#if defined(USE_TIMER_POWER_OFF_FUNC)
		if(timer_setting_enable){
			timer_pwr_setting();
			break;
		}
#endif		
		if((get_device_online_status()&0x03)==0){
			break;
	     }		
            if (DISP_DWORD_NUMBER == curr_menu)
            {
                	Disp_Con(DISP_NULL);
			put_msg_fifo(INFO_PICK_SONG | KEY_SHORT_UP);
                	break;
            }
			
            if (play_status == MUSIC_PAUSE)
            {
			Mute_Ext_PA(UNMUTE);
			play_status = MUSIC_PLAY;
			Disp_Con(DISP_PLAY);
                	mad_control(MAD_PLAY,0);
			if(music_type == 1)
				enable_decodeint();
			if(music_type == 2)
				enable_softint();
            }
            else if (play_status == MUSIC_PLAY)
            {
			Mute_Ext_PA(MUTE);            
			play_status = MUSIC_PAUSE;
			if(music_type == 1)
				disable_decodeint();
			Disp_Con(DISP_PAUSE);
                	mad_control(MAD_PAUSE,0);
                	read_usb_remain_data();
			write_playtime(&playpoint_time);	   	//暂停时记忆断点信息(EEPROM)
            }
            else if (play_status == MUSIC_STOP){

			disp_play_filenum_timer=10;
			
#ifdef USE_USB_PROG_PLAY_MODE
			if(usb_play_prog_mode){

				if(usb_prog_tab[0]!=0){
					given_file_number =usb_prog_tab[0];

				}
				else{
					usb_prog_mode_cls();
				}
				usb_play_prog_mode=0;
			}				
#endif
                	put_msg_lifo(INIT_PLAY);
			//Mute_Ext_PA(UNMUTE);

	     }
            break;

        case INFO_PICK_SONG | KEY_SHORT_UP :
            given_file_number = (u16)cfilenum;           
            cfilenum = 0;
	     if ((given_file_number > 0) && (given_file_number <= fs_msg.fileTotal))
            {
                	put_msg_lifo(INIT_PLAY);
                	break;
            }
	     Disp_Con(DISP_ERROR);
            break;
       case INFO_HALF_SECOND :
	   	
#if ((USE_DEVICE == MEMORY_STYLE)&&(FAT_MEMORY))      
            updata_fat_memory();
#endif

#if defined(USE_BAT_MANAGEMENT)
	     bmt_hdlr();
#endif
#ifdef USE_USB_ERP_2_HDLR
	     usb_erp_2_timer_hdlr();
#endif

#if defined(USE_TIMER_POWER_OFF_FUNC)
	       timer_pwr_off_hdlr();
#endif

            set_brightness_fade_out();
	     update_playpoint(&playpoint_time);		//半秒更新断点进度,不写入存储器

#if 1//defined(USE_FOLDER_SELECT_FUNC)
		if(folder_select){
           	 	return_cnt++;
            		if (RETURN_TIME == return_cnt){
				return_cnt=4;
				folder_select=0;
			}
			else{
				break;
			}
		}
#endif		
	    if(adkey_detect){
	   	    adkey_detect=0;
	   	    set_sys_vol(my_music_vol);
	    }

	     if(disp_play_filenum_timer>0)disp_play_filenum_timer--;
		 
            if (file_end_time)
            {
			file_end_time--;
                	if (file_end_time == 0)
			{
                    		get_music_file1(GET_PLAY_FILE);		
			}
            }
#if FF_FR_MUSIC	   ///在每一次快进完成之后,播出半秒左右的声音
	     if ((2 == decode_cmd)&&(play_status == MUSIC_FF_FR))
	     {
			decode_cmd = 0;
			set_eq(eq_mode);
			play_status = MUSIC_PLAY;
	     }

#else
            if ((decode_cmd != 0) && (decode_cmd <= 2))		
            {
                	decode_cmd--;
			set_eq(eq_mode);
                	if (decode_cmd == 0) 					///<快进快退结束后1S,打开主音量
		  	{
				play_status = MUSIC_PLAY;
		   	}
            }
#endif
#ifdef RTC_DISP_IN_IDLE_MODE

	    if(disp_scenario == DISP_RTC_SCEN){

		    	rtc_setting_exit();

			if(curr_menu != DISP_RTC){
            			return_cnt++;
            			if (RETURN_TIME == return_cnt){
					rtc_disp_hdlr();
				}
				break;
			}
			rtc_disp_hdlr();
			break;
	     }
#endif	

#ifdef NO_DEV_SHOW_NO_DEV
		if((get_device_online_status()&0x03)==0){
			Disp_Con(DISP_NODEVICE);
			break;
		}
#endif            

            if (DISP_PLAY == curr_menu)
            {
			rew_play_timer=1;				            
                	disp_file_time();
            }

            return_cnt++;
            if (RETURN_TIME == return_cnt)
            {

#if defined(USE_TIMER_POWER_OFF_FUNC)	
			timer_setting_enable=0;
#endif

                if (DISP_DWORD_NUMBER == curr_menu)
                {
			Disp_Con(DISP_NULL);
                    	put_msg_fifo(INFO_PICK_SONG | KEY_SHORT_UP);
                }
                else
                {
                    if (play_status== MUSIC_PAUSE){
                        if (curr_menu != DISP_PAUSE)
                            Disp_Con(DISP_PAUSE);
                    }
                    else if(play_status== MUSIC_PLAY){
                        if (curr_menu != DISP_PLAY){

				if(disp_play_filenum_timer==0)
                            Disp_Con(DISP_PLAY);
				else
                            Disp_Con(curr_menu);
			   }
                    }
		      else if(play_status== MUSIC_STOP){

                        if (curr_menu != DISP_STOP)
                            Disp_Con(DISP_STOP);
			  }
                }
            }
#if 1//( USE_RTCRAM == MEMORY_STYLE  )
			save_playpoint(2);	   	//2*0.5 = 1s 1s记录一次播放进度,
#endif
		break;

	 case INFO_MODE | KEY_LONG:

		if((get_device_online_status()==0)){
			break;
		}
#if 0		
#ifdef USE_USB_PROG_PLAY_MODE
		if(play_status == MUSIC_STOP){
			usb_prog_play_init();
			break;
		}
#endif
#endif
		folder_mode_select=~folder_mode_select;
		folder_select=folder_mode_select;
		if(folder_mode_select){
#ifdef USE_USB_PROG_PLAY_MODE
			usb_prog_mode_cls();
#endif		
		       Disp_Con(DISP_DIR);	
		}
		else{
		       Disp_Con(DISP_PLAY);	
		}
		break;
	 case INFO_MODE | KEY_SHORT_UP:

		if((get_device_online_status()==0)){
			break;
		}
#ifdef USE_USB_PROG_PLAY_MODE
		if(play_status == MUSIC_STOP){
			usb_prog_play_init();
			break;
		}
#endif
        case INFO_PLAY_MODE :

		//if(usb_play_prog_mode||usb_prog_icon_bit){
		//	 break;
		//}			
		
		play_mode++;
            	if (play_mode > REPEAT_END)
            	{
                	play_mode = REPEAT_HEAD;
            	}
#ifndef NO_PLAY_MODE_STR_DISP				
            write_info(MEM_PLAY_MODE,play_mode);
            Disp_Con(DISP_PLAYMODE);
#endif			
            break;
			
	    case INFO_EQ_UP | KEY_SHORT_UP :
               
	        eq_mode++;
	        if (eq_mode > CLASSIC)
	        {
	            eq_mode = NORMAL;
	        }
	        write_info(MEM_EQ_MODE,eq_mode);
	        set_eq(eq_mode);
	        Disp_Con(DISP_EQ);
	        break;
#if 0			
    	case INFO_MODE | KEY_LONG:
		if(disp_scenario == DISP_RTC_SCEN){

			if(rtc_setting==0){
				rtc_setting = 0x01;
				rtc_set = 3;
	                	rtc_set_cnt=30;
			}
		}			
		break;
#endif		
#if RTC_ENABLE 
	 case INFO_ALM_BELL :					///<闹钟响消息,进入闹钟循环
            	if (play_status)
            	{
				/**/
			if(music_type == 1)
				disable_decodeint();
                
			mad_control(MAD_PAUSE,0);
                	read_usb_remain_data();
            	}
            
		if(alm_bell_mode())
		{
			if (play_status)
		       {
	              	mad_control(MAD_PLAY,0);
				if(music_type == 1)
					enable_decodeint();
				if(music_type == 2)
					enable_softint();			
	            	}
			return;	
		}

            	if (play_status)
            	{
                	mad_control(MAD_PLAY,0);
			if(music_type == 1)
				enable_decodeint();
			if(music_type == 2)
				enable_softint();			
            	}
#ifdef PWR_CTRL_IN_IDLE_MODE

#if defined(PWR_CTRL_WKUP)
		wkup_pin_ctrl(1);
#else
		PWR_CTRL_GPIO_INIT();
		PWR_CTRL_EN();
#endif

#endif
		break;
#endif			
        default :
_HOT_KEY_HDLR:		
            if (!ap_handle_hotkey(key))
                return;
            if ((!play_status) && (!device_check()))
            {
		if(disp_scenario == DISP_NORMAL){

		  	stop_decode();
	             	Disp_Con(DISP_RTC);
			disp_scenario = DISP_RTC_SCEN;
		  }
                play_status = MUSIC_PLAY;
                //return;
            }
        }
    }
}