Comunication to HDD adapter:

           complete EXI cycle (32 bits, four bytes)

           byte 0:  command phase: 
                                           
                       bit7: r/w,  (0=write / 1=read)
                       bit6: 8/16, (mode 0=8bit / 1=16bit)
                       bit5: multiple read, (0=normal / 1=active)
                       bit4-0: ATA register select= cs1,cs0,a2,a1,a0
                       
	   byte 1:  dummy in read; 
	            data in write8;
	            data lsb in write16;
	            
	   byte 2:  data lsb in read8; 
	            data msb in write16;
	            dummy in write8;
	            
	   byte 3:  dummy in write8/16;
	            data msb in read16;  
-----------------------------------------------------------------

Example: read any ATA register (8 bit mode)

	snd[0]=(addr&0x1f);  // 000xxxxx  - read 8bit op; addr - address of register to read 
	snd[1]=0;            // dummy byte
	
	exi_write(GC_HDD_CHANNEL,&snd,2);

        // get value from ATA register
		
	snd[0]=getSpiByte();


Example: read ATA register (16 bit)

        snd[0]=(addr&0x1f)|0x40;  // 010xxxxx  - read 16 bit; addr - address of register to read   
	snd[1]=0; // dummy byte
	
	exi_write(GC_HDD_CHANNEL,&snd,2);
			
	snd[0]=getSpiByte(); // read LSB
	snd[1]=getSpiByte(); // read MSB
		

Example: write to ATA register (8 bit)

	snd[0]=(addr&0x1f)|0x80;  // 100xxxxx  - write 8bit op; addr - address of register to read   
	snd[1]=data;
	snd[2]=0; // dummy byte
	exi_write(GC_HDD_CHANNEL,&snd,3);
	
	
Example: 
	
     1- First set Read Multiple op....
      
        ATA_REG_DATA = ATA data register
       
        dwords = (numSectors*512)/4; // (number of 32bit words to read)
       
	snd[0]=(ATA_REG_DATA&0x1f)|0x60;  // 011xxxxx  - read multiple (32bit words) - address: ATA data register
	snd[1]=dwords&0xff;      //  (number of 32bit words to read, 1 sect= 128 dwords)
	snd[2]=0;                
	snd[3]=0; //dummy
	
	exi_write(GC_HDD_CHANNEL,&snd,4);

	
     2- Then read ..... (4 bytes, 32bits for each EXI cycle)
         
       	
	snd[0]=getSpiByte(); // read LSB1
	snd[1]=getSpiByte(); // read MSB1
	snd[2]=getSpiByte(); // read LSB0
	snd[3]=getSpiByte(); // read MSB0
	
      And repeat until read all requested sectors.... 
        
      
      
EXAMPLE OF READ DATA BUFFER FUNCTION UNSING MULTIPLE READ 

static unsigned char ataReadDataBuffer(unsigned char *Buffer, unsigned short numSectors)
{
	unsigned int i;
        unsigned short dwords;
        unsigned int tmp, numBytes;
        
        dwords=numSectors*128; // reads sector in 128 dwords
       
	// read data from drive, init multiple read 
	
	ataRead_init_mult(numSectors); // inicia la transferencia en modo multiple

	tmp=ataRead32(); // lee 4 bytes por ciclo exi

	for (i=0; i<dwords; i++)
	{
		//multiple transfer (series of 32 bits EXI reads)
		
		*Buffer++ = ((tmp >> 16) & 0xff);
		*Buffer++ = ((tmp >> 16 ) >> 8) & 0xff;
		*Buffer++ = (tmp & 0xff);
		*Buffer++ = (tmp >> 8) & 0xff;
		
		tmp=ataRead32(); // lee 4 bytes por ciclo exi

	}
}
      
      
      
Dampro.      