?? ide_base.c
字號(hào):
/***********************************************************************************
* 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;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -