亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ata.c

?? 嵌入式系統中的fat32和fat16源代碼(完全版)
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// Title		: IDE-ATA interface driver for hard disks
// Authors		: Angelo Bannack, Giordano Bruno Wolaniuk
// File Name	: 'ata.c'
// Date			: April 16, 2004
// Version		: 1.00
// Target MCU	: Atmel AVR Series
// Editor Tabs	: 4
//
// NOTE: This code is based on original library "IDE-ATA interface driver for hard disks"
//       from Pascal Stang.
//
//	     The authors in no way will be responsible for damages that you coul'd be using this code.
//       Use this code at your own risk.
//
//       This code is distributed under the GNU Public License
//       which can be found at http://www.gnu.org/licenses/gpl.txt
//
//*****************************************************************************

#ifndef WIN32
	#include <avr/io.h>
	#include <avr/interrupt.h>
	#include <avr/signal.h>
	#include <avr/pgmspace.h>
#endif
#include "global.h"
#include "ata.h"

// global variables
typeDriveInfo ataDriveInfo;		// drive information


//*****************************************************************************
// Function: ataInit
// Parameters: none
// Returns: none
//
// Description: Gives a software reset into the ata dispositive
//*****************************************************************************
void ataInit(void)
{
	unsigned char i;
	unsigned char* buffer = (unsigned char*) SECTOR_BUFFER_ADDR;


	DDR_DATAL= 0x00;			// Use DATAL as the input from the hardrive
	DDR_DATAH= 0x00;			// Use DATAH as the input from the hardrive
	PORT_DATAL= 0xFF;			// Enable pullup on DATAL
	PORT_DATAH= 0xFF;			// Enable pullup on DATAH

	DDR_ADDR = 0xDF;			// Use ADDR PORT as the output for the hardrive
  								// But use PORT_ADDR.5 as host interrupt (INPUT)
    PORT_ADDR= 0xc0;            // Initialize PORT_ADDR to c0.


    ataWriteByte(ATA_REG_ACTSTATUS, 0x06);  	 	// Assert Software reboot.
    delay(100);
    ataWriteByte(ATA_REG_ACTSTATUS, 0x00);
    delay(100);

    // Wait until drive clear BUSY Bit in Alternate Status Register
    while(IDE_Wait_State(ATA_SR_BSY) == 1);

	// issue identify command
	ataWriteByte(ATA_REG_HDDEVSEL, 0);
	ataWriteByte(ATA_REG_ACTSTATUS, 0x02);

    while(IDE_Wait_State(ATA_SR_DRDY) == 0);

	ataWriteByte(ATA_REG_CMDSTATUS1, 0xEC);
	// wait for drive to request data transfer

	while(IDE_Wait_State(ATA_SR_DRQ) == 0);

	delay(200); // wait 200 us
	// read in the data
	ataReadDataBuffer(buffer, 512);

	// set local drive info parameters
	ataDriveInfo.cylinders =		*( ((unsigned int*) buffer) + ATA_IDENT_CYLINDERS );
	ataDriveInfo.heads =			*( ((unsigned int*) buffer) + ATA_IDENT_HEADS );
	ataDriveInfo.sectors =			*( ((unsigned int*) buffer) + ATA_IDENT_SECTORS );
	ataDriveInfo.LBAsupport =		*( ((unsigned int*) buffer) + ATA_IDENT_FIELDVALID );
	ataDriveInfo.sizeinsectors =	*( (unsigned long*) (buffer + ATA_IDENT_LBASECTORS*2) );
	// copy model string
	for(i=0; i<40; i+=2)
	{
		// correct for byte order
		ataDriveInfo.model[i  ] = buffer[(ATA_IDENT_MODEL*2) + i + 1];
		ataDriveInfo.model[i+1] = buffer[(ATA_IDENT_MODEL*2) + i    ];
	}
	// terminate string
	ataDriveInfo.model[40] = 0;

	// process and print info
	if(!ataDriveInfo.LBAsupport) {
		// CHS, no LBA support
		// calculate drive size
		ataDriveInfo.sizeinsectors = (unsigned long) ataDriveInfo.cylinders*ataDriveInfo.heads*ataDriveInfo.sectors;
	}
}


//*****************************************************************************
// Function: ataSetDrivePowerMode
// Parameters: DriveNo, mode, timeout
// Returns: none
//
// Description: Sets the Power Mode
//	            Possible modes: ATA_DISKMODE_SPINDOWN
//                              ATA_DISKMODE_SPINUP
//                              ATA_DISKMODE_SETTIMEOUT
//                              ATA_DISKMODE_SLEEP
//*****************************************************************************
void ataSetDrivePowerMode(unsigned char DriveNo, unsigned char mode, unsigned char timeout)
{
	// select drive
	ataDriveSelect(DriveNo);
	// Wait for drive to be ready
	ataStatusWait(ATA_SR_BSY, ATA_SR_BSY);

	// set mode
	switch(mode)
	{
	case ATA_DISKMODE_SPINDOWN:		ataWriteByte(ATA_REG_CMDSTATUS1, ATA_CMD_SPINDOWN); break;
	case ATA_DISKMODE_SPINUP:		ataWriteByte(ATA_REG_CMDSTATUS1, ATA_CMD_SPINUP); break;
	case ATA_DISKMODE_SETTIMEOUT:
		ataWriteByte(ATA_REG_SECCOUNT, timeout);
		ataWriteByte(ATA_REG_CMDSTATUS1, ATA_CMD_IDLE_5SU);
		break;
	case ATA_DISKMODE_SLEEP:		ataWriteByte(ATA_REG_CMDSTATUS1, ATA_CMD_SLEEP); break;
	default:
		break;
	}
}



//*****************************************************************************
// Function: ataReadDataBuffer
// Parameters: Buffer, numBytes
// Returns: none
//
// Description: The Buffer will be filled with the readed data
//*****************************************************************************
void ataReadDataBuffer(unsigned char *Buffer, unsigned short numBytes)
{
	register unsigned int i asm ("r16");

	DDR_DATAL = 0x00; 		      	// Use the PORT DATAH as an input
	DDR_DATAH = 0x00; 		      	// Use the PORT DATAL as an input
	PORT_DATAL= 0xFF;				// habilita pull-ups
	PORT_DATAH= 0xFF;				// habilita pull-ups
	PORT_ADDR = PORT_ADDR & 0xe0; 		// Clear the lower 5 bits of the address line
	PORT_ADDR = PORT_ADDR | (ATA_REG_DATA & 0x1f); 	// Assert the address Line

	for (i=0; i< numBytes; i+=2)
	{
		cbi(PORT_IDE_RD, PIN_IDE_RD);
	  	__asm volatile ("NOP");
	  	__asm volatile ("NOP");
	  	*(Buffer++)= PIN_DATAL;
	  	*(Buffer++)= PIN_DATAH;
		sbi(PORT_IDE_RD, PIN_IDE_RD);
	}
}


////////////////////
#ifndef ATA_READ_ONLY
//*****************************************************************************
// Function: ataWriteDataBuffer
// Parameters: Buffer, numBytes
// Returns: none
//
// Description: The entire Buffer will be pulled out to the ata dispositive
//*****************************************************************************
void ataWriteDataBuffer(unsigned char *Buffer, unsigned short numBytes)
{
	register unsigned int i asm ("r16");

	DDR_DATAL = 0xFF; 		      	// Use the PORT DATAH as an output
	DDR_DATAH = 0xFF; 		      	// Use the PORT DATAL as an output
	PORT_ADDR = PORT_ADDR & 0xe0; 		// Clear the lower 5 bits of the address line
	PORT_ADDR = PORT_ADDR | (ATA_REG_DATA & 0x1f); 	// Assert the address Line

	for (i=0; i< numBytes; i+=2)
	{
	  	PORT_DATAL= *(Buffer++);
	  	PORT_DATAH= *(Buffer++);
	  	cbi(PORT_IDE_WR, PIN_IDE_WR);
	  	__asm volatile ("NOP");
	  	__asm volatile ("NOP");
		sbi(PORT_IDE_WR, PIN_IDE_WR);
	}
}
#endif
////////////////////


//*****************************************************************************
// Function: ataStatusWait
// Parameters: mask, waitStatus
// Returns: the wait status
//
// Description: Read the Status form the hard disk until the result be equal waitStatus
//*****************************************************************************
unsigned char ataStatusWait(unsigned char mask, unsigned char waitStatus)
{
	register unsigned char status;

	// wait for desired status
	while( ((status = ataReadByte(ATA_REG_ACTSTATUS)) & mask) == waitStatus );
	return status;
}

//*****************************************************************************
// Function: ataReadSectorCHS
// Parameters: Driver, Head, Track, Sector, Buffer
// Returns: on Suscefull returns 0, the result errors otherwise.
//
// Description: Read one Sector (512 Bytes) from the ata dispositive
//*****************************************************************************
unsigned char ataReadSectorsCHS(	unsigned char Drive,
											unsigned char Head,
											unsigned int Track,
											unsigned char Sector,
											unsigned char *Buffer)
{
  	unsigned char temp;

	// Wait for drive to be ready
	temp = ataStatusWait(ATA_SR_BSY, ATA_SR_BSY);

  	// Prepare parameters...
	ataWriteByte(ATA_REG_HDDEVSEL, 0xA0+(Drive ? 0x10:00)+Head); // CHS mode/Drive/Head
	ataWriteByte(ATA_REG_CYLHI, Track>>8);  		// MSB of track
	ataWriteByte(ATA_REG_CYLLO, Track);     		// LSB of track
  	ataWriteByte(ATA_REG_STARTSEC, Sector);    	// sector
	ataWriteByte(ATA_REG_SECCOUNT, 1);			// # of sectors

	// Issue read sector command...
  	ataWriteByte(ATA_REG_CMDSTATUS1, 0x21);

	// Wait for drive to be ready
	temp = ataStatusWait(ATA_SR_BSY, ATA_SR_BSY);

	if (temp & ATA_SR_ERR)
		return 1;

	// Wait for drive to request data transfer
	ataStatusWait(ATA_SR_DRQ, 0);

	// read data from drive
	ataReadDataBuffer(Buffer, 512);

	// Return the error bit from the status register...
	temp = ataReadByte(ATA_REG_CMDSTATUS1);	// read status register

	return (temp & ATA_SR_ERR) ? 1:0;
}


////////////////////
#ifndef ATA_READ_ONLY
//*****************************************************************************
// Function: ataWriteSectorsCHS
// Parameters: Driver, Head, Track, Sector, Buffer
// Returns: on Suscefull returns 0, the result errors otherwise.
//
// Description: Write one Sector (512 Bytes) to the ata dispositive
//*****************************************************************************
unsigned char ataWriteSectorsCHS(unsigned char Drive,
											unsigned char Head,
											unsigned int Track,
											unsigned char Sector,
											unsigned char *Buffer)
{
  	unsigned char temp;

	// Wait for drive to be ready
	temp = ataStatusWait(ATA_SR_BSY, ATA_SR_BSY);

  	// Prepare parameters...
	ataWriteByte(ATA_REG_HDDEVSEL, 0xA0+(Drive ? 0x10:00)+Head); // CHS mode/Drive/Head
	ataWriteByte(ATA_REG_CYLHI, Track>>8);  		// MSB of track
	ataWriteByte(ATA_REG_CYLLO, Track);     		// LSB of track
  	ataWriteByte(ATA_REG_STARTSEC, Sector);    	// sector
	ataWriteByte(ATA_REG_SECCOUNT, 1);			// # of sectors

	// Issue write sector command
  	ataWriteByte(ATA_REG_CMDSTATUS1, 0x31);

	// Wait for drive to request data transfer
	ataStatusWait(ATA_SR_DRQ, 0);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
2021中文字幕一区亚洲| 欧美一级高清片| 国产成人av一区二区三区在线 | 亚洲国产乱码最新视频| 国产精品美女视频| 国产精品丝袜一区| 国产精品女人毛片| 国产精品乱人伦| 亚洲色图丝袜美腿| 亚洲在线观看免费| 丝袜美腿亚洲色图| 青青草国产精品亚洲专区无| 久久电影网电视剧免费观看| 国产又粗又猛又爽又黄91精品| 美女mm1313爽爽久久久蜜臀| 国产一区二区三区免费看 | 欧美精彩视频一区二区三区| 久久久久99精品国产片| 中文天堂在线一区| 亚洲国产欧美在线人成| 蜜臀久久99精品久久久画质超高清| 久久国产夜色精品鲁鲁99| 国产精品一区二区无线| 99视频精品在线| 欧美挠脚心视频网站| 欧美成人官网二区| 国产精品久久久久一区| 夜夜操天天操亚洲| 激情欧美日韩一区二区| 99在线精品免费| 日韩一级大片在线| 18欧美亚洲精品| 日本亚洲三级在线| 99精品视频在线观看| 欧美日产在线观看| 久久久夜色精品亚洲| 一区二区三区中文在线观看| 麻豆91小视频| 91色视频在线| 精品美女一区二区三区| 中文字幕一区二区三区不卡| 秋霞影院一区二区| av一区二区三区在线| 69av一区二区三区| 国产精品久久久爽爽爽麻豆色哟哟 | 伦理电影国产精品| 色吊一区二区三区| 久久综合狠狠综合久久综合88| 亚洲女厕所小便bbb| 日本91福利区| 欧美在线free| 国产精品久久久久永久免费观看| 日韩成人av影视| 欧美午夜精品久久久久久超碰 | 亚洲激情男女视频| 国产精品911| 日韩一区二区三区四区五区六区| 亚洲视频你懂的| 成人国产精品视频| 久久免费国产精品| 久久精品免费看| 国产亚洲成aⅴ人片在线观看| 亚洲精品日韩综合观看成人91| 国产伦精品一区二区三区视频青涩 | 国产精品天美传媒| 国产美女在线精品| 精品国一区二区三区| 日韩精品91亚洲二区在线观看| 色av成人天堂桃色av| 国产精品毛片无遮挡高清| 久久爱另类一区二区小说| 欧美精品九九99久久| 亚洲午夜一区二区三区| 91麻豆免费观看| 一区二区三区四区中文字幕| 91免费观看视频在线| 中文字幕一区二区在线播放| 成人理论电影网| 国产精品三级久久久久三级| 国产精品综合久久| 亚洲国产精品精华液2区45| 国产黄色91视频| 国产午夜精品理论片a级大结局| 精品一区二区三区香蕉蜜桃| 精品国产91洋老外米糕| 国产精品亚洲一区二区三区在线| 久久久精品2019中文字幕之3| 国产精品18久久久久久vr| 欧美国产精品中文字幕| 99精品视频在线观看| 亚洲一区二区三区四区在线观看 | 国产在线精品一区二区| 欧美成人艳星乳罩| 国产乱国产乱300精品| 国产精品盗摄一区二区三区| 91久久精品国产91性色tv| 亚欧色一区w666天堂| 日韩欧美色电影| 国产成人免费视频精品含羞草妖精 | 国产电影精品久久禁18| 亚洲欧美在线观看| 欧美日韩专区在线| 欧美成va人片在线观看| 国产精品成人网| 捆绑调教美女网站视频一区| 久久精品视频免费| 欧美羞羞免费网站| 韩国毛片一区二区三区| 亚洲精品自拍动漫在线| 欧美一区二区视频在线观看2020| 国产成人精品1024| 亚洲在线中文字幕| 国产网站一区二区| 欧美在线小视频| 国产综合成人久久大片91| 亚洲欧洲在线观看av| 91麻豆精品国产91久久久资源速度| 国产黑丝在线一区二区三区| 一区二区三区中文在线| 欧美精品久久一区二区三区| 国产麻豆视频一区| ㊣最新国产の精品bt伙计久久| 欧美一级日韩免费不卡| 国产精选一区二区三区| 亚洲一线二线三线视频| 99久久婷婷国产综合精品| 麻豆精品一区二区| **性色生活片久久毛片| 欧美一区二区久久| 91亚洲国产成人精品一区二区三| 亚洲黄色在线视频| 久久亚洲影视婷婷| 色哦色哦哦色天天综合| 久久99久久精品欧美| 一区二区三区欧美久久| 亚洲欧洲一区二区三区| 欧美一级在线观看| 色狠狠一区二区| 韩国v欧美v亚洲v日本v| 国产欧美精品在线观看| 精品国产精品一区二区夜夜嗨| 91丨porny丨蝌蚪视频| 免费成人美女在线观看| 亚洲综合色视频| 久久色.com| 久久影视一区二区| 91精品国产综合久久久久久 | 国产精品区一区二区三区| 91精品国产入口在线| 色激情天天射综合网| 成人免费看视频| 91蝌蚪porny| 成人免费看黄yyy456| 国产中文一区二区三区| 免费观看一级特黄欧美大片| 欧美mv和日韩mv的网站| 久久久久国产免费免费| 2欧美一区二区三区在线观看视频| 欧美亚洲免费在线一区| 91麻豆6部合集magnet| 欧美日韩中文国产| 色94色欧美sute亚洲线路一久| 波多野结衣在线aⅴ中文字幕不卡 波多野结衣在线一区 | 欧美激情一区二区三区不卡 | 国产精品妹子av| 久久女同性恋中文字幕| 精品福利在线导航| 精品乱人伦小说| 久久精品一二三| 2021久久国产精品不只是精品| 久久精品免视看| 国产精品三级av在线播放| 国产精品人人做人人爽人人添| 亚洲欧洲日韩女同| 一区二区激情小说| 午夜国产精品一区| 免费在线观看一区| 国内精品视频一区二区三区八戒 | 欧美一区二区三区色| 91精品婷婷国产综合久久| 欧美一级艳片视频免费观看| 欧美一级国产精品| 国产精品每日更新| 亚洲已满18点击进入久久| 亚洲国产成人av网| 日本人妖一区二区| 91首页免费视频| 欧美日韩国产中文| 8v天堂国产在线一区二区| 成人激情免费视频| 91福利区一区二区三区| 欧美高清视频不卡网| 久久天堂av综合合色蜜桃网| 国产三级精品在线| 亚洲小说春色综合另类电影| 九九**精品视频免费播放| 丁香婷婷综合激情五月色| 在线日韩国产精品| 国产精品久久久一区麻豆最新章节| 亚洲精品videosex极品|