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

📄 ide.c

📁 ATMEL 89c51sndc mp3外接硬盘源码
💻 C
字号:
/*C**************************************************************************
* NAME:         ide.c
*----------------------------------------------------------------------------
* Copyright (c) 2002 Atmel.
*----------------------------------------------------------------------------
* RELEASE:      snd1c-demo-hdd-0_2_0      
* REVISION:     1.1     
*----------------------------------------------------------------------------
* PURPOSE:
* This file contains the low level HDD/CDR routines
*****************************************************************************/

/*_____ I N C L U D E S ____________________________________________________*/

#include "config.h"                         /* system configuration */
#include "lib_demob\board.h"                /* board definition */
#include "ide.h"                            /* IDE interface definition */


/*_____ M A C R O S ________________________________________________________*/


/*_____ D E F I N I T I O N ________________________________________________*/

xdata Byte volatile ide_data           At(IDE_DATA_ADDRESS);
xdata Byte volatile ide_error          At(IDE_ERROR_ADDRESS);
xdata Byte ide_sector_count            At(IDE_SECTOR_COUNT_ADDRESS);
xdata Byte ide_sector_number           At(IDE_SECTOR_NUMBER_ADDRESS);
xdata Byte ide_cylinder_low            At(IDE_CYLINDER_LOW_ADDRESS);
xdata Byte ide_cylinder_high           At(IDE_CYLINDER_HIGH_ADDRESS);
xdata Byte ide_drive_head              At(IDE_DRIVE_HEAD_ADDRESS);
xdata Byte volatile ide_status         At(IDE_STATUS_ADDRESS);
xdata Byte volatile ide_alt_status     At(IDE_ALT_STATUS_ADDRESS);

xdata Byte volatile ide_reset_on       At(IDE_RESET_ON_ADDRESS);
xdata Byte volatile ide_reset_off      At(IDE_RESET_OFF_ADDRESS);

bdata bit ide_parity;

/*_____ D E C L A R A T I O N ______________________________________________*/


/*F*************************************************************************
* NAME: ide_read_dataword
*---------------------------------------------------------------------------
* PARAMS:
*
* return:
*   Word Data read from media
*----------------------------------------------------------------------------
* PURPOSE: 
*   Word read function
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
****************************************************************************/
Uint16 ide_read_dataword (void)
{
Uint16 tmp;

  ((Byte*)&tmp)[1] = ide_data;
  ((Byte*)&tmp)[0] = DAT16H;
  return tmp;
}

/*F*************************************************************************
* NAME: ide_read_databyte
*---------------------------------------------------------------------------
* PARAMS:
*
* return:
*   Byte Data read from media
*----------------------------------------------------------------------------
* PURPOSE: 
*   Byte read function
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
****************************************************************************/
Byte ide_read_databyte (void)
{
  if (ide_parity == 0)
  {
    ide_parity = 1;
    return ide_data;
  }
  else
  {
    ide_parity = 0;
    return DAT16H;
  }
}


/*F*************************************************************************
* NAME: ide_write_databyte
*---------------------------------------------------------------------------
* PARAMS:
*
* return:
*   Byte Data write to media
*----------------------------------------------------------------------------
* PURPOSE: 
*   Byte write function
*----------------------------------------------------------------------------
* EXAMPLE:
*----------------------------------------------------------------------------
* NOTE:
*----------------------------------------------------------------------------
* REQUIREMENTS:
****************************************************************************/
void ide_write_databyte (Byte d)
{
static Byte temp;

  if (ide_parity == 0)
  {
    ide_parity = 1;
    temp = d;             /* High order byte -> next time, will be stored in ACC */
  }
  else
  {
    ide_parity = 0;
    DAT16H = d;
    ide_data = temp;      /* Low order byte */
  }
}

⌨️ 快捷键说明

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