/*----------------------------------------------------------------------------*/ 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(); }
/*----------------------------------------------------------------------------*/ 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 rtc_function(void) { #if !defined(MINI_DIGIT_BOX) rtc_mode = RTC_PLAY_MODE; rtc_set = 0; alm_set = 0; #endif flush_low_msg(); PT1 = 1; Mute_Ext_PA(MUTE); if (alm_flag) //闹钟响时默认进入闹钟模式 { rtc_mode = ALM_UP_MODE; #ifdef ALM_UP_DISP_TIME Disp_Con(DISP_RTC); #else Disp_Con(DISP_ALM_UP); #endif goto _deal_rtc0; } else { get_curr_date(); Disp_Con(DISP_RTC); } set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL); //设置RTC模式的音量上限 dac_out_select(DAC_DECODE); sysclock_div2(1); #ifdef UART_ENABLE_RTC //printf(" -----> RTC MODE %x rtc_set %x\r\n",(u16)rtc_mode,(u16)rtc_set); //printf(" --0000-->RTC MODE ==%d \r\n",(u16)curr_date.year); //printf(" --1111--->RTC MODE ==%d \r\n",(u16)curr_date.month); //printf(" --3333--->RTC MODE ==%d \r\n",(u16)curr_date.day); printf(" --HOUR--->RTC MODE ==%d \r\n",(u16)curr_date.hour); printf(" --MIN --->RTC MODE ==%d \r\n",(u16)curr_date.minutes); //printf(" --date--->RTC MODE ==%d \r\n",(u16)curr_date.date); #endif _deal_rtc0: deal_rtc(); #if defined(NEW_RTC_SETTING_CTRL) new_rtc_setting=0; #endif main_vol_set(0, CHANGE_VOL_NO_MEM); sys_clock_pll(); }
/*----------------------------------------------------------------------------*/ 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); }
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 }
/*----------------------------------------------------------------------------*/ void music_decode(void) { sys_printf(" ------------------------------------>music_decode "); #ifdef AC_SLAVE_ENABLE DSA_init(); #endif dev_remov_timer=0; play_mode = REPEAT_OFF; disk_toc_ok=0; dev_invalid=0; input_number_en = 1; //允许数字输入功能 vol_change_en=1; key_voice_en=1; main_menu = MENU_MUSIC_MAIN; dec_msg = get_dec_msg_ptr(); fat_ptr1.buf = win_buffer; SYSTEM_CLK_DIV1(); //sd_speed_init(0, 100); key_table_sel(0); flush_all_msg(); music_info_init(); set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量 if(DSA_SEL_DEV==DEVICE_SDMMC0){ given_device = DEVICE_SDMMC0; } else if(DSA_SEL_DEV==DEVICE_UDISK){ given_device = DEVICE_UDISK; } //put_msg_lifo(MSG_MUSIC_SELECT_NEW_DEVICE); music_play(); //delay_10ms(3); stop_decode(); usb_suspend(); //Entered Suspend Mode key_voice_en=0; main_vol_set(0, CHANGE_VOL_NO_MEM); given_device = NO_DEVICE; }
/*----------------------------------------------------------------------------*/ 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); }
/*----------------------------------------------------------------------------*/ void aux_fun(void) { flashled(3); // amp_abd(1); //work_mode++; //return ; input_number_en = 0; vol_change_en=1; main_menu = MENU_AUX; disp_port(MENU_AUX); amux_dsp_eq(); SYSTEM_CLK_DIV4(); encode_channel = REC_LINEIN; encode_vol = 3; key_table_sel(0); flush_all_msg(); set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量 aux_main(); main_vol_set(0, CHANGE_VOL_NO_MEM); break_encode(); }
/*----------------------------------------------------------------------------*/ 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 aux_main(void) { #ifdef AUX_DETECT_FUNC if(!aux_online){ work_mode = MUSIC_MODE; return ; } #endif #ifdef UART_ENABLE deg_str("aux \n"); #endif aux_detect_protect(FALSE); set_delay_mute(DELAY_MUTE_1000MS); key_table_sel(SYS_DEFUALT_KEY_TABLE); sys_mute_flag=0; input_number_en = 0; vol_change_en=1; main_menu = MENU_AUX_MAIN; disp_port(MENU_AUX_MAIN); amux_dsp_eq(); SYSTEM_CLK_DIV2(); encode_channel = REC_LINEIN; encode_vol = 3; key_table_sel(0); flush_all_msg(); set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量 aux_main_handlr(); ext_amp_mute(MUTE); main_vol_set(0, CHANGE_VOL_NO_MEM); sys_mute_flag=0; break_encode(); }
/*----------------------------------------------------------------------------*/ void fm_radio(void) { // printf("enter fm\n"); //P05_source_select(P05_SEL_OSC1); amux_dsp_eq(); sys_clk_div(2);//SYSTEM_CLK_DIV2(); init_fm_rev(); PT2313_Config(RADIO_CHAN,CHAN_ADJ); input_number_en = 1; vol_change_en=1; main_menu = MENU_FM_MAIN; key_table_sel(1); flush_all_msg(); enter_fm_rev(); disp_port(MENU_FM_MAIN); sys_clk_div(4);//SYSTEM_CLK_DIV4(); set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量 dac_out_select(DAC_AMUX1, 0); encode_channel = REC_FM; #if ECHO_ENABLE encode_channel = REC_MIC ; #endif encode_vol = REC_AMUX_GAIN; fm_rev(); main_vol_set(0, CHANGE_VOL_NO_MEM); amp_mute(1); alm_on_flag =0; fm_rev_powerdown(); //P05_source_select(P05_SEL_IO); break_encode(); }
/*----------------------------------------------------------------------------*/ void sys_info_init(void) { delay_10ms(80); //保证U盘/SD卡能有足够时间通过在线检测,稳定接入 dac_init(); #if DEVICE_ENCRYPTION device_password_init(0x12345678); //输入加密设备的密码 #endif #if ((USE_DEVICE == MEMORY_STYLE)&&(FAT_MEMORY)) get_info_memory(); get_info(); #endif #if ((USE_RTC_EEPROM == MEMORY_STYLE)) check_eeprom_status(); #endif #if 1 my_music_vol = read_info(MEM_VOL); if ((my_music_vol > MAX_MAIN_VOL) || (my_music_vol == 0)) //每次开机时,不要超过最大音量的一半,以免开机音量过大 { my_music_vol = 16; } #endif #if VOLUME_DEFAULT my_music_vol = VOLUME_DEFAULT; #endif music_vol = my_music_vol; set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL); main_vol_set(my_music_vol, CHANGE_VOL_MEM); main_fade_en = 1; #if 0 #if OTP_MUSIC_ENABLE decode_opt_music_file(); #endif #if RTC_ENABLE if (work_mode != SYS_RTC) #endif { usb_audio_massstorage(); //每次上电判断是否连接电脑 } #endif #if 0 #ifdef USE_SYS_MODE_RECOVER work_mode = read_info(MEM_SYSMODE); #ifdef UART_ENABLE printf("------->- MEM_SYSMODE restored work_mode:%d \r\n",(u16)work_mode); #endif if (work_mode > SYS_IDLE){ #ifdef USE_USB_SD_DECODE_FUNC work_mode = SYS_MP3DECODE_USB; #else work_mode = SYS_FMREV; #endif } #else work_mode = SYS_MCU_CD; #endif #endif }
/*----------------------------------------------------------------------------*/ 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 }
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; } } }
/*----------------------------------------------------------------------------*/ 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 }
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; } } } }
u8 decode_voicetime_file() { u8 key; u8 cnt =0; u8 flag; get_time_tobuf(); //获取需要报时的文件 _play_voicetime: voicetime_on = 1; dsp_hi_pro(); decodeint_hi_pro(); f_init(win_buffer, (u16)code_otp_read, 1); f_open((u8 *)&fat_file, 0); f_open_dummy_file(0x200); mad_control(0,(u16)buffer); set_eq(0); //必须在每首歌曲播放前初始化EQ music_type = musice_format_check(buffer); set_max_vol(MAX_ANALOG_VOL, MAX_DIGITAL_VOL); my_memset(win_buffer, 0, 512); //解码前,必须清除buffer main_vol_set(0, SET_USE_CURRENT_VOL); flush_low_msg(); play_status = MUSIC_PLAY; decode_cmd = 0; decode_user_exit(0); enable_softint(); enable_decode_isr(); set_device(0); while(1) { key = get_msg(); switch (key) { case DECODE_MSG_DISK_ERR: case DECODE_MSG_FILE_END: otp_music_addr = play_buf[cnt]; cnt++; delay_10ms(20); if(cnt > play_len) { cnt= 0; otp_music_addr =0; stop_decode(); return 0; } else { goto _play_voicetime; } default : #if 0 flag = alm_bell_key(key); if(flag) { otp_music_addr =0; stop_decode(); close_alm_bell(); return flag; } #endif break; } } }
/*----------------------------------------------------------------------------*/ 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 } }
/*----------------------------------------------------------------------------*/ 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); } }
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 }
/*----------------------------------------------------------------------------*/ void rec_mic_fun(void) { REC_CHAN_PORT_INIT(); REC_CHAN_PORT_ENABLE(); set_max_vol(MAX_ANOLOG_VOL,MAX_DIGITAL_VOL);///设置最大音量 #if KALAOK_FUNCTION if(RECODE_STOP == encode_status) { 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 #endif { #if !ECHO_ENABLE ///<由于可能需要混响输出声音,此处不能静音 //if((BUSY != echo_ptr->status) ) dac_mute_control(1,1); #endif vol_change_en = 0; } input_number_en = 0; main_menu = MENU_REC; disp_port(MENU_REC); //while(1); sys_clk_div(2);//SYSTEM_CLK_DIV2(); //SYSTEM_CLK_DIV1(); #if 1 encode_channel = REC_LINEIN; encode_vol = REC_AMUX_GAIN; #else encode_channel = REC_MIC; encode_vol = REC_MIC_GAIN; #endif key_table_sel(0); flush_all_msg(); //deg_str("Rec Mode\n"); if(RECODE_INIT == encode_status) { put_msg_lifo(MSG_REC_FIND); //put_msg_lifo(MSG_REC_START); } //put_msg_lifo(MSG_REC_START); rec_mic_main(); #if KALAOK_FUNCTION if(RECODE_STOP == encode_status) { kala_dac_off(); P3HD &=~(1<<6); dsp_set_adc_con(0); } #endif dac_mute_control(0,0); REC_CHAN_PORT_DISABLE(); break_encode(); }