CHAPTER 5 APPLICATION EXAMPLES
Application Note U17121EJ1V1AN
90
int status;
status = Wait_IDE_BSY0_DRQ0();
// Wait until BSY=0, DRQ=0
if ( status != 0 ) {
return STATUS_TIMEOUT_BSY0_DRQ0;
// Timeout error end
}
*IDEREG_DEVICE_HEAD = dev_num << 4;
// Device selection
wait(TIMER400ns);
// Wait 400 ns
status = Wait_IDE_BSY0_DRQ0();
// Wait until BSY=0, DRQ=0
if ( status != 0 ) {
return STATUS_TIMEOUT_BSY0_DRQ0;
// Timeout error end
}
return STATUS_SUCCESS;
// Normal end
}
/////////////////////////////////////////////////////////////////////////
// Function name: ATA_PIO_datain //
// Function: Executes PIO data in command protocol. //
// Argument: atacom : ATA_COMMAND structure pointer //
// sector_count : Number of sectors //
// 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_PIO_datain(ATA_COMMAND *atacom, UHWORD sector_count, void *buff)
{
UBYTE dev, idestat;
UWORD *buffp;
int i, j, status;
buffp = (UWORD*)buff;
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
Содержание V850E/MA1
Страница 2: ...Application Note U17121EJ1V1AN 2 MEMO ...