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

📄 media.c

📁 atmel at89c51snd1c mp3芯片方案源码
💻 C
字号:

#include "config.h"                         /* system configuration */
#include "media.h"
#include "lib_mcu\mmc\mmc_drv.h"                        /* mmc driver definition */
#include "lib_mcu\ide\ide_drv.h"              /* hard disk definition */
#include "lib_mcu\cdrom\cdrom_drv.h"

extern   Byte    gl_media_select;
bit      bMediaReadOpenFlag;
bit      bMediaWriteOpenFlag;
INT16U   u16MediaBytePointer;
INT32U   u32MediaSector;


//////////////////////////////////////////////////////////////////////////////////
INT8U u8MediaSelect(INT8U u8MediaType)
{
    gl_media_select = 0;   //select none

    if(u8MediaType == MEDIA_HDD)
    {
       gl_media_select = MEDIA_HDD;
    }
    else if(u8MediaType == MEDIA_MMC)
    {
       gl_media_select = MEDIA_MMC;
    } 
    else if(u8MediaType == MEDIA_CDROM)
	{
	   gl_media_select = MEDIA_CDROM;
	}
    return (gl_media_select);
}


//////////////////////////////////////////////////////////////////////////////////
bit  Hard_read_one_sector(INT32U u32Sector)
{
   if(gl_media_select == MEDIA_HDD)
   {
      if( hdd_read_one_sector(u32Sector) ) 
	    return TRUE;
	  else
	    return FALSE;
   }
   else if(gl_media_select == MEDIA_MMC)
   {
      if( mmc_read_one_sector(u32Sector) )
	     return TRUE;
	  else 
	     return FALSE;
   }
}


//////////////////////////////////////////////////////////////////////////////////
bit  Hard_write_one_sector(INT32U u32Sector)
{
   if(gl_media_select == MEDIA_HDD)
   {
      if( hdd_write_one_sector(u32Sector) ) 
	    return TRUE;
	  else
	    return FALSE;
   }
   else if(gl_media_select == MEDIA_MMC)
   {
      if( mmc_write_one_sector(u32Sector) )
	     return TRUE;
	  else 
	     return FALSE;
   }  
}



//////////////////////////////////////////////////////////////////////////////////
bit  Hard_read_open(INT32U u32Sector)
{
   if(gl_media_select == MEDIA_HDD)
   {
      if( hdd_read_open(u32Sector) ) 
	    return TRUE;
	  else
	    return FALSE;
   }
   else if(gl_media_select == MEDIA_MMC)
   {
      if( mmc_read_open(u32Sector) )
	     return TRUE;
	  else 
	     return FALSE;
   }  
}



//////////////////////////////////////////////////////////////////////////////////
INT8U  Hard_read_byte(void)
{
   if(gl_media_select == MEDIA_HDD)
   {
      return(hdd_read_byte());
   }
   else if(gl_media_select == MEDIA_MMC)
   {
      return(mmc_read_byte());
   }  
}


//////////////////////////////////////////////////////////////////////////////////
bit  Hard_read_close(void)
{
   if(gl_media_select == MEDIA_HDD)
   {
      if( hdd_read_close() ) 
	    return TRUE;
	  else
	    return FALSE;
   }
   else if(gl_media_select == MEDIA_MMC)
   {
      if( mmc_read_close() )
	     return TRUE;
	  else 
	     return FALSE;
   }  
}

//////////////////////////////////////////////////////////////////////////////////
bit Hard_install(void)
{
   if(gl_media_select == MEDIA_HDD)
   {
      if(hdd_install())
	     return OK;
	  else
	     return KO;
   }
   else if(gl_media_select == MEDIA_MMC)
   {
      if(Mmc_init())
	     return OK;
	  else
	     return KO;
   }   
   else if(gl_media_select == MEDIA_CDROM)
   {
       cdrom_init();
	   return OK;
   }
}








⌨️ 快捷键说明

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