CHAPTER 5 APPLICATION EXAMPLES
Application Note U17121EJ1V1AN
86
ac.features
= 0x00;
// Features register
ac.sector_count
= 0x00;
// SectorCount register
ac.sector_number
= 0x00;
// SectorNumber register
ac.cylinder_low
= 0x00;
// CylinderLow register
ac.cylinder_high
= 0x00;
// CylinderHigh register
ac.device_head
= dev_num<<4;
// Device/Head register
ac.command
= 0xE1;
// Command register
status = ATA_PIO_nondata(&ac);
return status;
}
///////////////////////////////////////////////////////////////////////////
// Function name: ATA_Identify_Device //
// Function: Executes IDENTIFY DEVICE command (Protocol:PI, Command:ECh).//
// Argument: dev_num : Device selection (0:Master/1:Slave) //
// buff : Buffer pointer //
// Return value: //
// STATUS_SUCCESS : Normal end //
// STATUS_TIMEOUT_DEVICE_SELECTION : DEVICE SELECTION error end //
// STATUS_TIMEOUT_DRDY1 : DRDY=1 timeout error end //
// STATUS_TIMEOUT_INTRQ : INTRQ timeout error end //
// STATUS_IDE_ERROR : Error end after command execution //
// //
///////////////////////////////////////////////////////////////////////////
int ATA_Identify_Device(int dev_num, void *buff)
{
ATA_COMMAND ac;
int status;
ac.features
= 0x00;
// Features register
ac.sector_count
= 0x00;
// SectorCount register
ac.sector_number
= 0x00;
// SectorNumber register
ac.cyliner_low
= 0x00;
// CylinderLow register
ac.cylinder_high
= 0x00;
// CylinderHigh register
ac.dev_head
= dev_num << 4;
// Device/Head register
ac.command
= 0xEC;
// Command register
status = ATA_PIO_datain(&ac, 1, buff);
return status;
}
//////////////////////////////////////////////////////////////////////////
// Function name: ATA_Read_Sector //