CHAPTER 5 APPLICATION EXAMPLES
Application Note U17121EJ1V1AN
93
return STATUS_IDE_ERROR(*IDEREG_ERROR); // Error end (after command execution)
}
return STATUS_SUCCESS; // Normal end
}
/////////////////////////////////////////////////////////////////////////
// Function name: ATA_PIO_nondata //
// Function: Executes PIO non data command protocol. //
// Argument: atacom : ATA_COMMAND structure 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_PIO_nondata(ATA_COMMAND *atacom)
{
int status;
UBYTE dev, idestat;
dev = ( atacom->device_head >> 4 ) & 1;
status = ATA_Device_Selection(dev); // DEVICE SELECTION
if ( status != 0 ) {
return STATUS_TIMEOUT_DEVICE_SELECTION; // DEVICE SELECTION timeout
}
*IDEREG_FEATURES = atacom->features; // Features register
*IDEREG_SECTOR_COUNT = atacom->sector_count; // SectorCount register
*IDEREG_SECTOR_NUMBER = atacom->sector_number; // SectorNumber register
*IDEREG_CYLINDER_LOW = atacom->cylinder_low; // CylinderLow register
*IDEREG_CYLINDER_HIGH = atacom->cylinder_high; // CylinderHigh register
status = Wait_IDE_DRDY1(); // Loop until DRDY=1
if ( status != 0 ) {
return STATUS_TIMEOUT_DRDY1; // DRDY timeout
}
*IDEREG_COMMAND = atacom->command; // Command register
wait(TIMER400ns); // Wait 400 ns
status = Wait_IDE_INTRQ(); // Wait for INTRQ assert
if ( status != 0 ) {
return STATUS_TIMEOUT_INTRQ; // INTRQ timeout error
}