网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61IC中国电子在线 >> DSP >> 代码示例 >> ADI DSP代码示例 >> Blackfin >> 文章正文
  ADSP-BF533 IDE_Base(C)源代码         ★★★ 【字体:
ADSP-BF533 IDE_Base(C)源代码
作者:61IC    文章来源:本站原创    点击数:    更新时间:2007-1-22    

/***********************************************************************************
* 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;
}

               欢迎点击进入:TI德州中文网   (国内唯一针对TI应用的中文技术网站)    文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    基于ADSP-BF533的最小系统设…
    基于ADSP-BF533处理器的去方…
    ADSP-BF533 IDE Access(C)源…
    ADSP-BF533 文件系统(C)源代…
    ADSP-BF533 FAT32 Base(C)源…
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号