⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mconfig.c

📁 本程序为ST公司开发的源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
		{			Error=i;			break;		}				*pSDRAM=RAMBackup;		pSDRAM++;  	}  	//return(100);  	return(Error);}/******************************************************************************//* Function:  CheckFLASHData                                                  *//*                                                                            *//*! \brief     *  \param    void *  \return   uint32 *  \remark *//******************************************************************************/uint32 CheckFLASHData(void){	uint32 FLASHCheckSum=0;	uint32 FLASHCheckSumRead;	uint8 TempData[260];  	uint32 i,j;  	uint32 sf_patch_size;  	//uint32 Error=0; // [RB] unused	DISABLE_INTERRUPTS();	SelectSdram(SELECT_BSPI);	bspi_init();	bspi_rdid();		if(sf_type == BL_MP25P40)	{	 sf_read(BL_SF_DWN_INFO_4M, TempData,256);	 sf_patch_size = BL_PATCH_AREA_SIZE_4M;	}	else	{	 sf_read(BL_SF_DWN_INFO_1M, TempData,256);	 sf_patch_size = BL_PATCH_AREA_SIZE_1M;	} 	FLASHCheckSumRead=TempData[240]+(uint32)(TempData[241]<<8)+(uint32)(TempData[242]<<16)+(uint32)(TempData[243]<<24);		for(i = 0;i<sf_patch_size;i+=256)	{		sf_read(i, TempData,256);		for(j=0;j<64;j++)		{			FLASHCheckSum+=TempData[j*4]+(uint32)(TempData[j*4+1]<<8)+(uint32)(TempData[j*4+2]<<16)+(uint32)(TempData[j*4+3]<<24);		}	}	SelectSdram(SELECT_SDRAM);	ENABLE_INTERRUPTS();		if(FLASHCheckSum==FLASHCheckSumRead)	{		return(0);	}	else	{		return(1);	}	}/******************************************************************************//* Function:  verify_loader_configuration                                     *//*                                                                            *//*! \brief    Force loader configurations whisc are not compatible *            with the selected mechanism *  \param    void *  \return   void *  \see *  \remark *//******************************************************************************/void verify_loader_configuration(){  if (mechanism_model != M0_SHINWA_CDC02)  {    module_config.data.loader_cfg_1.field.conservative_behavior_Shinwa_CDC02 = 0;  }  if (IS_TANASHIN_MECHANISM(mechanism_model))  {    module_config.data.loader_cfg_2.field.eject_without_disc = 1;    if (IS_TANASHIN_MECHANISM_8CM(mechanism_model))    {      module_config.data.loader_cfg_2.field.insert_without_disc = 1;    }    else    {      module_config.data.loader_cfg_2.field.insert_without_disc = 0;    }  }}/******************************************************************************//* Function:  mconfig_update_params                                            *//*                                                                            *//*! \brief    Update all changed module configuration parameters *  \param    uint8 addr, uint8 len *  \return   void *  \see      uint8 *  \remark *//******************************************************************************/void mconfig_update_params(uint8 addr, uint8 len){  char response_msg[8];  volatile uint16 reg;    while ((0 != len) && (addr < MODULE_CONFIG_SIZE))   {    switch (addr)    {    case CADDR_AUDIO_OUTPUT_CFG:       if(audio_output_cfg_update())       {             CNF_AUDIO_OUTPUT_PREV = CNF_AUDIO_OUTPUT;   	    CNF_I2S_OUTPUT_FORMAT_PREV = CNF_I2S_OUTPUT_FORMAT;   	    CNF_I2S_FS_PREV = CNF_I2S_FS; 		   	    CNF_I2S_SCLK_LEVEL_PREV = CNF_I2S_SCLK_LEVEL; 		   	    CNF_I2S_WCLK_LEVEL_PREV = CNF_I2S_WCLK_LEVEL; 		   	    CNF_I2S_FORMAT_PREV = CNF_I2S_FORMAT;    	           }       else       {        CNF_AUDIO_OUTPUT = CNF_AUDIO_OUTPUT_PREV;   	    CNF_I2S_OUTPUT_FORMAT = CNF_I2S_OUTPUT_FORMAT_PREV;   	    CNF_I2S_FS = CNF_I2S_FS_PREV;   	    CNF_I2S_SCLK_LEVEL = CNF_I2S_SCLK_LEVEL_PREV; 		   	    CNF_I2S_WCLK_LEVEL = CNF_I2S_WCLK_LEVEL_PREV; 		   	    CNF_I2S_FORMAT = CNF_I2S_FORMAT_PREV; 		   	           }    	              break;    case CADDR_LOAD_ACTION:      if ((0 != module_config.data.load_action) && (module_config.data.load_action < MIN_LOAD_ACTION))      {        module_config.data.load_action = MIN_LOAD_ACTION;      }      break;    case CADDR_TEXT_INFO_SETTING_LENGTH:      if (module_config.data.text_info_setting_length > MAX_TEXT_LENGTH)      {        module_config.data.text_info_setting_length = MAX_TEXT_LENGTH;      }      else if (module_config.data.text_info_setting_length < MIN_TEXT_LENGTH)      {        module_config.data.text_info_setting_length = MIN_TEXT_LENGTH;      }      break;    case CADDR_AUDIO_FORMAT:#if (LAYER3 == 0)      module_config.data.audio_format.field.mp3_enable = 0;#endif#if (LAYER2 == 0)          module_config.data.audio_format.field.mp2_enable = 0;      #endif#if (LAYER1 == 0)       module_config.data.audio_format.field.mp1_enable = 0;      #endif#if (HAVE_AAC == 0)      module_config.data.audio_format.field.aac_mpeg4_enable = 0;      #endif#if (HAVE_WMA == 0)      module_config.data.audio_format.field.wma_enable = 0;      #endif      // currently no ogg decoder implemented      module_config.data.audio_format.field.ogg_vorbis_enable = 0;          break;    case CADDR_FUNCTION_CFG:      if (ESP_ON == module_config.data.function_cfg.field.esp_enable)      {        if (ADPCM_OFF != module_config.data.function_cfg.field.esp_compress_ratio)        {          module_config.data.function_cfg.field.esp_compress_ratio = ADPCM_ON;        }#if 0        new_cap_config = 1; // [RB] Necessary to communicate the config change to Cap,        				// but commented out because ADPCM does not work#endif      }      else      {        module_config.data.function_cfg.field.esp_compress_ratio = ADPCM_OFF;        // remap usage of SDRAM and reinitialize buffers allocated there        sdram_layout(0);        cap_config.esp = ESP_OFF;        cap_config.new_config = 1;        AudioBufferInit();        Init_X_array();      }      break;        case CADDR_LOADER_CFG_1:    case CADDR_LOADER_CFG_2:      verify_loader_configuration();      break;	case CADDR_MEM_CHECK_CFG:		module_config.data.MemCheck&=0x17;				// check SDRAM		if(module_config.data.MemCheck&0x01)		{			response_msg[0] = 0x01;			response_msg[1] = 0x07;			// SDRAM			response_msg[2] = 0x03;						if(CheckSDRAM())				response_msg[3] = 0x01;			else				response_msg[3] = 0x02;			hostifAppSendMsg(&response_msg[0], 4);		}		// check FLASH data		if(module_config.data.MemCheck&0x10)		{			response_msg[0] = 0x01;			response_msg[1] = 0x07;			// FLASH			response_msg[2] = 0x01;						if(CheckFLASHData())				response_msg[3] = 0x01;			else				response_msg[3] = 0x04;			hostifAppSendMsg(&response_msg[0], 4);		}				break;   	case CADDR_AUTO_MODE:   	  if (module_config.data.auto_mode.field.shuffle_mode)   	  {        //devide not ready or no playable files        if (!  ((player_params.DevicesReady & player_params.device)              && (CountFilesForDevice(player_params.device, b_TRUE, SEARCH_PLAYABLE))))                     {                  module_config.data.auto_mode.field.shuffle_mode = 0;        }   	       	  }   	  break;   	case CADDR_SEARCH_SPEED:   	  if (module_config.data.search_speed > SEEK_MAX_SPEED)   	    module_config.data.search_speed = SEEK_MAX_SPEED;   	  if (module_config.data.search_speed < SEEK_MIN_SPEED)   	    module_config.data.search_speed = SEEK_MIN_SPEED;      break;          case CADDR_PLAYLIST_CFG:      if (module_config.data.playlist_cfg.field.playlist_enabled)      {         //devide not ready or no playlist files        if (!  ((player_params.DevicesReady & player_params.device)              && (CountFilesForDevice(player_params.device, b_FALSE, SEARCH_PLAYLISTS))))                     {                  module_config.data.playlist_cfg.field.playlist_enabled = 0;        }      }      break;          case CADDR_SEARCH_PLAY_TIME:   	  if (module_config.data.search_play_time > SEEK_PLAY_TIME_MAX)   	    module_config.data.search_play_time = SEEK_PLAY_TIME_MAX;   	  if (module_config.data.search_play_time < SEEK_PLAY_TIME_MIN)   	    module_config.data.search_play_time = SEEK_PLAY_TIME_MIN;      break;          case CADDR_USB_OPTIONS_CFG:    {        extern uint8 APP_HUB_ON;            	if (module_config.data.usb_options.field.enable_hub_support != 0x00)    	{           APP_HUB_ON = (uint8) 1;    	}    	else    	{           APP_HUB_ON = (uint8) 0;    	}    	if (module_config.data.usb_options.field.enable_vbus_control != 0x00)    	{    	   /* A+ controls the VBUS */           configure_gpio(PORT_B, GPIO_4, GPIO_OUT_PP);    	}    	else    	{    	   /* A+ does not control the VBUS, put in HIGH-Z */           configure_gpio(PORT_B, GPIO_4, GPIO_IN);    	}    }    break;   	case CADDR_ESP_SIZE:    if ((ESP_OFF == module_config.data.function_cfg.field.esp_enable) ||        (module_config.data.shockproof_size == 0) ||        (module_config.data.shockproof_size > DFLT_ESP_SIZE) ||        (module_config.data.shockproof_size < 3)) /* ESP tested with minimum 220 sectors, approx. 3s */    {        module_config.data.shockproof_size = DFLT_ESP_SIZE;    }    else    {        sdram_layout(module_config.data.shockproof_size);        cap_config.esp_params.input_buffer_size = 0;        cap_config.new_config = 1;        AudioBufferInit();        Init_X_array();    }    break;          default:      break;    }  ++addr;  --len;  }}/******************************************************************************//* Function:  audio_output_cfg_update                                            *//*                                                                            *//*! \brief     *  \param    void *  \return   uint8 *  \remark *//******************************************************************************/uint8 audio_output_cfg_update(void){   uint32 dma1;   uint8 update = 0;         switch(CNF_AUDIO_OUTPUT)   {   	case CNF_AUDIO_I2S:   	 // I2S on   	 // Analog On   	 // SPDIF  Off    	 if((player_mode == PLM_STOP || player_mode == PLM_PAUSE))   	 {   	  if(!dma_ch0_fiq)   	  {   	   DISABLE_INTERRUPTS();   	   GCR1.field.spdif_sel = 0; // 0->I2S is  Selected     	   dma1 = DMA_CTRL1.field.enable;   	   DMA_CTRL1.field.enable = 0;   	      	   oif_init();   	  	   	      	   DMA_CTRL1.field.enable = dma1;   	      	   update = 1;   	   ENABLE_INTERRUPTS();   	  }   	     	 }   	    	break;   	   	case CNF_AUDIO_SPDIF:   	 // I2S off   	 // Analog On   	 // SPDIF On   	 // Mute I2S   	 OIF_AP_MUTE_CTRL.all |= MUTE_I2S_OFF | MUTE_I2S_FORCE;    	 GCR1.field.spdif_sel = 1; // 1->SPDIF is Selected     oif_mute_control.audio_on = 0;	      update = 1;  	   	break;   	   	   	case CNF_AUDIO_ANALOG:   	// Only Analog.   	// I2S and SPDIF Muted   	OIF_AP_MUTE_CTRL.all |= MUTE_I2S_OFF | MUTE_I2S_FORCE | MUTE_SPDIF_OFF | MUTE_SPDIF_FORCE;    oif_mute_control.audio_on = 0;	    update = 1;   	   	default:   	break;   }     return update;     }   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -