示例#1
0
/*******************************************************************************
* Function Name  : bt_reset
* Description    : bt_reset
* Input          : none
* Output         : None
* Return         : none
*******************************************************************************/
void bt_reset(void)
{
    BT_PWR_OFF();
    BT_PWR_ON();
    delay_ms(100);
    BT_ENTER_RST();
    delay_ms(200);
    BT_EXIT_RST();
}
void iphone_func(void)
{
#if defined(K000_XingChuang_x821_V001)
	charger_iphone_ctrl();
#endif
    Mute_Ext_PA(MUTE);	

    set_play_flash(LED_FLASH_ON);
    Disp_Con(DISP_IPOD);
    PT1 = 1;										//timer1 interrupt 低优先级
    flush_low_msg();
    play_status = 0;

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

    sysclock_div2(1);
	
#ifdef BLUETOOTH_GPIO_CTRL
#ifndef SYS_BT_TURN_OFF_PWR_CHECK
    BT_PWR_OFF();
#endif 
#endif 

    open_uart_ctrl();
    ipone_hdlr();
#if defined(TURN_OFF_IPOD_WHEN_LEAVE_IPHONE_DOCK)
	delay_10ms(10);
	IPOD_STOP;
	delay_10ms(1);
     	IPOD_RELEASE;	
	delay_10ms(1);	
#endif	
    close_uart_ctrl();

    main_vol_set(0, CHANGE_VOL_NO_MEM);

    sys_clock_pll();

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

#if defined(K000_XingChuang_x821_V001)
    wkup_pin_ctrl(0);
#endif
	
}
示例#3
0
/*******************************************************************************
* Function Name  : BT_Init
* Description    : BT_Init IO配置,初始化。
* Input          : none
* Output         : None
* Return         : none
*******************************************************************************/
void BT_Init(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);

    GPIO_InitStructure.GPIO_Pin = BT_PWR_PIN | BT_AT_PIN | BT_RST_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA, &GPIO_InitStructure);

    GPIO_InitStructure.GPIO_Pin = BT_LINK_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
    GPIO_Init(GPIOA, &GPIO_InitStructure);

    BT_PWR_OFF();											// 开蓝牙电源
    BT_EXIT_RST();
}
/*----------------------------------------------------------------------------*/
void blue_tooth_main(void)
{
    u8 key;
#ifdef TURN_OFF_PLAY_STATUS_LED_IN_BLUETOOTH_MODE
    set_play_flash(LED_FLASH_STOP);
#endif

#ifdef K000_XC_BC_BT_V001
        play_status =MUSIC_PAUSE;
#endif
    while (1)
    {
        key = get_msg();
#if 0
	if(key!=0xFF)
	printf( "---->---deal_aux %x \r\n",(u16)key);
#endif
		
#if defined(KEY_PRESS_LED_INDICATOR)
	key_press_led_indicator(key);
#elif defined(CUSTOM_KEY_FEATURE_USE)
	custom_key_hdlr(key);
#endif
#ifdef BLUE_TOOTH_GPIO_STATUS
	if(blue_tooth_detect){
		blue_tooth_detect=0;
		bt_disp_status_hdlr();		
	}
#endif
#if defined(KPL_MSG_COMPATIBLE)
	kpl_msg_hdlr(key);
#endif

	 dac_sw_check();

 	switch (key)
        {

#ifdef BLUE_TOOTH_DETECTION_FOR_POWER_OFF
        case INFO_POWER|KEY_SHORT_UP:
	    sys_power_down();
	    break;
#endif 

#ifdef PP_KEY_LONG_CONFIG_BT
        case INFO_PLAY | KEY_LONG:
	     blue_tooth_key_hdlr(BT_CONFIG_HOLD);
		 break;
#endif
        case INFO_PLAY | KEY_HOLD:
#ifdef PP_KEY_LONG_CONFIG_BT
		 break;
	     //blue_tooth_key_hdlr(BT_CONFIG_HOLD);			
#else
	     blue_tooth_key_hdlr(BT_PP_HOLD);			
#endif
	     break;
        case INFO_PLAY | KEY_SHORT_UP :

	     blue_tooth_key_hdlr(BT_PP);
#ifndef BLUE_TOOTH_NO_SYS_MUTE_CTRL
#if !defined(BLUE_TOOTH_BYPASS)	 
            if (play_status == MUSIC_PAUSE)
            {
	         play_status =MUSIC_PLAY;
		  my_main_vol(my_music_vol);
#ifndef BLUE_TOOTH_PP_NOT_EXT_MUTE
  		  Mute_Ext_PA(UNMUTE);
#endif
            }
	     else if (play_status == MUSIC_PLAY){

	        play_status =MUSIC_PAUSE;
#ifndef BLUE_TOOTH_PP_NOT_EXT_MUTE	 	
  		Mute_Ext_PA(MUTE);		 	
#endif
		my_main_vol(0);	
	     }
#endif		 
#endif		 
            Disp_Con(DISP_BLUE_TOOTH);		 
	   break;        

        case INFO_NEXT_FIL | KEY_SHORT_UP:	
        	blue_tooth_key_hdlr(BT_NEXT_FILE);
		break;
		
        case INFO_PREV_FIL | KEY_SHORT_UP:
	     	 blue_tooth_key_hdlr(BT_PREV_FILE);
		 break;

        case INFO_HALF_SECOND :

#ifdef USE_USB_HOTPLUG_FUNC
		usb_hotplug_hdlr();
#endif
#ifdef BLUE_TOOTH_MUTE_DETECT_FUNC
		blue_tooth_mute_detect();
#endif
#if defined(USE_BAT_MANAGEMENT)
		bmt_hdlr();
#endif
#ifdef DISP_BACKLIGHT_AUTO_SAVE_POWER
	 	Disp_BL_time_out();
#endif

#ifdef BLUE_TOOTH_LINK_IDLE_POWER_OFF
		bt_link_idle_hdlr();
#endif

	    if(bt_key_release_cnt--==0){
#ifdef PP_KEY_HOLD_CONFIG_BT
		if(key_release_hdlr==BT_CONFIG_HOLD){

	     	 	blue_tooth_key_hdlr(BT_CONFIG_HOLD_RELEASE);
#else				
		if(key_release_hdlr==BT_PP_HOLD){
		
	     	 	blue_tooth_key_hdlr(BT_PP_HOLD_RELEASE);
#endif
		}
		else if((key_release_hdlr==BT_VOL_UP_HOLD)||(key_release_hdlr==BT_VOL_DOWN_HOLD)){
	     	 	blue_tooth_key_hdlr(BT_VOL_HOLD_RELEASE);

		}
	    }
		
#ifdef USE_BT_ACTIVATED_PIN
	   if(ACTIVATED_PIN_cnt--==0){
			BT_RST_OFF();
	   }
#endif
		
#ifdef BT_DISP_CONNECT_TIME
		bt_disp_time_hdlr();
#endif


#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_BLUE_TOOTH);
			}
			else{
		                   Disp_Con(DISP_PWR_OFF);
					break;
			}
#endif
		}
#endif

			
#if defined(TIME_FORCE_SHOW_ON_SCREEN)

	if(DISP_BLUE_TOOTH == 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_BLUE_TOOTH);
#else			 	
	                if(DISP_RTC != curr_menu){
				time_show_return_cnt++;
	                }
#endif				
		     }
	     }
#endif
            if (return_cnt < RETURN_TIME)
            {
                return_cnt++;
            }
            else if (RETURN_TIME == return_cnt)
            {
                if (DISP_BLUE_TOOTH != curr_menu)
                    Disp_Con(DISP_BLUE_TOOTH);
				
#if defined(CUSTOM_MAIN_DISP_VOL)
	         if (DISP_BLUE_TOOTH== curr_menu){
                    Disp_Con(DISP_VOL);
	         }
#endif
            }

            if (DISP_BLUE_TOOTH == curr_menu)
	 	     Disp_Con(DISP_BLUE_TOOTH);

	     Disp_Update();			
            break;
			
#ifdef BLUE_TOOTH_BYPASS
    case INFO_VOL_PLUS:
    case INFO_VOL_PLUS | KEY_HOLD :
    case INFO_NEXT_FIL:
    case INFO_NEXT_FIL| KEY_HOLD :
		
    case INFO_VOL_MINUS:
    case INFO_VOL_MINUS | KEY_HOLD :
    case INFO_PREV_FIL:
    case INFO_PREV_FIL| KEY_HOLD :		
		break;
#else
#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:
	break;
    case INFO_VOL_PLUS| KEY_SHORT_UP:
#ifdef BLUE_TOOTH_INDEPENDENT_VOLUME_KEY
      	blue_tooth_key_hdlr(BT_VOL_UP);
	break;
#endif	
    case INFO_VOL_PLUS | KEY_HOLD :
#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
#ifndef BLUE_TOOTH_INDEPENDENT_VOLUME
        my_music_vol += 2;
#endif
      	blue_tooth_key_hdlr(BT_VOL_UP_HOLD);
	goto __VOL_HDLR;
	
#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:
		break;
    case INFO_VOL_MINUS| KEY_SHORT_UP:
#ifdef BLUE_TOOTH_INDEPENDENT_VOLUME_KEY
      	blue_tooth_key_hdlr(BT_VOL_DOWN);
	break;
#endif
    case INFO_VOL_MINUS | KEY_HOLD :
#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
      	blue_tooth_key_hdlr(BT_VOL_DOWN_HOLD);

__VOL_HDLR:

#ifndef BLUE_TOOTH_INDEPENDENT_VOLUME
        if(my_music_vol)
            my_music_vol--;

        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;
	 }
#endif		
	 clear_super_mute_lock();

        write_info(MEM_VOL,my_music_vol);
	 my_main_vol(my_music_vol);	
	 Disp_Con(DISP_VOL);
#endif	 
        break;
#endif		
#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 :							    
            if (!ap_handle_hotkey(key))
                return;
        }
    }
}
/*----------------------------------------------------------------------------*/
/**@brief  AUX功能入口
   @param  无
   @return 无
   @note   void aux_function(void)
*/
/*----------------------------------------------------------------------------*/
void blue_tooth_hdlr(void)
{
#if 1//defined(LINE_IN_PLAY_KEY_PAUSE)
         play_status =MUSIC_PLAY;
#endif

#ifdef BLUE_TOOTH_MUTE_DETECT_FUNC
	bluetooth_mute_detect=0;
#endif

#ifdef BT_DISP_CONNECT_TIME
    link_sec =0;
    link_min =0; 
    link_hour =0;		
#endif

    set_play_flash(LED_FLASH_ON);
    Disp_Con(DISP_BLUE_TOOTH);

    PT1 = 1;										//timer1 interrupt 低优先级
    flush_low_msg();
#if SDMMC_CMD_MODE
   sd_chk_ctl(SET_SD_L_CHK);
#endif
    main_vol(0);

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

#ifdef SUPPORT_PT2313

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

    PT2313_Config(MP3_CHAN,CHAN_ADJ);

    my_main_vol(my_music_vol);	
	
#elif defined(BLUE_TOOTH_BYPASS)||defined(BLUE_TOOTH_PATH_DIRECT_IN_PA)

    dac_out_select(DAC_DECODE);
    my_main_vol(0);	

#else

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

    my_main_vol(my_music_vol);	
	
#endif

#ifdef FIX_VOL_TO_MAX
    my_main_vol(30);	
#endif
    sysclock_div2(1);

    Mute_Ext_PA(UNMUTE);	

    blue_tooth_main();
	
    main_vol_set(0, CHANGE_VOL_NO_MEM);

    sys_clock_pll();
    Mute_Ext_PA(MUTE);		

#ifdef BLUETOOTH_GPIO_CTRL
    BT_PWR_OFF();
#endif 

#if SDMMC_CMD_MODE
	sd_chk_ctl(SET_SD_H_CHK);
#endif

}