예제 #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);
    }
}
예제 #2
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);	   
		}
	}
}
예제 #3
0
/*----------------------------------------------------------------------------*/
void aux_function(void)
{
#ifdef USE_LINE_IN_DETECT_FUNC
	    if (!aux_online)
	    {
	     	 Set_Curr_Func(SYS_MP3DECODE_USB);
	        return;
	    }
#endif	
	Mute_Ext_PA(MUTE);

	sysclock_div2(1);
    	flush_low_msg();
    	Disp_Con(DISP_AUX);
	set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL);			//设置AUX模式的音量上限
    	deal_aux();

	Mute_Ext_PA(MUTE);
		
	main_vol_set(0, CHANGE_VOL_NO_MEM);
}
예제 #4
0
void fm_radio(void)
{
#if defined(FM_LINE_IN_SHARE_SAME_CHANNEL)||defined(FM_LINE_IN_ONLY_ONE_MODE_EXIST)
#ifdef USE_LINE_IN_DETECT_FUNC
   if(aux_online){
   	
	Set_Curr_Func(SYS_AUX);
	return;
   }
#endif
#endif

#ifdef NOT_MOUNT_FM_DEV		
       if(get_fm_id() ==0xFFFF){	//NO FM 
		Set_Curr_Func(SYS_IDLE);
		return;
	}
#endif

//     xd_u8 vol_tmp=0;
    PT1 = 1;										//timer1 interrupt 低优先级
    IR_KEY_Detect =0;
#if 1//defined(FM_PLAY_KEY_PAUSE)    
            play_status = MUSIC_PLAY;
#endif

#ifndef DISABLE_P05_OSC_OUTPUT
    fm_osc_output_select(TRUE);
#endif

#if defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
	radio_freq_tune_pop=0;
#endif

#if defined(K202_WEISI_KL202_V001000000000)
    set_led_enable_bit(1);
#endif	
    set_play_flash(LED_FLASH_ON);
#ifdef USE_AMP_MODE_SELECT
	D_CLASS_AMP_GPIO_INIT(); 
	D_CLASS_AMP_LOW();
#endif
    Mute_Ext_PA(MUTE);
    my_main_vol(0);
#if SDMMC_CMD_MODE
	sd_chk_ctl(SET_SD_L_CHK);
#endif
    flush_low_msg();
    sysclock_div2(1);

    init_fm_rev();

#ifdef RADIO_AM_WM_ENABLE
	FMAM_Mode_Switch_Profile(work_mode);
#else
    	enter_fm_rev();  
#endif
    set_fre(frequency,1);

#ifdef DISP_CH_NUM_IN_RADIO_AT_FISRT
    Disp_Con(DISP_CH_NO);
#else
    Disp_Con(DISP_FREQ);
#endif


//    delay_10ms(1);
	
//vol_tmp = my_music_vol;
//    if(vol_tmp>12)my_music_vol = 12;//dac_channel_sel()会用music_vol 打开声音通道

#ifdef SUPPORT_PT2313

    my_main_vol(0);	
    delay_10ms(10);
	
#ifdef FM_PATH_SHARE_SAME_MP3_PT_CHAN

#ifdef EXCHANGE_LINE_IN_CHANNEL
    aux_channel_crosstalk_improve(DAC_AMUX1);//4  P26,P27 FM_IN
#else
    aux_channel_crosstalk_improve(DAC_AMUX0);//4P24,P25 FM_IN	
#endif

    delay_10ms(20);
	
    PT2313_Config(MP3_CHAN,CHAN_ADJ);
#else
    PT2313_Config(FM_CHAN,CHAN_ADJ);
#endif	

#else//  SUPPORT_PT2313

#ifdef FM_BY_PASS
 //   Mute_Ext_PA(UNMUTE); 
    //my_main_vol(my_music_vol);	
    	aux_channel_crosstalk_improve(DAC_AMUX0);//4P24,P25 FM_IN	  
	//dac_out_select(DAC_DECODE);	//4  
	//aux_ch_reg=DAC_AMUX0;

    	main_vol(0);  
   // dac_highz_output_enable();

#else

#ifdef FM_LINE_IN_SHARE_SAME_CHANNEL

#ifdef EXCHANGE_LINE_IN_CHANNEL
    aux_channel_crosstalk_improve(DAC_AMUX0);//4P24,P25 FM_IN	  
#else
    aux_channel_crosstalk_improve(DAC_AMUX1);//4P26,P27 FM_IN
#endif

#else

#ifdef EXCHANGE_LINE_IN_CHANNEL
    aux_channel_crosstalk_improve(DAC_AMUX1);//4P26,P27 FM_IN
#else
    aux_channel_crosstalk_improve(DAC_AMUX0);//4P24,P25 FM_IN	  
#endif

#endif

#endif	// END OF FM_BY_PASS

#endif	// END OF SUPPORT_PT2313

//    my_music_vol =vol_tmp;
	
    my_main_vol(my_music_vol);	
    set_fre(frequency,1);
#ifdef FM_BY_PASS
    my_main_vol(my_music_vol);	// add here for FM volume setting confirm, after setting the freq ,vol may turn on ....
#endif

    set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL);			//设置FM模式的音量上限

    dac_out_select(aux_ch_reg);

    delay_10ms(20);	
    Mute_Ext_PA(UNMUTE);
    fm_rev();
    Mute_Ext_PA(MUTE);
    sys_clock_pll();

    main_vol_set(0, CHANGE_VOL_NO_MEM);
	
    fm_rev_powerdown();

#if defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
	radio_freq_tune_pop=0;
#endif
	
#if SDMMC_CMD_MODE
	sd_chk_ctl(SET_SD_H_CHK);
#endif

#ifndef DISABLE_P05_OSC_OUTPUT
    fm_osc_output_select(FALSE);
#endif

#if defined(USE_SPECTRUM_PARTTERN)		  
    set_lcd_flash_lock(UNLOCK);	
#endif

#ifdef USE_AMP_MODE_SELECT
	D_CLASS_AMP_HIGH();
#endif
	
}
예제 #5
0
/*----------------------------------------------------------------------------*/
void fm_rev( void )
{
    u8 key;

#if defined(SPECTRUM_FUNC_ENABLE)
    set_spectrum_lock(UNLOCK);
#endif		  

#if defined(FM_PAUSE_LED_INDICATOR)
    set_play_flash(LED_FLASH_NOR);
#endif

    my_main_vol(my_music_vol);	
	
    while (1)
    {
        key = get_msg();
#if defined(KEY_PRESS_LED_INDICATOR)
	key_press_led_indicator(key);
#elif defined(CUSTOM_KEY_FEATURE_USE)
		custom_key_hdlr(key);
#endif

#if defined(KPL_MSG_COMPATIBLE)
	kpl_msg_hdlr(key);
#endif

#if 0
	if(key!=0xff)
	printf(" music_play get_msg %x \r\n",(u16)key);
#endif
	dac_sw_check();

#ifndef FM_BY_PASS
       dac_out_select(aux_ch_reg);
#endif

        switch (key)
        {

#if defined(K000_HG_898_V001)||defined(USE_STOP_KEY_SHORT_CH_DOWN)
	case INFO_STOP |KEY_SHORT_UP :
		goto __CH_DOWN;
		break;
#endif
#ifdef USE_STOP_KEY_SHORT_SCAN
    	case INFO_STOP| KEY_SHORT_UP :
	goto __SCAN_FREQ;
#endif

#ifdef IR_INFO_EQ_DOWN_SCAN
        case INFO_EQ_DOWN| KEY_SHORT_UP :
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			goto __SCAN_FREQ;
		}
		break;
#endif

#ifdef USE_MODE_KEY_LONG_SCAN
    	case INFO_MODE | KEY_LONG :
	goto __SCAN_FREQ;
#endif
#ifdef RADIO_MODE_HOT_KEY_ENABLE	
#ifdef RADIO_MODE_HOT_KEY_LONG_SCAN
    	case INFO_FM_MOD| KEY_LONG :
	goto __SCAN_FREQ;
#endif	
#endif
#ifdef USE_EQ_KEY_SHORT_SCAN
    	case INFO_EQ_UP| KEY_SHORT_UP :
	goto __SCAN_FREQ;
#endif
#ifdef USE_EQ_KEY_SHORT_CH_UP
    case INFO_EQ_UP | KEY_SHORT_UP :
	goto __CH_DOWN;
		break;
#endif
#if 1//def USE_POWER_KEY
#ifdef USE_POWER_KEY_SHORT_SCAN
    	case INFO_POWER | KEY_SHORT_UP :
#ifdef USE_IR_POWER_KEY_TO_POWER_OFF
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			goto _HOT_KEY_HDLR;	
		}
#endif		
	goto __SCAN_FREQ;

#endif
#endif  
#if defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
    	 case INFO_CUS_KEY_1 | KEY_SHORT_UP :

		radio_freq_tune_pop=~radio_freq_tune_pop;
		radio_tune_timer=12;
		
		if(radio_freq_tune_pop){

                     Disp_Con(DISP_FREQ);
		}
		break;
#endif

#ifdef RADIO_MODE_HOT_KEY_ENABLE	

#ifdef RADIO_AM_WM_SEL_IN_ONE_KEY
#ifdef RADIO_AM_WM_ENABLE
    case INFO_FM_MOD | KEY_SHORT_UP:
        if (work_mode == SYS_AMREV){
		Set_Curr_Func(SYS_FMREV);			
	     	FMAM_Mode_Switch_Profile(SYS_FMREV);
	}
	else if(work_mode == SYS_FMREV){
		Set_Curr_Func(SYS_AMREV);			
	     	FMAM_Mode_Switch_Profile(SYS_AMREV);
	}
		break;
#endif		
#endif
#endif		
#if defined(USE_POWER_KEY_FOR_FM_PLAY)
    	 case INFO_POWER | KEY_SHORT_UP :
#if defined(USE_IR_LONG_POWER_KEY_TO_FAKE_POWER_OFF)
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif			
#ifdef USE_IR_POWER_KEY_TO_POWER_OFF
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif
#elif defined(USE_MODE_LONG_FOR_FM_PLAY)
    	 case INFO_MODE| KEY_LONG:
#endif
        case INFO_PLAY | KEY_SHORT_UP :
#if defined(FM_PLAY_KEY_PAUSE)        
#if defined(K722_YJH_722_V001)
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif	
#if defined(IR_PLAY_KEY_SCAN_FREQ_ALL)
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			goto __SCAN_FREQ;
		}
#endif
            play_status = !play_status;

            if (play_status)
            {
		  my_main_vol(my_music_vol);
  		  Mute_Ext_PA(UNMUTE);
#if defined(FM_PAUSE_LED_INDICATOR)
		 set_play_flash(LED_FLASH_ON);
#endif
            }
	     else{
  		Mute_Ext_PA(MUTE);		 	
		my_main_vol(0);	

#if defined(USE_SPECTRUM_PARTTERN)		  		
		set_lcd_flash_lock(LOCK);
#endif

#if defined(FM_PAUSE_LED_INDICATOR)
    		set_play_flash(LED_FLASH_NOR);
#endif		
	     }

#if defined(PAUSE_FLASH_WHOLE_SCREEN)
            if (play_status == MUSIC_PAUSE)
			set_led_flash_tpye(2);
	     else{
			set_led_flash_tpye(0);
	     }
#endif
          Disp_Con(DISP_FREQ);		 
		
	   break;        
#endif	   
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_PLAY_KEY_SCAN_FREQ_DISABLE)
			break;
#elif defined(IR_PLAY_SHORT_CH_UP)
			goto __CH_UP;
#else
			goto __SCAN_FREQ;
#endif
		}
		else{
			
#if defined(ADKEY_PLAY_SHORT_SCAN_FRE_DISABLE)		
		break;
#endif			
		#ifdef ADKEY_PLAY_SHORT_SCAN_FRE
			goto __SCAN_FREQ;	
		#else
			#if defined( ADKEY_NEXT_ADJST_FREQ)
			goto __CH_UP;
			#endif
			#if defined(ADKEY_PLAY_SHORT_ADJ_CH)
			goto __CH_UP;
			#endif
		#endif
		}
            break;
#if defined(K120_YJH_120_V001)||defined(K000_HG_898_V001)||defined(EQ_DOWN_SCAN_ALL)
        case INFO_EQ_DOWN| KEY_SHORT_UP :
#if 1//defined(EQ_DOWN_SCAN_ALL)	
		goto __SCAN_FREQ;
#endif
#ifndef K722_YJH_722_V001		
		goto __FRE_DOWN;
#endif
#endif			
        case INFO_PLAY | KEY_LONG :

		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_PLAY_KEY_LONG_SCAN_FREQ)
		goto __SCAN_FREQ;
#else
		break;
#endif
		}
#ifdef USE_LONG_PLAY_KEY_TO_SWITCH_MODE		
		goto _HOT_KEY_HDLR;
#endif

#ifdef AUX_MODE_HOT_KEY_USE_PLAY_LONG		
		goto _HOT_KEY_HDLR;
#endif

#ifdef USE_EQ_KEY_SHORT_SCAN
		break;
#endif
#ifdef ADKEY_PLAY_SHORT_SCAN_FRE
		break;
#endif
__SCAN_FREQ:

#if defined(USE_SPECTRUM_PARTTERN)		  
	     set_lcd_flash_lock(LOCK);
#endif

#ifdef DISP_SCH_AT_FM_SCAN	
            Disp_Con(DISP_SCH);
	     delay_10ms(60);
#endif
            scan_fre();

#if defined(USE_SPECTRUM_PARTTERN)		  
	     set_lcd_flash_lock(UNLOCK);
#endif

	     if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			//break;
	     }			
            //flush_low_msg();
            fre_channl = 1;
            get_channl(fre_channl);
            //Disp_Con(DISP_FREQ);
            break;
#if RTC_ENABLE 
		case INFO_ALM_BELL :				///<闹钟响消息,进入闹钟循环
            		sys_clock_pll();
			dac_out_select(DAC_DECODE);
			if(alm_bell_mode())
			{
				dac_out_select(DAC_AMUX0);
				return;
			}
			dac_out_select(DAC_AMUX0);
			break;
#endif
        case INFO_HALF_SECOND :
			
#if ((USE_DEVICE == MEMORY_STYLE)&&(FAT_MEMORY))          
             updata_fat_memory();
#endif
			
#if defined(AD_MEASURE_TEMP_FUNC)
		adc_diode_temp_measure_hdlr();
#endif
#ifdef DISP_BACKLIGHT_AUTO_SAVE_POWER
	 	Disp_BL_time_out();
#endif

#ifdef USE_USB_HOTPLUG_FUNC
		usb_hotplug_hdlr();
#endif
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV_IMPROVE
		if(mute_release_timer>0)
			mute_release_timer--;

		 if(mute_release_timer==0){
			my_main_vol(my_music_vol);	
			Mute_Ext_PA(UNMUTE);
		 }
#endif

#if defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
		if(radio_tune_timer>0){
			radio_tune_timer--;
			
			if(radio_tune_timer==0){
				radio_freq_tune_pop=0;
	                    Disp_Con(DISP_FREQ);
			}

			if(radio_freq_tune_pop){

			      pop_spark=~pop_spark;

			     if(pop_spark){
	                    		Disp_Con(DISP_PWR_OFF);
			     }
			     else{				
	                    		Disp_Con(DISP_FREQ);
			    }
			}
		}
#endif
#ifdef VOL_ADJ_SPARK_LED
		if(vol_adj_spark_bit){
			vol_adj_spark_bit=0;
			restore_led_flash_mod(last_led_play_mod);		
		}
#endif	 
            if (return_cnt < RETURN_TIME)
            {
                return_cnt++;
            }

#if defined(TIME_FORCE_SHOW_ON_SCREEN)

            if (DISP_FREQ == curr_menu){
				
	            if (time_show_return_cnt>RETURN_TIME_SHOW_TIME){
	                    get_curr_date();
	                    Disp_Con(DISP_RTC_POINT);
				break;
		    }	
		     else{
#if defined(MANUAL_SWITCH_TIME_DISPLAY)
	                    Disp_Con(DISP_FREQ);
#else
	                if(DISP_RTC != curr_menu){
				time_show_return_cnt++;
	                }
#endif				
		     }
	     }
#endif
            if (RETURN_TIME == return_cnt)
            {
#ifdef SUPPORT_PT2313
		  clr_aud_effect_state();
#endif			
#if defined(LED_DRV_USE_SM1628)
		led_spark_protect=0;
#endif

                if (DISP_DWORD_NUMBER == curr_menu)
                {
                    goto _PICK_CH;
                }
                else if (DISP_FREQ != curr_menu)
                    Disp_Con(DISP_FREQ);
#if defined(NEW_VOLUME_KEY_FEATURE)||defined(VOL_TUNE_NEW_VOLUME_KEY_FEATURE)
		if(new_vol_feature){
			new_vol_feature =0;
			if(last_disp_menu!=DISP_NULL)			
                     Disp_Con(last_disp_menu);
		}
#endif								
            }
#if defined(USE_BAT_MANAGEMENT)
		bmt_hdlr();
#endif
	     Disp_Update();			
            break;

        case INFO_PICK_FRE | KEY_LONG:
            save_fre(frequency);
            Disp_Con(DISP_FREQ);
            break;

        case INFO_PICK_FRE | KEY_SHORT_UP:
_PICK_CH:
            if (DISP_DWORD_NUMBER != curr_menu)
            {
                break;
            }

            if (( cfilenum <= MAX_FRE) && (cfilenum >= MIN_FRE))
            {

                frequency = cfilenum;
                cfilenum = 0;
                set_fre(frequency, 1);
            }
            else if ((cfilenum) && (cfilenum<=all_channl))
            {
                fre_channl = cfilenum;
                get_channl(fre_channl);
            }
            cfilenum = 0;
            Disp_Con(DISP_FREQ);
            write_info(MEM_FRE,frequency - MIN_FRE);
            break;

#if defined(VOL_TUNE_FREQ_VOL)||defined(VOL_TUNE_FREQ_ONLY)||defined(VOL_TUNE_NEW_VOLUME_KEY_FEATURE)||defined(VOL_TUNE_VOL_DEFAULT_TUNE_FREQ_POP)
        case INFO_PLUS:	
      	     frequency += 2;
            goto __FRE_DOWN;			
			
        case INFO_MINUS:			 
		goto __FRE_DOWN;			
		break;
#endif
        case INFO_NEXT_FIL | KEY_SHORT_UP:

#if defined(NEW_VOLUME_KEY_FEATURE)
		break;
        case INFO_NEXT_FIL :
        case INFO_NEXT_FIL | KEY_HOLD:

		if(new_vol_feature){
			goto _HOT_KEY_HDLR;
		}
#endif				
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_SHORT_ADJ_CH)
			     goto __CH_UP;
#elif defined( IR_NEXT_PREV_DO_NOTHING)
			break;
#elif defined( IR_NEXT_PREV_SHORT_AUTO_SCAN)
			     goto __SCAN_UP;	
#else
 	     	      		frequency += 2;
		            goto __FRE_DOWN;
#endif
		}
		else{
#if defined(K722_YJH_722_V001)
		if(fre_channl==1){
 	     	      		frequency += 2;
		            goto __FRE_DOWN;
		}
		else{
			     goto __CH_UP;
		}
#endif

#if defined( ADKEY_NEXT_ADJST_FREQ)
 	     	      		frequency += 2;
		            goto __FRE_DOWN;
#elif defined(ADKEY_NEXT_PREV_SHORT_AUTO_SCAN)
			     goto __SCAN_UP;	
#else
			     goto __CH_UP;
#endif
		}

	case INFO_PREV_FIL | KEY_SHORT_UP:
		
#if defined(NEW_VOLUME_KEY_FEATURE)
		break;
	case INFO_PREV_FIL :
	case INFO_PREV_FIL | KEY_HOLD:

		if(new_vol_feature){
			goto _HOT_KEY_HDLR;
		}
#endif				
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_SHORT_ADJ_CH)
			     goto __CH_DOWN;
#elif defined( IR_NEXT_PREV_DO_NOTHING)
			break;
#elif defined(IR_NEXT_PREV_SHORT_AUTO_SCAN)
			     goto __SCAN_DOWN;
#else
		            goto __FRE_DOWN;
#endif
		}
		else{
#if defined(K722_YJH_722_V001)
		if(fre_channl==1){
		            goto __FRE_DOWN;
		}
		else{
			     goto __CH_DOWN;
		}
#endif
				
#if defined( ADKEY_NEXT_ADJST_FREQ)
				goto __FRE_DOWN;
#elif defined(ADKEY_NEXT_PREV_SHORT_AUTO_SCAN)
				goto __SCAN_DOWN;		
#else				
				goto __CH_DOWN;
#endif
		}
		
__FRE_DOWN:
            frequency--;
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV

#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV_IMPROVE
		 if(mute_release_timer==0)
#endif
		{
			Mute_Ext_PA(MUTE);
			my_main_vol(0);		
		}
#endif

#ifdef RADIO_AM_WM_ENABLE			
	    if(work_mode==SYS_FMREV){
			
	            if ( frequency > MAX_FRE)
	            {
	                frequency = MIN_FRE;
	            }
	            else if (frequency < MIN_FRE)
	            {
	                frequency = MAX_FRE;
	            }
	            set_fre(frequency, 1);
	            write_info(MEM_FRE,frequency - MIN_FRE);
	    	}
		else	{

		     if ( frequency > AM_MAX_FRE)
	            {
	                frequency = AM_MIN_FRE;
	            }
	            else if (frequency < AM_MIN_FRE)
	            {
	                frequency = AM_MAX_FRE;
	            }
	            set_fre(frequency, 1);
	            Save_AM_Freq((frequency - AM_MIN_FRE),(AM_FREQ_MAGIC_NUM));
		}
#else
	            if ( frequency > MAX_FRE)
	            {
	                frequency = MIN_FRE;
	            }
	            else if (frequency < MIN_FRE)
	            {
	                frequency = MAX_FRE;
	            }
	            set_fre(frequency, 1);
	            write_info(MEM_FRE,frequency - MIN_FRE);
#endif
            Disp_Con(DISP_FREQ);
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV
#ifdef MUTE_EXAMP_AT_FM_NEXT_PREV_IMPROVE
		 mute_release_timer=2;
#else
		my_main_vol(my_music_vol);	
		Mute_Ext_PA(UNMUTE);
#endif
#endif

            //delay_ms(20);
            break;

#if defined(USE_MODE_LONG_FOR_FM_CH_UP)
    	 case INFO_MODE| KEY_LONG:
#endif		 	
        case INFO_CH_NEXT | KEY_SHORT_UP:
        case INFO_CH_UP| KEY_SHORT_UP:
	__CH_UP:
			fre_channl += 2;
        case INFO_CH_PREV | KEY_SHORT_UP:
        case INFO_CH_DOWN| KEY_SHORT_UP:
	__CH_DOWN:
            fre_channl--;
            if (fre_channl > all_channl)
            {
                fre_channl = 1;
            }
            else if (!fre_channl)
            {
                fre_channl = all_channl;
            }
            get_channl(fre_channl);
            Disp_Con(DISP_FREQ);
            flush_low_msg();
			
            break;

#ifdef SEMI_AUTO_SCAN_FREQ

#if defined(K722_YJH_722_V001)
        case INFO_PLAY_MODE | KEY_SHORT_UP:
		frequency += 2;
		goto __FRE_DOWN;					
#endif		
        case INFO_CH_UP| KEY_HOLD:

        case INFO_NEXT_FIL | KEY_HOLD:
	 if(IR_KEY_Detect){
		IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_HOLD_AUTO_SCAN)

#elif defined(IR_NEXT_PREV_KEY_HOLD_DO_NOTHING)
	break;
#else
	break;
#endif
		
	 }
	 else{
#if defined(ADKEY_NEXT_PREV_HOLD_AUTO_SCAN)
	//goto __SCAN_UP;
#elif defined(ADKEY_NEXT_PREV_HOLD_FREQ_ADJ)
      		frequency += 2;
		goto __FRE_DOWN;			
#elif defined(ADKEY_NEXT_PREV_HOLD_CH_SEL)
	goto __CH_UP;
#else
	goto _HOT_KEY_HDLR;
#endif
        }
        case INFO_PLUS | KEY_SHORT_UP:
#if defined(INDEPENDENT_KEY_TUNE_FREQ)
	frequency += 2;
	goto __FRE_DOWN;
#endif
        case INFO_PLUS | KEY_HOLD:
 #if defined(INDEPENDENT_KEY_FAST_TUNE_FREQ)			
 	frequency += 2;
	goto __FRE_DOWN;
#endif

__SCAN_UP:			
		auto_scan(SEARCH_UP);
            break;
#if defined(K722_YJH_722_V001)
        case INFO_EQ_UP | KEY_SHORT_UP:
		goto __FRE_DOWN;			
#endif
        case INFO_CH_DOWN| KEY_HOLD:
        case INFO_PREV_FIL | KEY_HOLD:

	 if(IR_KEY_Detect){
		IR_KEY_Detect =0;
#if defined(IR_NEXT_PREV_HOLD_AUTO_SCAN)

#elif defined(IR_NEXT_PREV_KEY_HOLD_DO_NOTHING)
	break;
#else
	break;
#endif	
	 }
	 else{
 	
#if defined(ADKEY_NEXT_PREV_HOLD_AUTO_SCAN)
	//goto __SCAN_DOWN;
#elif defined(ADKEY_NEXT_PREV_HOLD_FREQ_ADJ)
		goto __FRE_DOWN;			
#elif defined(ADKEY_NEXT_PREV_HOLD_CH_SEL)
	goto __CH_DOWN;
#else
	goto _HOT_KEY_HDLR;
#endif
        }
        case INFO_MINUS|KEY_SHORT_UP:			 

#if defined(INDEPENDENT_KEY_TUNE_FREQ)			
	goto __FRE_DOWN;
#endif

        case INFO_MINUS| KEY_HOLD:
#if defined(INDEPENDENT_KEY_FAST_TUNE_FREQ)			
	goto __FRE_DOWN;
#endif
			
__SCAN_DOWN:			
		auto_scan(SEARCH_DN);			
            break;
#endif

        default :
_HOT_KEY_HDLR:			
            if (!ap_handle_hotkey(key))
                return;
        }
    }
}
예제 #6
0
/*----------------------------------------------------------------------------*/
void main(void)
{
     xd_u8 sys_timer=0;

      sys_power_up();
      Mute_Ext_PA(MUTE);
      sys_clock_pll();//(MAIN_CLK_PLL);
	 
#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

#ifdef ALARM_USE_MULTI_SOURCE_FUNC
	alarm_power_on_protect=0;
#endif
#ifdef ADKEY_SELECT_MODE
   	mode_switch_protect_bit=1;
#endif
#ifdef USE_POWER_KEY
	//waiting_power_key();
      sys_power_up();	
#endif	
	//Disp_Con(DISP_HELLO);
	sys_init();
    	sys_info_init();
	Init_Func_List();
	flush_all_msg();
#if FILE_ENCRYPTION
    	password_init(0xaa);  //输入加密文件的密码
#endif  

#ifdef ADKEY_DEBUG
	AD_Debug_func();
#endif
#if 0
	while(1){
		keyScan();
		delay_10ms(1);
		sys_timer = get_msg();
#if 1
	if(sys_timer!= 0xff){

	    	printf("------->-get_msg   %x \r\n",(u16)sys_timer);
	}
#endif

	}
#endif	
#ifdef SYS_POWER_ON_DEFAULT_IN_RADIO
	Set_Curr_Func(SYS_FMREV);
#elif defined(SYS_POWER_ON_DEFAULT_IN_CD)
	Set_Curr_Func(SYS_MCU_CD);
#endif
       if((work_mode==SYS_MP3DECODE_USB)||(work_mode==SYS_MP3DECODE_SD)){

		Set_Curr_Func(SYS_FMREV);
	}
	radio_force_preset=6;
#ifdef UART_ENABLE
    	printf("------->- SYS INIT   work_mode:%d   \r\n",(u16)work_mode);
#endif
	while (1)
       {
		Set_Curr_Func(work_mode);
        	switch (work_mode)
	       {
#ifdef USE_USB_SD_DECODE_FUNC	       
	 		case SYS_MP3DECODE_USB:
	 		case SYS_MP3DECODE_SD:	 
	 			decode_play();
	            	break;
#endif					
#ifdef USE_CD_MCU_MASTER_FUNC
		    	case SYS_MCU_CD:
#ifdef UART_ENABLE
			sys_printf(" SYS_MCU_CD");
#endif
					
				mcu_main_hdlr();
			break;
#endif			
#ifdef USE_RADIO_FUNC
	        	case SYS_FMREV:
#ifdef AM_RADIO_FUNC
	        	case SYS_AMREV:
#endif			

#ifdef UART_ENABLE
			sys_printf(" SYS_RADIO_FUNC");
#endif

	            		fm_radio();
	            	break;
#endif					
#ifdef USE_AUX_FUNC			
	        	case SYS_AUX:

#ifdef UART_ENABLE
			sys_printf(" SYS_AUX");
#endif
					
	            		aux_function();
	            	break;
#endif			

#ifdef USE_BLUE_TOOTH_FUNC			
    	        	case SYS_BLUE_TOOTH:

#ifdef UART_ENABLE
			sys_printf(" SYS_BLUE_TOOTH");
#endif
						
	            		Blue_tooth_main();
	            	break;
#endif

#ifdef USE_RTC_FUNC
	        	case SYS_RTC:
	            		rtc_function();
	            	break;
#endif
#ifdef USE_SYS_IDEL_FUNC
	        	case SYS_IDLE:
		            idle_mode();
#ifdef ADKEY_SELECT_MODE				
		   	     mode_switch_protect_bit=1;			
#endif
		   	     sys_restore_mode();
			     dac_mute_control(0,1);
			     flush_all_msg();	
			     my_music_vol = 26;
			     set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL);
			     set_sys_vol(my_music_vol);
		     	break;
#endif			 
	        	default:

#ifdef USE_USB_SD_DECODE_FUNC	               	
	            		//work_mode = SYS_MP3DECODE_USB;
#else
	            		//work_mode = SYS_MCU_CD;
#endif
			Set_Curr_Func(SYS_FMREV);

	            	break;
	        }
#ifdef USE_SYS_MODE_RECOVER
	if(work_mode !=SYS_IDLE){
              write_info(MEM_SYSMODE,work_mode);
    	}
#endif	
			
    }

}
예제 #7
0
/*----------------------------------------------------------------------------*/
void aux_function(void)
{
#ifdef USE_LINE_IN_DETECT_FUNC
#ifndef AUX_DETECT_FUNC_WITH_MANUAL_SEL
   if(!aux_online){
   	
	Set_Curr_Func(SYS_MP3DECODE_USB);
	return;
   }
#endif   
#endif
#ifdef SYS_DEFAULT_IN_PWR_OFF_FOR_LED_PROTECTION_UNTIL_AUX
	 sys_pwr_on_led_protect_bit=0;
#endif
#if 1//defined(LINE_IN_PLAY_KEY_PAUSE)
         play_status =MUSIC_PLAY;
#endif
#if defined(TWO_PLAY_LED_IN_USE)
	 led_open_enable = 0;
#endif	
    set_play_flash(LED_FLASH_ON);

#if defined(IPONE_DOCK_FUNC_ENABLE)&&!defined(IPONE_INDEPENDENT_MODE)
    Disp_Con(DISP_IPOD);
#else
    Disp_Con(DISP_AUX);
#endif
    PT1 = 1;										//timer1 interrupt 低优先级
    flush_low_msg();
#if SDMMC_CMD_MODE
	sd_chk_ctl(SET_SD_L_CHK);
#endif

    set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL);			//设置AUX模式的音量上限

#ifdef SUPPORT_PT2313

#ifdef AUX_PATH_SHARE_SAME_MP3_PT_CHAN

#ifdef EXCHANGE_LINE_IN_CHANNEL
    aux_channel_crosstalk_improve(DAC_AMUX0);//4P24,P25 FM_IN	  
#else
    aux_channel_crosstalk_improve(DAC_AMUX1);//4P26,P27 FM_IN
#endif

    delay_10ms(60);

#ifdef INDEPENDENT_AUX_PATH_TO_PT
    PT2313_Config(AUX_CHAN,CHAN_ADJ);

#else
    PT2313_Config(MP3_CHAN,CHAN_ADJ);
#endif

#else

    PT2313_Config(AUX_CHAN,CHAN_ADJ);

#endif

#else	//SUPPORT_PT2313

#ifdef FM_BY_PASS

#ifdef ADC_DETECT_LINE_IN
    aux_online =1;
    Line_In_Detect =0;
#endif
    main_vol(0);

#ifdef EXCHANGE_LINE_IN_CHANNEL
    aux_channel_crosstalk_improve(DAC_AMUX0);	//4P24,P25 AUX_IN	 
#else	
    aux_channel_crosstalk_improve(DAC_AMUX1);;//4P26,P27 AUX_IN
#endif

    Mute_Ext_PA(UNMUTE);
    my_main_vol(my_music_vol);
    
#else	//FM_BY_PASS
	
#ifdef EXCHANGE_LINE_IN_CHANNEL
    aux_channel_crosstalk_improve(DAC_AMUX0);	//4P24,P25 AUX_IN	 
#else	
    aux_channel_crosstalk_improve(DAC_AMUX1);//4	P26,P27 AUX_IN
#endif
    //Mute_Ext_PA(UNMUTE);
    //my_main_vol(my_music_vol);
#endif	//FM_BY_PASS
#endif	//SUPPORT_PT2313

#ifdef ADC_DETECT_LINE_IN
    my_main_vol(0);		
#else
    Mute_Ext_PA(UNMUTE);	
    my_main_vol(my_music_vol);	
#endif
	
    sysclock_div2(1);
#if defined(IPONE_DOCK_FUNC_ENABLE)&&!defined(IPONE_INDEPENDENT_MODE)
    //open_uart_ctrl();
    ipone_hdlr();
    //close_uart_ctrl();
#else
    deal_aux();
#endif

   Mute_Ext_PA(MUTE);		

#ifdef SUPPORT_PT2313
    my_main_vol(0);		
#else
   main_vol_set(0, CHANGE_VOL_NO_MEM);
#endif

    sys_clock_pll();

#if defined(USE_SPECTRUM_PARTTERN)		  
    set_lcd_flash_lock(UNLOCK);
#endif

#if SDMMC_CMD_MODE
	sd_chk_ctl(SET_SD_H_CHK);
#endif

}
예제 #8
0
void deal_aux( void )
{
    u8 key;
#if defined(K755_JinYeHeLi_755_V001)||defined(K755_AnJieEr_755_V001)
    set_play_flash(LED_FLASH_SLOW);
#endif

#if defined(AUX_PAUSE_LED_INDICATOR_FLASH_WHEN_PLAY)
    set_play_flash(LED_FLASH_NOR);
#endif
#if defined(SPECTRUM_FUNC_ENABLE)
    set_spectrum_lock(UNLOCK);
#endif		  

    my_main_vol(my_music_vol);	

    while (1)
    {
        key = get_msg();
#if 0
	if(key!=0xFF)
	printf( "---->---deal_aux %x \r\n",(u16)key);
#endif

       dac_out_select(aux_ch_reg);
		
#if defined(KEY_PRESS_LED_INDICATOR)
	key_press_led_indicator(key);
#elif defined(CUSTOM_KEY_FEATURE_USE)
	custom_key_hdlr(key);
#endif

#if defined(KPL_MSG_COMPATIBLE)
	kpl_msg_hdlr(key);
#endif

	 dac_sw_check();
	 
	switch (key)
        {
#ifdef USE_IR_LONG_POWER_KEY_TO_FAKE_POWER_OFF
        case INFO_POWER | KEY_LONG:

		if(IR_KEY_Detect){
			goto _HOT_KEY_HDLR;	
		}
		break;
#endif			
        
#if defined(LINE_IN_PLAY_KEY_PAUSE)
#if 1//defined(USE_ONLY_POWER_HOLD_CTRL)
#if defined(USE_POWER_KEY_FOR_AUX_PLAY)
        case INFO_POWER | KEY_SHORT_UP :
#ifdef USE_IR_LONG_POWER_KEY_TO_FAKE_POWER_OFF
		if(IR_KEY_Detect){
			IR_KEY_Detect=0;		
			break;
		}
        case INFO_PLAY | KEY_SHORT_UP :				
#endif			
#ifdef USE_IR_POWER_KEY_TO_POWER_OFF
		if(IR_KEY_Detect){
			goto _HOT_KEY_HDLR;	
		}
        case INFO_PLAY | KEY_SHORT_UP :		
#endif		
			
#else
        case INFO_PLAY | KEY_SHORT_UP :
#endif
#else
        case INFO_PLAY | KEY_SHORT_UP :
#endif			
#ifdef K722_YJH_722_V001
		if(IR_KEY_Detect){
			IR_KEY_Detect = 0;
			break;
		}
#endif			

            if (play_status == MUSIC_PAUSE)
            {
	         play_status =MUSIC_PLAY;
		  my_main_vol(my_music_vol);
#ifndef NO_AUX_MUTE_WHEN_PAUSE		  
  		  Mute_Ext_PA(UNMUTE);
#endif

#if defined(USE_SPECTRUM_PARTTERN)		  
		  set_lcd_flash_lock(UNLOCK);
#endif

#if defined(AUX_PAUSE_LED_INDICATOR)
		 set_play_flash(LED_FLASH_ON);
#elif defined(AUX_PAUSE_LED_INDICATOR_FLASH_WHEN_PLAY)
		 set_play_flash(LED_FLASH_NOR);
#endif
#if defined(SPECTRUM_FUNC_ENABLE)
    set_spectrum_lock(UNLOCK);
#endif		  
            }
	     else if (play_status == MUSIC_PLAY){

	        play_status =MUSIC_PAUSE;

#ifndef NO_AUX_MUTE_WHEN_PAUSE		  		 	
  		Mute_Ext_PA(MUTE);		 
#endif
		my_main_vol(0);	
		
#if defined(USE_SPECTRUM_PARTTERN)		  		
		set_lcd_flash_lock(LOCK);
#endif

#if defined(AUX_PAUSE_LED_INDICATOR)
    		set_play_flash(LED_FLASH_FAST);
#elif defined(AUX_PAUSE_LED_INDICATOR_FLASH_WHEN_PLAY)
		 set_play_flash(LED_FLASH_ON);
#endif	
#if defined(SPECTRUM_FUNC_ENABLE)
    set_spectrum_lock(LOCK);
#endif		  
	     }
#if defined(PAUSE_FLASH_WHOLE_SCREEN)
            if (play_status == MUSIC_PAUSE)
			set_led_flash_tpye(2);
	     else{
			set_led_flash_tpye(0);
	     }
#endif		 
            Disp_Con(DISP_AUX);		 
	   break;        
#endif	   
#ifdef ADC_DETECT_LINE_IN
    case MSG_AUX_IN :
		sys_printf("  MSG_AUX_IN");
	 my_main_vol(my_music_vol);	
	 Mute_Ext_PA(UNMUTE);
        break;

    case MSG_AUX_OUT :
		sys_printf("  MSG_AUX_OUT");
	 Mute_Ext_PA(MUTE);		
	 main_vol(0);			
        break;
#endif

#ifdef USE_AUX_2
     case INFO_MODE | KEY_SHORT_UP:
	 	
		if(aux_2_sel==0){
			aux_2_sel =1;
		       Set_Curr_Func(AUX_2_DEV);
			set_play_flash(LED_FLASH_ON);			   
	   		PT2313_Config(AUX_CHAN,CHAN_ADJ);			
		}
		else{
			aux_2_sel =0;
			goto _HOT_KEY_HDLR;
		}
		break;

     case INFO_AUX_MOD | KEY_SHORT_UP:
	aux_2_sel=~aux_2_sel;
	if(aux_2_sel){

	       Set_Curr_Func(AUX_2_DEV);
   		PT2313_Config(AUX_CHAN,CHAN_ADJ);
	}	
	else{

	       Set_Curr_Func(AUX_DEV);
		PT2313_Config(MP3_CHAN,CHAN_ADJ);
	}

	set_play_flash(LED_FLASH_ON);

	break;
#endif
        case INFO_HALF_SECOND :
#if ((USE_DEVICE == MEMORY_STYLE)&&(FAT_MEMORY))           
            updata_fat_memory();
#endif
			
#if defined(AD_MEASURE_TEMP_FUNC)
		adc_diode_temp_measure_hdlr();
#endif

#ifdef USE_USB_HOTPLUG_FUNC
		usb_hotplug_hdlr();
#endif

#ifdef VOL_ADJ_SPARK_LED
		if(vol_adj_spark_bit){
			vol_adj_spark_bit=0;
			restore_led_flash_mod(last_led_play_mod);		
		}
#endif	 
#ifdef DISP_BACKLIGHT_AUTO_SAVE_POWER
	 	Disp_BL_time_out();
#endif


            if (return_cnt < RETURN_TIME)
            {
                return_cnt++;
            }

#if defined(LINE_IN_PLAY_KEY_PAUSE)
		if(play_status==MUSIC_PAUSE){

#ifdef LINE_IN_FLASH_WHOLE_SCREEN	
			aux_screen_flash_bit=~aux_screen_flash_bit;
			if(aux_screen_flash_bit){
		                  Disp_Con(DISP_AUX);
			}
			else{
		                   Disp_Con(DISP_PWR_OFF);
					break;
			}
#endif
		}
#endif

			
#if defined(TIME_FORCE_SHOW_ON_SCREEN)

	if(DISP_AUX == curr_menu){
		
	            if (time_show_return_cnt>RETURN_TIME_SHOW_TIME){
	                    get_curr_date();
	                    Disp_Con(DISP_RTC_POINT);
				break;
		    }	
		     else{
#if defined(MANUAL_SWITCH_TIME_DISPLAY)
	                    Disp_Con(DISP_AUX);
#else			 	
	                if(DISP_RTC != curr_menu){
				time_show_return_cnt++;
	                }
#endif				
		     }
	     }
#endif

            if (RETURN_TIME == return_cnt)
            {
            
#ifdef SUPPORT_PT2313
		  clr_aud_effect_state();
#endif
#if defined(LED_DRV_USE_SM1628)
		led_spark_protect=0;
#endif

                if (DISP_DWORD_NUMBER == curr_menu)
                {
                    cfilenum = 0;
                }
                if (DISP_AUX != curr_menu)
                    Disp_Con(DISP_AUX);
				
#if defined(CUSTOM_MAIN_DISP_VOL)
	         if (DISP_AUX== curr_menu){
                    Disp_Con(DISP_VOL);
	         }
#endif
				
            }
#if defined(USE_BAT_MANAGEMENT)
		bmt_hdlr();
#endif
	     Disp_Update();			
            break;
#if defined(NEW_VOLUME_KEY_FEATURE)
        case INFO_NEXT_FIL :
        case INFO_NEXT_FIL | KEY_SHORT_UP:
        case INFO_NEXT_FIL | KEY_HOLD:

		if(!new_vol_feature){
			break;
		}
#else			

    case INFO_VOL_PLUS:
    case INFO_VOL_PLUS | KEY_HOLD :
#ifdef KEY_NEXT_PREV_HOLD_ADJ_VOL_IN_AUX
    case INFO_NEXT_FIL| KEY_HOLD :
#endif
#if !defined(INDEPENDENT_VOLUME_KEY)		
    case INFO_NEXT_FIL:
    case INFO_NEXT_FIL| KEY_HOLD :
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			break;
		}
#endif		

#endif		

#ifdef SUPPORT_PT2313
	if((audio_effect_state>0)){
		audio_effect_hdlr(0x01);
		flush_low_msg();	
		break;
	}
#endif

        my_music_vol += 2;

#if defined(NEW_VOLUME_KEY_FEATURE)
        case INFO_PREV_FIL :
        case INFO_PREV_FIL | KEY_SHORT_UP:
        case INFO_PREV_FIL | KEY_HOLD:

		if(!new_vol_feature){
			break;
		}
#else				

    case INFO_VOL_MINUS:
    case INFO_VOL_MINUS | KEY_HOLD :
#ifdef KEY_NEXT_PREV_HOLD_ADJ_VOL_IN_AUX
    case INFO_PREV_FIL| KEY_HOLD :
#endif		
#if !defined(INDEPENDENT_VOLUME_KEY)				
    case INFO_PREV_FIL:
    case INFO_PREV_FIL| KEY_HOLD :
		if(IR_KEY_Detect){
			IR_KEY_Detect =0;
			break;
		}
#endif		
#endif

#ifdef SUPPORT_PT2313	
	if((audio_effect_state>0)){
		audio_effect_hdlr(0x02);
		flush_low_msg();
		break;
	}
#endif

        if(my_music_vol)
            my_music_vol--;
#ifdef VOL_ADJ_SPARK_LED

	if(!vol_adj_spark_bit){
		vol_adj_spark_bit=1;
		last_led_play_mod = get_led_flash_mode();
	}
	set_play_flash(LED_FLASH_VERY_FAST);
#endif

        if (my_music_vol > MAX_VOL)
        {
            my_music_vol = MAX_VOL;
        }
#if defined(LINE_IN_PLAY_KEY_PAUSE)
        if (play_status == MUSIC_PAUSE)
        {
	       play_status =MUSIC_PLAY;
#ifndef NO_AUX_MUTE_WHEN_PAUSE		  
  		  Mute_Ext_PA(UNMUTE);
#endif		   
	 }
#endif		
	 clear_super_mute_lock();

        write_info(MEM_VOL,my_music_vol);
	 my_main_vol(my_music_vol);	
	 Disp_Con(DISP_VOL);
        break;			
#if RTC_ENABLE 
	case INFO_ALM_BELL :					   ///<闹钟响消息,进入闹钟循环
		sys_clock_pll();
		dac_out_select(DAC_DECODE);
		if(alm_bell_mode())
		{
			dac_out_select(DAC_AMUX0);
			return;
		}		
		dac_out_select(DAC_AMUX0);
	break;
#endif
        default :
_HOT_KEY_HDLR:			        
            if (!ap_handle_hotkey(key))
                return;
        }
    }
}
/*----------------------------------------------------------------------------*/
void usb_device(void)
{
    u8 key;
    u8 connect_counter = 0;
    bool usb_con = 0;

    while (1)
    {
#if ((USB_DEVICE_CFG & USB_MASS) == USB_MASS)
        UFI_massstorage();
#endif
#if ((USB_DEVICE_CFG & USB_SPEAKER) == USB_SPEAKER)
        key_voice_en=1;
        dac_out_select(DAC_MUSIC, 0);
#endif

        key = app_get_msg();
        if (alm_request_cnt)
        {
            key = alm_request_msg_convert(key);
        }
        switch (key)
        {

#if ((USB_DEVICE_CFG & USB_SPEAKER) == USB_SPEAKER)
#if (MUSIC_SPECTRUM_EN == 1)
        case MSG_100MS:
            if (cur_menu == MENU_USBDEV_MAIN)
            {
                music_spec_cul(1);
                disp_port(MENU_100MS_REFRESH);
            }
            break;
#endif

        /*  case MSG_MUSIC_NEXT_EQ:
              eq_mode++;
              if (eq_mode > CLASSIC)
              {
                  eq_mode = NORMAL;
              }
              //set_dsp_eq(eq_mode);
          	set_eq(eq_mode);
              disp_port(MENU_SET_EQ);
              break;	 */

        case MSG_PC_MUTE:
            dac_mute_control(1,1);
            break;
        case MSG_PC_UNMUTE:
            dac_mute_control(0,1);
            break;
#else
        case MSG_VOL_UP:
            break;

        case MSG_VOL_DOWN:
            break;
#endif


#if ((USB_DEVICE_CFG & USB_HID) == USB_HID)
        case MSG_MUSIC_PP:
            //Usb_Audio_Mute_Ctl();
            usb_hid_control(USB_AUDIO_PP);
            break;

        case MSG_MUSIC_NEXT_FILE:
            usb_hid_control(USB_AUDIO_NEXTFILE);
            break;

        case MSG_MUSIC_PREV_FILE:
            usb_hid_control(USB_AUDIO_PREFILE);
            break;

#endif

        case MSG_USB_PC_OUT:
            Set_Curr_Func(SYS_MP3DECODE_USB);
            return;

        case MSG_HALF_SECOND:
            if (!usb_con)
            {
                connect_counter++;
                if(USBCON0 & BIT(6))
                    usb_con = 1;
                else if (connect_counter > 4)
                    return;
            }
            //printf("alm_request_cnt:%u,main_menu_conter:%u\n",(u16)alm_request_cnt,(u16)main_menu_conter);
            if (alm_request_cnt)
            {
                alm_request_cnt++;
                disp_port(MENU_ALM_REQUEST);
                if (alm_request_cnt > 60)
                {
                    alm_request_cnt = 0;
                    Set_Curr_Func(SYS_RTC);
                    put_msg_lifo(MSG_CHANGE_WORK_MODE);
                }
                break;
            }
            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);
            }
            break;
#if RTC_ENABLE
        case MSG_CHANGE_WORK_MODE:
            if (alm_cnt)
            {
                return;
            }
            break;

        case MSG_REQUEST_Y:
            alm_request_cnt = 0;
            Set_Curr_Func(SYS_RTC);
            put_msg_lifo(MSG_CHANGE_WORK_MODE);
            break;
        case MSG_REQUEST_N:
            alm_request_cnt = 0;
            close_alarm();
            main_menu_conter = SUB_MENU_TIME;
            break;
        case MSG_ALM_ON:
            alm_request_cnt = 1;
            write_next_alm_sec();
            disp_port(MENU_ALM_REQUEST);
            break;
#endif

        default :
            ap_handle_hotkey(key);
            break;
        }

    }

}
/*----------------------------------------------------------------------------*/
void usb_audio_massstorage(void)
{
    device_check();
    if (pc_connect)
    {
        input_number_en = 0;
        vol_change_en=1;
        //sd_speed_init(0, 100);
        main_menu = MENU_USBDEV_MAIN;
        disp_port(MENU_USBDEV_MAIN);
        usb_config(USB_DEVICE_CFG);
        write_protect_set(0);                           //不使用写保护功能,如果需要,请根据卡座写保护的状态改变配置
        SYSTEM_CLK_DIV1();
        init_usb_device_hardware();
#if((PLL_IN_HPRC == INPUT_OSC_SELECT) && USE_SOF_PLL)
        {
            u8 flag;
            flag = correct_hprc();
            if(1 == flag)			 ///<限定时间内,校准通过,保存矫正值
            {
                write_hprc_cnt(MEM_PLLCON0, memery_hprc_cnt);
//			deg_string("secuss\n");
            }
            else if(0 == flag)		  ///<校准时USB线拔出
            {
                work_mode = MUSIC_MODE;
                IE1 &= ~BIT(1);
                P3PU &= ~BIT(6);
//			deg_string("unsecuss\n");
                return;
            }
            else if(2 == flag)		 ///<限定时间内,校准失效,可继续相应功能
            {
//			work_mode = MUSIC_MODE;
//			IE1 &= ~BIT(1);
//        	P3PU &= ~BIT(6);
//			return;
            }
        }
#endif
        key_table_sel(0);
        flush_all_msg();
#if ((USB_DEVICE_CFG & USB_SPEAKER) == USB_SPEAKER)
        set_eq(eq_mode);
#endif
        alm_request_cnt = 0;
        set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量
        usb_device();
        recording_end();
        dac_mute_control(0,1);		 ///<退出PC后,关掉DAC MUTE。
#if ((USB_DEVICE_CFG & USB_SPEAKER) == USB_SPEAKER)
        main_vol_set(0, CHANGE_VOL_NO_MEM);
#endif
        IE1 &= ~BIT(1);
        P3PU &= ~BIT(6);
    }
    else
    {
        work_mode++;
        Set_Curr_Func(work_mode);
    }
}
예제 #11
0
/*----------------------------------------------------------------------------*/
void music_play(void)
{
    u8 key;
    u8 res;
	
    while (1)
    {
#if (FF_FR_MUSIC == 0)
        if (play_status == MAD_PLAY)
        {
            dac_out_select(DAC_MUSIC, 0);
        }
#else
        if ((play_status == MAD_PLAY) || (play_status == MAD_FF) || (play_status == MAD_FR))
        {
            dac_out_select(DAC_MUSIC, 0);
        }
#endif
        //suspend_sdmmc();						//可减少SDMMC功耗,但会增加电源波动
        key = app_get_msg();

        switch (key)
        {
        case MSG_CHANGE_WORK_MODE:
            //backup_music_point();
           break;
           // return;

        case MSG_DEVICE_REMOVED:
        	device_check();
        	disk_remove_deal_for_music();
		stop_decode();
	 	dev_remov_timer=8;
		
            break;

        case MSG_MUSIC_NEW_DEVICE_IN:							//有新设备接入
            //backup_music_point();
            flush_all_msg();
            given_file_method = PLAY_FIRST_FILE;
	case MSG_MUSIC_SELECT_NEW_DEVICE:					        //重新选择设备
            res = find_device(given_device);

            if ((res == DEV_INIT_ERR) ||
                    (res == NO_DEFINE_DEV))                    //指定的设备不在线,或初始化失败
            {
			disk_toc_ok=0;
			dev_invalid=1;
		    //Set_Curr_Func(SYS_IDLE);
       	    //put_msg_lifo(MSG_CHANGE_WORK_MODE);      
	            break;
				
                //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 defined(NO_DEV_DEFAULT_GO_TO_AUX)
		 //Set_Curr_Func(SYS_AUX);
#elif defined(NO_DEV_DEFAULT_GO_TO_IDLE)
		// Set_Curr_Func(SYS_IDLE);
        	 //put_msg_fifo(MSG_NO_DEVICE);	 
#else
		 //Set_Curr_Func(SYS_FMREV);
#endif

			disk_toc_ok=0;
			dev_invalid=1;

		 //Set_Curr_Func(SYS_IDLE);
       	 //put_msg_lifo(MSG_CHANGE_WORK_MODE);      
	        break;

            }
            else
                put_msg_lifo(MSG_MUSIC_SELECT_NEW_FILE);		//找到可用设备

	     first_init_dev =1;

            break;

        case MSG_MUSIC_SELECT_NEW_FILE:

#if 0
            if (device_check() == 0)                                //当前播放设备已经不在线,则自动选取下一个设备
            {
#if 1
			disk_toc_ok=0;
	    	 //Set_Curr_Func(SYS_IDLE);
	        //put_msg_lifo(MSG_CHANGE_WORK_MODE);      
#else            
                given_device = DEVICE_AUTO_NEXT;
                put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
#endif				
                break;
            }
#endif
            res = fs_get_filenum(play_mode, given_file_method);

#if 0
            if (res == GET_DEVICE_END)								//下一曲到设备的结束,查找下一个设备的第一首
            {
                given_file_method = PLAY_FIRST_FILE;
                given_device = DEVICE_AUTO_NEXT;
                put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
                break;
            }
            else if (res == GET_DEVICE_HEAD)								//上一曲到设备的结束,查找下一个设备的最后一首
            {
                given_file_method = PLAY_LAST_FILE;
                given_device = DEVICE_AUTO_PREV;
                put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE);
                break;
            }
#endif
	     if(res == GET_DEVICE_END){

	              given_file_method = PLAY_FIRST_FILE;	 	
	     		put_msg_lifo(MSG_MUSIC_STOP);
			break;
	     }

            put_msg_lifo(MSG_MUSIC_PLAY_NEW_FILE);
            break;

        case MSG_MUSIC_PLAY_NEW_FILE:									//按文件序号选择文件进行播放

            flush_all_msg();
            stop_decode();
            cipher_ctl(0);
            res = fs_getfile_bynumber(0, &fat_ptr1, given_file_number);
            disp_port(MENU_FILENUM);

            if (res == 0)
            {
                if (given_file_method == PLAY_BREAK_POINT)
                    res = start_decode();
                else
                    res = start_decode();
            }

            if (res != 0)                                       //播放不成功
            {
                play_status = MAD_STOP_WAIT;
                play_delay_time = 0;
                if (given_file_method <= PLAY_BREAK_POINT) 		//重新找下一首
                {
                    given_file_method = PLAY_NEXT_FILE;
                    break;
                }
                else											//重新找上一首
                {
                    given_file_method = PLAY_PREV_FILE;
                    break;
                }
            }
            main_menu = MENU_MUSIC_MAIN;
            write_file_info();

            break;

        case MSG_DECODE_FILE_END:


            if ((dec_msg->play_time >= 5) || (play_status == MAD_FF) || (play_status == MAD_FR))     //当前歌曲的播放时间大于5S时,直接播放下一首
            {         
                	given_file_method = PLAY_AUTO_NEXT;
                	put_msg_lifo(MSG_MUSIC_SELECT_NEW_FILE);
            }
            else													//当前歌曲播放时间小于5S,有可能是不坏歌曲,等待一段时间
            {
                	play_delay_time = 0;
                	given_file_method = PLAY_AUTO_NEXT;
                	play_status = MAD_STOP_WAIT;
            }

    	     if(play_mode == REPEAT_OFF){
			
		    if(given_file_number ==  fs_msg.fileTotal){
				
	            		flush_all_msg();			
				stop_decode();
	    	   }   
    	     }   
            break;

        case MSG_MUSIC_PREV_FILE:												//选择上一个文件进行播放

            given_file_method = PLAY_PREV_FILE;
            put_msg_lifo(MSG_MUSIC_SELECT_NEW_FILE);
            break;

        case MSG_MUSIC_NEXT_FILE:												//选择下一个文件进行播放

            //delay_10ms(30);
            given_file_method = PLAY_NEXT_FILE;
            put_msg_lifo(MSG_MUSIC_SELECT_NEW_FILE);
            break;
#if defined(DECODE_STOP_MODE_ENABLE	)
	case MSG_MUSIC_STOP:

		if(play_status !=MAD_STOP){
            		flush_all_msg();
			stop_decode();
		}
		break;
#endif		
        case MSG_MUSIC_PP:											//暂停和播放
            if (cur_menu == MENU_INPUT_NUMBER)			            //数字输入模式
            {
                put_msg_lifo(MSG_PICH_SONG);
                break;
            }
			
#if defined(DECODE_STOP_MODE_ENABLE	)			
	    if(play_status ==MAD_STOP){
			
	        	device_check();
				
			if(DSA_SEL_DEV == DEVICE_SDMMC0){
				if((device_online&BIT(0))==0){
					break;
				}	
			}
			else if (DSA_SEL_DEV == DEVICE_UDISK){
				if((device_online&BIT(1))==0){
					break;
				}	
			}
			
                    	given_file_method = PLAY_FIRST_FILE;
                    	put_msg_lifo(MSG_MUSIC_SELECT_NEW_FILE);

			play_status = MAD_PLAY;
			break;
	    }
#endif
            if (play_status == MAD_PLAY)
            {
                disp_port(MENU_PAUSE);
                main_menu = MENU_PAUSE;
                mad_control(MAD_PAUSE, 0);
                play_status = MAD_PAUSE;
 // 		  set_play_flash(LED_FLASH_ON);

            }
            else if (play_status == MAD_PAUSE)
            {
                main_menu = MENU_MUSIC_MAIN;
                disp_port(MENU_MUSIC_MAIN);
                mad_control(MAD_PLAY, 0);
                play_status = MAD_PLAY;
 // 		  set_play_flash(LED_FLASH_NOR);				
            }

            flush_all_msg();
            break;

        case MSG_MUSIC_NEXT_EQ:
            if (play_status == MAD_PAUSE)
                break;
            eq_mode++;
            if (eq_mode > CLASSIC)
            {
                eq_mode = NORMAL;
            }
            set_eq(eq_mode);
            disp_port(MENU_SET_EQ);
            break;

        case MSG_NEXT_PLAYMODE:
            if (play_status == MAD_PAUSE)
                break;
            play_mode++;
            if (play_mode > REPEAT_END)
            {
                play_mode = REPEAT_INIT;
            }
            //disp_port(MENU_SET_PLAY_MODE);
            break;

        case MSG_MUTE:												//静音
            break;

#if (FF_FR_EN == 1)
        case MSG_MUSIC_FR:											//启动快退
            if (find_break_point_file_flag)							//如果是记忆播放的歌曲,不能快退
            {

                break;
            }
            if (play_status == MAD_PLAY)
            {
                play_status = MAD_FR;
            }

            break;

        case MSG_MUSIC_FF:											//启动快进
            if (play_status == MAD_PLAY)
            {
                play_status = MAD_FF;
            }
            break;

		case MSG_KEY_CHANGE:
        case MSG_MUSIC_FFR_DONE:									//快进快退结束,恢复播放
            if (play_status == MAD_FR)
            {
                set_eq(eq_mode);
                flush_all_msg();
#if (FF_FR_MUSIC == 0)

                dac_mute_control(0);
#endif
                play_status = MAD_PLAY;
            }
            else if (play_status == MAD_FF)
            {
                set_eq(eq_mode);
                flush_all_msg();
#if (FF_FR_MUSIC == 0)

                dac_mute_control(0);
#endif
                play_status = MAD_PLAY;
            }

            break;
#endif
        case MSG_PICH_SONG:
            if (cur_menu == MENU_INPUT_NUMBER)			           //数字输入模式
            {
                if ((input_number <= fs_msg.fileTotal) && (input_number != 0))			   //输入数字是否有效
                {
                    given_file_number = input_number;
                    given_file_method = PLAY_FIRST_FILE;
                    given_device = DEVICE_AUTO_NEXT;
                    put_msg_lifo(MSG_MUSIC_PLAY_NEW_FILE);
                }
                else
                    disp_port(main_menu);
            }

            break;

#if (MUSIC_SPECTRUM_EN == 1)
        case MSG_100MS:
            if (cur_menu == MENU_MUSIC_MAIN)
            {
                music_spec_cul(1);
                disp_port(MENU_100MS_REFRESH);
            }
            break;
#endif

        case MSG_200MS:
////////////////////////////////////////////////////////////
//快进快退实际的操作在这里完成
#if (FF_FR_EN == 1)
            if (play_status == MAD_FF)
            {
#if (FF_FR_MUSIC == 0)							//如果需要在快进快退过程中听到声音,可以不加此行
                dac_mute_control(1);
#endif
                mad_control(MAD_FF, FF_FR_STEP);
                mad_control(MAD_FAST_FORWARD, 0);
#if (FF_FR_MUSIC == 1)

                dac_mute_control(0,1);
#endif
                mad_control(MAD_PLAY, 0);
            }
            else if (play_status == MAD_FR)
            {
#if (FF_FR_MUSIC == 0)
                dac_mute_control(1);							//如果需要在快进快退过程中听到声音,可以不加此行
#endif
                mad_control(MAD_FR, FF_FR_STEP);
                mad_control(MAD_FAST_REVERASE, 0);
#if (FF_FR_MUSIC == 1)
                dac_mute_control(0,1);
#endif
                mad_control(MAD_PLAY, 0);
            }
            disp_port(MENU_HALF_SEC_REFRESH);
#endif
#if (DISP_DOT_LCD == 1)
            disp_port(MENU_200MS_REFRESH);								//播放时的滚动显示
#endif
            break;

        case MSG_HALF_SECOND:
/////////////////////////////////////////////////////////////
//短歌曲或损坏的歌曲在这里跳到下一首
            if (play_status == MAD_STOP_WAIT)				//等待一段时间再自动选择下一首
            {
                if (play_delay_time < 4)
                    play_delay_time++;
                else
                {
                    put_msg_lifo(MSG_MUSIC_SELECT_NEW_FILE);
                }
            }

		if(dev_remov_timer>0){

			dev_remov_timer--;
			if(dev_remov_timer==0){
			    	 Set_Curr_Func(SYS_IDLE);
			        put_msg_lifo(MSG_CHANGE_WORK_MODE);      
			}
		}
////////////////////////////////////////////////////////////
//显示界面的切换
            if (main_menu_conter < SUB_MENU_TIME)
            {
                main_menu_conter++;
            }
            else if (cur_menu != main_menu)
            {
                if (cur_menu == MENU_INPUT_NUMBER)			//数字输入模式
                {
                    put_msg_lifo(MSG_PICH_SONG);
                    break;
                }
                else
                {
                    cur_menu = main_menu;
                }
                disp_port(cur_menu);
            }
/////////////////////////////////////////////////////////////
//调整显示亮度
            set_brightness_fade_out();
/////////////////////////////////////////////////////////////
//更新实时界面
            disp_port(MENU_HALF_SEC_REFRESH);
            break;
        case MSG_NEXT_FOLDER:
	     select_folder_file(FIND_NEXT_DIR);		
            break;
        case MSG_PREV_FOLDER:
	     select_folder_file(FIND_PREV_DIR);		
            break;
#if 0//RTC_ENABLE
        case MSG_ALM_ON:
            write_next_alm_sec();
            Set_Curr_Func(SYS_RTC);
            put_msg_lifo(MSG_CHANGE_WORK_MODE);
            break;
#endif
        default :
            ap_handle_hotkey(key);
            break;
        }
    }
}
예제 #12
0
/*----------------------------------------------------------------------------*/
static u8 start_decode(void)
{
    cipher_judge();

    mad_control(MAD_STOP, 0);
    decode_init();									//解码初始化,会将解码的变量及状态清零
    music_type = music_format_check(decode_buffer);	//检查文件格式

    if (music_type == NOT_SUPPORT)					//不支持的格式
    {
        return 1;
    }
    else if (music_type == IS_MP3)					//MP3
    {

        get_music_tag();
        if (!get_mp3_total_time())
            return 1;
    }
    else
        get_music_tag();

    if (dec_msg->total_time == 0)					//总播放时间为0,则不进行播放,如果遇到因为添加了此判断而不能播放的文件,则可去掉此条件
    {
        return 1;
    }

    set_eq(eq_mode);

#if (BREAK_POINT_PLAY_EN == 1)
    if (find_break_point_file_flag) 								//取保存过的断点信息
    {
        find_break_point_file_flag = load_music_point();
    }
#endif
	dsp_set_dcc_flt(14);
    dsp_set_ch_mode(0);
    dsp_set_rinv_mode(0);
    mad_control(MAD_INIT, 0);
    mad_control(MAD_PLAY, 0);
    play_status = MAD_PLAY;
	
    if (device_active == DEVICE_SDMMC0)
    {
	 Set_Curr_Func(SYS_MP3DECODE_SD);
    }
    else if (device_active == DEVICE_UDISK)
    {

	 Set_Curr_Func(SYS_MP3DECODE_USB);
    }	

      if(first_init_dev){
		first_init_dev =0;

		if(play_status !=MAD_STOP){
            		flush_all_msg();
			stop_decode();
		}
		
      }
	disk_toc_ok=1;
	DSA_clr_ID3_info();
 // set_play_flash(LED_FLASH_NOR);
    return 0;
}
예제 #13
0
void deal_rtc(void)
{
    u8 key;
#ifdef USE_RTC_YEAR_FUNCTION
    bool date_show_active=0;
#endif
#ifdef TURN_OFF_PLAY_STATUS_LED_IN_RTC_MODE
	set_play_flash(LED_FLASH_STOP);
#endif

#ifdef PWR_OFF_IN_RTC_MODE_AFTER_30_MIN
#if defined(USE_TIMER_POWER_OFF_FUNC)
	timer_pwr_idx=3;
	timer_disp=30;
#endif
#endif
    while (1)
    {
        key = get_msg();
        switch (key)
        {
#if defined(K820_LHD_820_V001)
    	case INFO_EQ_DOWN| KEY_SHORT_UP :

		  if(rtc_set==0){

                	rtc_mode = RTC_SET_MODE;
	            	rtc_set=3;
		  }
                else if (rtc_set==4)
                {
	            	rtc_set=0;
                	rtc_mode = RTC_PLAY_MODE;
		  }
		  else if(rtc_set==3){
	            	rtc_set=4;
		  }

		Disp_Con(DISP_RTC);
			
		break;
#endif

#if defined(K686_ZhengYang_686_V001)||defined(USE_MODE_LONG_FOR_RTC_SETTING)
        case INFO_MODE | KEY_LONG:				//4RTC闹钟设置模式
#elif defined(CUSTOM_KEY_LONG_FOR_RTC_HOTKEY)
    case INFO_CUS_KEY_1 | KEY_LONG:  
#elif defined(USE_PLAY_LONG_FOR_RTC_SETTING)
    case INFO_PLAY | KEY_LONG:    		
#elif defined(USE_PREV_LONG_FOR_RTC_SETTING)
        case INFO_PREV_FIL | KEY_LONG:				//4RTC闹钟设置模式
#elif defined(USE_PLAY_MODE_LONG_FOR_RTC_SETTING)
        case INFO_PLAY_MODE | KEY_LONG:				//4RTC闹钟设置模式
#elif defined(MINI_DIGIT_BOX)        
	case INFO_1|KEY_LONG:        
#elif defined(RTC_MODE_HOT_KEY_ENABLE)		
    case INFO_RTC_MOD | KEY_SHORT_UP:        
#else
        case INFO_PLAY | KEY_LONG:				//4RTC闹钟设置模式
#endif

#if defined(RTC_SETTING_OP_TIMER_ENABLE)
		op_timer=0;			
#endif

#ifdef INDEPENDENT_KEY_ADJ_TIME

		if (rtc_mode != ALM_UP_MODE)
		{
	           if (rtc_mode==RTC_PLAY_MODE)
	           {
#ifdef USE_RTC_TIME_ONLY
		            	rtc_set=3;
#else
		            	rtc_set=0;
#endif
	                	rtc_mode = RTC_SET_MODE;
	           }
		    else if(rtc_mode==RTC_SET_MODE){
				goto __TIME_ADJ_POS;	
		    }
	           else if (rtc_mode == ALM_SET_MODE)
	           {
				goto __TIME_ADJ_POS;	
		    } 
			   
		    Disp_Con(DISP_RTC);			
		}	
#elif defined(NEW_RTC_SETTING_CTRL)
		if (rtc_mode != ALM_UP_MODE)
		{
			if(new_rtc_setting==0){
				rtc_mode=RTC_SET_MODE;
		            	rtc_set=3;
			}
			else if(new_rtc_setting==1){

				rtc_mode=RTC_SET_MODE;
		            	rtc_set=0;
			}
			else if(new_rtc_setting==2){

				rtc_mode=RTC_SET_MODE;
		            	rtc_set=1;
			}
			else if(new_rtc_setting==3){
				
				rtc_mode=ALM_SET_MODE;
		            	alm_set=1;			

			}
			else if(new_rtc_setting==4){
				
				rtc_mode=ALM_SET_MODE;
		            	alm_set=0;			
			}

	            	Disp_Con(DISP_RTC);
        	}
#else

#ifdef K3031_AP_668_V001
            	if (rtc_mode==ALM_SET_MODE){

			if(alm_set==0){
				alm_set=1;
				break;
			}
        	}
#endif

#if defined(K820_LHD_820_V001)
			break;
#endif
		if (rtc_mode != ALM_UP_MODE)
		{
#if defined(MINI_DIGIT_BOX)   
            	if (rtc_mode==RTC_SET_MODE)
            	{
                	rtc_mode = RTC_PLAY_MODE;
            	}
		else{
			rtc_mode=RTC_SET_MODE;
		}
		op_timer=0;	
#else		
            	rtc_mode++;
	#ifdef USE_RTC_ALARM_FUNCTION				
            	if (rtc_mode>ALM_SET_MODE)
            	{
                	rtc_mode = RTC_PLAY_MODE;
            	}
	#else
            	if (rtc_mode>RTC_SET_MODE)
            	{
                	rtc_mode = RTC_PLAY_MODE;
            	}	
	#endif
#endif

#ifdef USE_RTC_TIME_ONLY
            	rtc_set=3;
#else
            	rtc_set=0;
#endif
            	alm_set=0;

            	Disp_Con(DISP_RTC);
		}
#endif		
            break;
#if defined(MINI_DIGIT_BOX)        
 			
	case INFO_6|KEY_LONG:
		if (rtc_mode != ALM_UP_MODE)
		{
	            	//rtc_mode++;		
	            	if (rtc_mode==ALM_SET_MODE)
	            	{
	                	rtc_mode = RTC_PLAY_MODE;
	            	}
			else{

	                	rtc_mode = ALM_SET_MODE;
		            	alm_set=1;

			}
            	}
		op_timer=0;			

            	  Disp_Con(DISP_RTC);
		break;
	case INFO_2|KEY_LONG:
                rtc_mode = ALM_SET_MODE;
	         alm_set=0;
		  alm_sw =~alm_sw;
            	  Disp_Con(DISP_RTC);
		op_timer=0;			
				  
		break;
#endif

#ifdef INDEPENDENT_KEY_ADJ_TIME

#ifdef RTC_MODE_HOT_KEY_ENABLE
    	case INFO_RTC_MOD | KEY_LONG: 
#else
	case INFO_PLAY | KEY_SHORT_UP:		
#endif		
            	if (rtc_mode==RTC_PLAY_MODE)
            	{
	            	alm_set=0;
                	rtc_mode = ALM_SET_MODE;
            	}
		Disp_Con(DISP_RTC);
		   
		break;
#elif defined(USE_NEXT_LONG_FOR_ALM_SETTING)
        case INFO_NEXT_FIL | KEY_LONG:				//4RTC闹钟设置模式	
                    	if (rtc_mode==RTC_PLAY_MODE)
            	{
	            	alm_set=0;
                	rtc_mode = ALM_SET_MODE;
            	}
		Disp_Con(DISP_RTC);
		   
		break;
#endif

#if defined(K686_ZhengYang_686_V001)||defined(USE_POWER_KEY_TO_ADJ_HOUR_AND_MIN)
        case INFO_POWER| KEY_SHORT_UP:
#elif defined(USE_MODE_LONG_FOR_RTC_SETTING)
        case INFO_MODE| KEY_SHORT_UP:
		if(rtc_mode == RTC_PLAY_MODE){
			goto _HOT_KEY_HDLR;
		}
#elif defined(CUSTOM_KEY_LONG_FOR_RTC_HOTKEY)
    case INFO_CUS_KEY_1 | KEY_SHORT_UP:       
#elif defined(MINI_DIGIT_BOX)        
	case INFO_1|KEY_SHORT_UP:
	case INFO_6|KEY_SHORT_UP:	
		op_timer=0;			
#else
        case INFO_PLAY| KEY_SHORT_UP:
#endif

#if defined(RTC_SETTING_OP_TIMER_ENABLE)
		op_timer=0;			
#endif

#if defined(NEW_RTC_SETTING_CTRL)
		if ((rtc_mode != ALM_UP_MODE)&&(rtc_mode !=RTC_PLAY_MODE))
		{
			if(new_rtc_setting==0){
				rtc_mode=RTC_SET_MODE;
	            		rtc_set++;

				if(rtc_set>4){
					rtc_mode=RTC_PLAY_MODE;
				}
			}
			else if(new_rtc_setting==1){

				rtc_mode=RTC_PLAY_MODE;
				Disp_Con(DISP_RTC_DATE);	
				break;				
			}
			else if(new_rtc_setting==2){

				rtc_mode=RTC_SET_MODE;
	            		rtc_set++;

				if(rtc_set>2){

					Disp_Con(DISP_RTC_DATE);
					rtc_mode=RTC_PLAY_MODE;
					break;
				}
			}
			else if(new_rtc_setting==3){
				
				rtc_mode=ALM_SET_MODE;
		            	alm_set++;			
				if(alm_set>2){

					Disp_Con(DISP_RTC_DATE);
					rtc_mode=RTC_PLAY_MODE;
					break;					
				}
			}
			else if(new_rtc_setting==4){

				Disp_Con(DISP_RTC_DATE);	
				rtc_mode=RTC_PLAY_MODE;
				alm_set=0;	
				break;
			}

			  Disp_Con(DISP_RTC);

        	}
#else
#if defined(K820_LHD_820_V001)
			break;
#endif
__TIME_ADJ_POS:
            if (rtc_mode == RTC_SET_MODE)
            {
                rtc_set++;
                if (rtc_set>4)
                {
#ifdef USE_RTC_TIME_ONLY
	            	rtc_set=3;
#else
	            	rtc_set=0;
#endif                
#ifdef RTC_SETTING_NO_CYC
			rtc_mode = RTC_PLAY_MODE;
#endif
		  }
			Disp_Con(DISP_RTC);
            }
            else if (rtc_mode == ALM_SET_MODE)
            {
#ifdef K3031_AP_668_V001
		if(alm_set==0)break;
#endif
                alm_set++;
#if defined(ALARM_SEL_SOURCE)
                if (alm_set>3)
#elif defined(ALARM_ADJ_VOL)
                if (alm_set>3)
#else
                if (alm_set>2)
#endif					
                {
#ifdef K3031_AP_668_V001
                    alm_set=1;
#else                
                    alm_set=0;
#endif
#ifdef RTC_SETTING_NO_CYC
			rtc_mode = RTC_PLAY_MODE;
#endif					
                }
		  Disp_Con(DISP_RTC);
            } 
#endif			
            break;
#ifdef ADJ_TIME_USE_VOL_KEY			
        case INFO_VOL_PLUS:
#ifdef RTC_ADJ_VOL
            if (rtc_mode==RTC_PLAY_MODE)
		goto _HOT_KEY_HDLR;
#endif						
			break;
        case INFO_VOL_PLUS | KEY_SHORT_UP:
        case INFO_VOL_PLUS | KEY_HOLD :			  //4RTC 设置模式下的时间选择(增加)
#else        
        case INFO_NEXT_FIL | KEY_SHORT_UP:
        case INFO_NEXT_FIL | KEY_HOLD:
			
#endif

#ifdef USE_NEXT_PREV_KEY_HOLD_FUNC_SKIP
		if(key==(INFO_NEXT_FIL | KEY_HOLD)) break;
#endif

#if defined(MINI_DIGIT_BOX)||defined(RTC_SETTING_OP_TIMER_ENABLE)
		op_timer=0;			
#endif
            if (rtc_mode==RTC_SET_MODE)
            {
                curr_date_plus();
                set_date_sec();
                fond_alm_clk();
		  Disp_Con(DISP_RTC);
            }
            else if (rtc_mode==ALM_SET_MODE)
            {
#ifdef ALARM_SEL_SOURCE
                if (alm_set==3){

			alm_source++;
			if(alm_source>ALM_SOUR_FM){
				alm_source=ALM_SOUR_USB;
			}
		   	Disp_Con(DISP_RTC);
			break;
		  }
#elif defined(ALARM_ADJ_VOL)
                if(alm_set==3){

		        my_music_vol++;

			 clear_super_mute_lock();

		        if (my_music_vol > MAX_VOL)
		        {
		            my_music_vol = MAX_VOL;
		        }
	  	}
#endif
                 alm_time_plus();
                 set_alm_sec();
		   Disp_Con(DISP_RTC);
            }
            else
	     {
#ifdef RTC_ADJ_VOL
		goto _HOT_KEY_HDLR;
#endif
#ifdef NEW_RTC_SETTING_CTRL

		new_rtc_setting++;

		if(new_rtc_setting>4){
			new_rtc_setting=0;
		}
				
		if(new_rtc_setting==0){
			
			Disp_Con(DISP_RTC);
		}
		else{
			
			Disp_Con(DISP_RTC_DATE);
		}
#else
#ifdef USE_RTC_YEAR_FUNCTION
		date_show_active = 1;	
		Disp_Con(DISP_RTC_DATE);	
#endif
#endif
	    }
            break;
#ifdef ADJ_TIME_USE_VOL_KEY			
        case INFO_VOL_MINUS:
#ifdef RTC_ADJ_VOL
            if (rtc_mode==RTC_PLAY_MODE)
		goto _HOT_KEY_HDLR;
#endif			
			break;
        case INFO_VOL_MINUS| KEY_SHORT_UP:
        case INFO_VOL_MINUS | KEY_HOLD :		   //4RTC 设置模式下的时间选择(减少)
#else			
        case INFO_PREV_FIL | KEY_SHORT_UP:
        case INFO_PREV_FIL | KEY_HOLD:
#endif

#ifdef USE_NEXT_PREV_KEY_HOLD_FUNC_SKIP
		if(key==(INFO_PREV_FIL | KEY_HOLD)) break;
#endif

#if defined(MINI_DIGIT_BOX)||defined(RTC_SETTING_OP_TIMER_ENABLE)        
		op_timer=0;			
#endif
            if (rtc_mode==RTC_SET_MODE)
            {
                curr_date_minus();
                set_date_sec();
                fond_alm_clk();
		  Disp_Con(DISP_RTC);
            }
            else if (rtc_mode==ALM_SET_MODE)
            {
#ifdef ALARM_SEL_SOURCE
                if (alm_set==3){
					
			if(alm_source--==ALM_SOUR_USB){
				alm_source=ALM_SOUR_FM;
			}
		   	Disp_Con(DISP_RTC);
			break;
		  }
#elif defined(ALARM_ADJ_VOL)
                if(alm_set==3){
					
		        if (my_music_vol)
		            my_music_vol--;

			 clear_super_mute_lock();

			 if(my_music_vol == MIN_VOL){
				Mute_Ext_PA(MUTE);
			 }
	 	}				
#endif
                	alm_time_minus();
               	set_alm_sec();
			Disp_Con(DISP_RTC);
            }
            else
	     {
#ifdef NEW_RTC_SETTING_CTRL

		new_rtc_setting--;
		if(new_rtc_setting>4){
			new_rtc_setting=4;
		}
		
		if(new_rtc_setting==0){
			
			Disp_Con(DISP_RTC);
		}
		else{
			
			Disp_Con(DISP_RTC_DATE);
		}
#else
#ifdef USE_RTC_YEAR_FUNCTION
		date_show_active = 1;		
		Disp_Con(DISP_RTC_DATE);
#endif
#endif
	    }
            break;

#if defined(MINI_DIGIT_BOX)   			
#if defined(USE_SNOOZE_FUNC)        
	case INFO_7|KEY_SHORT_UP:
            if (alm_flag>0)						 //4闹钟响后默认增加一天秒数
            {
		  set_snooze_func();				            
                close_alm_bell();
                Disp_Con(DISP_RTC);
            }
            break;		
#endif		
#endif		

        case INFO_EQ_UP | KEY_SHORT_UP:			 //4清除闹钟
            if (alm_flag)						 //4闹钟响后默认增加一天秒数
            {
#if defined(USE_SNOOZE_FUNC)        
		  set_snooze_func();				            
#endif		
                close_alm_bell();
                Disp_Con(DISP_RTC);
            }
            break;

        case INFO_HALF_SECOND :
#if ((USE_DEVICE == MEMORY_STYLE)&&(FAT_MEMORY))          
             updata_fat_memory();
#endif            
			
#if defined(AD_MEASURE_TEMP_FUNC)
		adc_diode_temp_measure_hdlr();
#endif
#ifdef DISP_BACKLIGHT_AUTO_SAVE_POWER
	 	Disp_BL_time_out();
#endif

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

#ifdef USE_MICPHONE_GPIO_DETECTION
		if(get_mic_online_status()){
			Disp_Con(DISP_MIC);
			break;
		}
#endif
            if ((DISP_ALM_UP == curr_menu) || (alm_flag>0))
            {
                if (alm_flag>=60)
                {
                    close_alm_bell();
                    return_cnt = (RETURN_TIME);
#ifdef RTC_ALRM_MEM_LAST_WORK_MODE
			Set_Curr_Func(last_work_mode);
			return;
#endif
		      
                }
                else if (alm_flag)
                {
			rtc_mode = ALM_UP_MODE;
                    alm_flag++;
                    //key_voice_disable = 1;
    		      Mute_Ext_PA(UNMUTE);
    		      set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL);			//设置RTC模式的音量上限
    			dac_out_select(DAC_DECODE);				  
                    sys_clock_pll();
		      my_main_vol(my_music_vol);	
                    write_dsp(-3, 10, 0x10);
#ifdef ALM_UP_DISP_TIME
                    Disp_Con(DISP_RTC_POINT);
#else
                    Disp_Con(DISP_ALM_UP);
#endif
#ifdef ALM_ON_FLASH_SCR
			alm_flash_flag=~alm_flash_flag;
		     if(alm_flash_flag){
                    	  Disp_Con(DISP_PWR_OFF);
		      }
#endif
#if defined(USE_BAT_MANAGEMENT)
			bmt_hdlr();
#endif
		      //delay_10ms(10);
                    break;
                }					
            }


            if ((rtc_mode==RTC_PLAY_MODE)||(rtc_mode==ALM_UP_MODE))					//4除闹钟模式外一直更新now_time
            {
                  get_curr_date();
                  chk_date_err();
                    //Disp_Con(DISP_RTC);
            }
#if defined(MINI_DIGIT_BOX)||defined(RTC_SETTING_OP_TIMER_ENABLE)
	     rtc_setting_key_hdlr();
#endif
            if (return_cnt < (RETURN_TIME))
            {
                return_cnt++;
            }
            if ((RETURN_TIME) == return_cnt)
            {
                if ((DISP_RTC != curr_menu) || (0 != rtc_mode))
                {
		      rtc_set = 0;
    		      alm_set = 0;
                    rtc_mode = 0;
#if defined(NEW_RTC_SETTING_CTRL)
			new_rtc_setting=0;
#endif			
                    get_curr_date();
                    Disp_Con(DISP_RTC);
                }
		
#ifdef USE_RTC_YEAR_FUNCTION			
	     date_show_active=0;
#endif				
            }	

#ifdef RTC_ADJ_VOL
		  if(DISP_VOL == curr_menu){
		  }
		  else
#endif				
			
#ifdef USE_RTC_YEAR_FUNCTION			
	     if(!date_show_active)
#elif defined(NEW_RTC_SETTING_CTRL)
	     if((rtc_mode == RTC_PLAY_MODE)&&(new_rtc_setting>0)){
			break;
		 }
		 	
#endif
		{
            		Disp_Con(DISP_RTC_POINT);
		}
#if defined(USE_BAT_MANAGEMENT)
		bmt_hdlr();
#endif

            break;

        default :
_HOT_KEY_HDLR:			
            if (!ap_handle_hotkey(key))
            {
                close_alm_bell();
                return;
            }
        }
    }
}