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

📄 ide_base.c

📁 在BF533上实现FAT32文件系统文件系统的源码,有兴趣的可以看看.
💻 C
字号:
/***********************************************************************************
* File              : ide_base.C
* Processor    : ADSP-BF533  
* IDDE          : VisualDSP++3.5
* Description  : define bunch of IDE driver functions including:
*                  
*                    Wait_Ready();
*                    Wait_ReadyBusy();
*                    Wait_DRQ();
*                    CheckforError();
*                    IdeStandby();
*                    IdeIdle();
*                    
***********************************************************************************/
#include "IDE/ide_base.h"
#include "type.h"


extern void Delay(unsigned int Value);

extern void IdeStandby(void);
extern void IdeIdle(void);
extern unsigned char IdeReadSector(unsigned char SectorNum,unsigned short CylinderNum,unsigned char DriverHead);
extern unsigned char IdeWriteSector(unsigned char SectorNum,unsigned short CylinderNum,unsigned char DriverHead);

/**********************************************************************************
* Function     : Wait_Ready 
* Description : Wait HD getting ready
* Input         : None
* Return       : 0-ready /error ID-HD error
***********************************************************************************/
BYTE  Wait_Ready(void)
{
   BYTE statbyte;
   BYTE flag = 0;
   
   while (!flag)
   {
 	  statbyte = *pStatus; 	     					// Read Status Register
 	  if (statbyte & IDE_ERROR)
 	  {
 	  	statbyte=*pErrorReg;						//Check HD error
 	  	return  statbyte;							//read error register if error and retrun error ID
 	  }
	  if (statbyte & IDE_DRDY) 
	  	flag = 1;     								//check ready or not, set flag
   }
   return 0;										
}
/**********************************************************************************
* Funciton     : Wait_ReadyBusy 
* Description : query HD busy or not.
* Input         : none
* Return       : 0-busy /error ID-HD error
***********************************************************************************/
BYTE Wait_ReadyBusy(void)
{
   BYTE statbyte;
   BYTE flag = 0;
   
   while (!flag)
   {
 	  statbyte = *pStatus; 	     // Read Status Register
 	  if (statbyte & IDE_ERROR)
 	  {
 	  	statbyte=*pErrorReg;
 	  	return  statbyte;
 	  }
	  if (((statbyte & IDE_DRDY)!=0 )&&((statbyte & IDE_BUSY)==0)) 
	  	flag = 1;     // Ready bit is in pos 6
   }
   return 0;
}

/**********************************************************************************
* Funciton     : Wait_DRQ
* Description : query HD data transfer ready or not
* Input         : none
* Return       : 0-ready /error ID-HD error
***********************************************************************************/
BYTE Wait_DRQ(void)
{
   BYTE statbyte;
   BYTE flag = 0;
   
   while (!flag)
   {
 	  statbyte = *pStatus; 	     // Read Status Register
 	  if (statbyte & IDE_ERROR)
 	  {
 	  	statbyte=*pErrorReg;
 	  	return  statbyte;
 	  }
	  if (statbyte & IDE_DRQ) 
	  	flag = 1;     // Ready bit is in pos 6
   }
   return 0x00;
}
/**********************************************************************************
* Funciton     : CheckforError
* Description : check HD error 
* Input         : none
* Return       : 0-no errors /error ID -yes
***********************************************************************************/
BYTE CheckforError(void)
{
 	  BYTE statbyte;
	  statbyte = *pStatus;	// Read Status Register
  	  if (statbyte & 0x01) 
  	  {
  	  	statbyte= *pErrorReg;
  	  	return statbyte; // Is LSB (error bit) is set then return 1
  	  }
	  else 
	  	return 0x00;
}
/**********************************************************************************
* Funciton     : IdeStandby
* Description : Set HD into standby mode
* Input         : none
* Return       : none
***********************************************************************************/
void IdeStandby(void)
{
	*pCommand = 0xe0;
}
/**********************************************************************************
* Funciton     : IdeIdle
* Description : Set HD into idle mode
* Input         : none
* Return       : none
***********************************************************************************/
void IdeIdle(void)
{
	*pCommand = 0x95;
}


⌨️ 快捷键说明

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