Beispiel #1
0
void IINCHIP_RXBUF_WRRD(uint16 addr, uint8 data)
{
   uint8 rdata, redata;
   IINCHIP_ISR_DISABLE();                      // Interrupt Service Routine Disable
   
   //SPI MODE I/F
   IINCHIP_CSoff();                            // CS=0, SPI start
   IINCHIP_SpiSendData((addr & 0xFF00) >> 8);  // Address byte 1
   IINCHIP_SpiSendData(addr & 0x00FF);         // Address byte 2
   IINCHIP_SpiSendData(g_rx_wr_cntl_bits);             // Data write command and Write data length 1
   IINCHIP_SpiSendData(data);                  // Data write (write 1byte data)
   IINCHIP_CSon();                             // CS=1,  SPI end
   
   IINCHIP_CSoff();                             // CS=0, SPI start 
   IINCHIP_SpiSendData((addr & 0xFF00) >> 8);   // Address byte 1
   IINCHIP_SpiSendData(addr & 0x00FF);          // Address byte 2
   IINCHIP_SpiSendData(g_rx_rd_cntl_bits);              // Data read command and Read data length 1
   rdata = IINCHIP_SpiSendData(0x00);            // Data read (read 1byte data) 
   IINCHIP_CSon();                             // CS=1,  SPI end
   
   IINCHIP_ISR_ENABLE();                       // Interrupt Service Routine Enable
   
   if( rdata != data )
   {
      printf("addr:%X, data:%X, rdata:%X, ", addr, data, rdata);
      IINCHIP_ISR_DISABLE();                      // Interrupt Service Routine Disable
      IINCHIP_CSoff();                             // CS=0, SPI start 
      IINCHIP_SpiSendData((addr & 0xFF00) >> 8);   // Address byte 1
      IINCHIP_SpiSendData(addr & 0x00FF);          // Address byte 2
      IINCHIP_SpiSendData(g_rx_rd_cntl_bits);              // Data read command and Read data length 1
      redata = IINCHIP_SpiSendData(0x00);            // Data read (read 1byte data) 
      IINCHIP_CSon();                             // CS=1,  SPI end      
      IINCHIP_ISR_ENABLE();                       // Interrupt Service Routine Enable      
      printf("redata:%X \r\n", redata);
   }
Beispiel #2
0
/*
@brief  This function writes into W5200 memory(Buffer)
*/ 
uint16 IINCHIP_WRITE_BLOCK(uint16 addr,uint8* buf,uint16 len)
{
  uint16 idx = 0;

  if(len == 0)
    return 0;

  IINCHIP_ISR_DISABLE();

  //SPI MODE I/F
  IINCHIP_CSoff();                                        // CS=0, SPI start 
  
  IINCHIP_SpiSendData(((addr+idx) & 0xFF00) >> 8);        // Address byte 1
  IINCHIP_SpiSendData((addr+idx) & 0x00FF);               // Address byte 2
  IINCHIP_SpiSendData((0x80 | ((len & 0x7F00) >> 8)));    // Data write command and Write data length 1
  IINCHIP_SpiSendData((len & 0x00FF));                    // Write data length 2
  for(idx = 0; idx < len; idx++)                          // Write data in loop
  {   
    IINCHIP_SpiSendData(buf[idx]);
  }
  
  IINCHIP_CSon();                                         // CS=1, SPI end 
        
  IINCHIP_ISR_ENABLE();                                   // Interrupt Service Routine Enable        
  return len;
}
Beispiel #3
0
void IINCHIP_WRITE( uint32 addrbsb,  uint8 data)
{
   IINCHIP_ISR_DISABLE();                        // Interrupt Service Routine Disable
   IINCHIP_CSoff();                              // CS=0, SPI start
   IINCHIP_SpiSendData( (addrbsb & 0x00FF0000)>>16);// Address byte 1
   IINCHIP_SpiSendData( (addrbsb & 0x0000FF00)>> 8);// Address byte 2
   IINCHIP_SpiSendData( (addrbsb & 0x000000F8) + 4);    // Data write command and Write data length 1
   IINCHIP_SpiSendData(data);                    // Data write (write 1byte data)
   IINCHIP_CSon();                               // CS=1,  SPI end
   IINCHIP_ISR_ENABLE();                         // Interrupt Service Routine Enable
}
Beispiel #4
0
 /**
@brief  This function writes the data into W5100 registers.
*/
void wiz_write_byte(uint16 addr,uint8 data)
{
    IINCHIP_ISR_DISABLE();
    IINCHIP_SpiInit();
    IINCHIP_CSoff();                             // CS=0, SPI start
    IINCHIP_SpiSendData(0xF0);
    IINCHIP_SpiSendData(addr>>8);
    IINCHIP_SpiSendData(addr);
    IINCHIP_SpiSendData(data);
    IINCHIP_CSon();    
    IINCHIP_ISR_ENABLE();   
}
Beispiel #5
0
uint8 IINCHIP_READ(uint32 addrbsb)
{
   uint8 data = 0;
   IINCHIP_ISR_DISABLE();                        // Interrupt Service Routine Disable
   IINCHIP_CSoff();                              // CS=0, SPI start
   IINCHIP_SpiSendData( (addrbsb & 0x00FF0000)>>16);// Address byte 1
   IINCHIP_SpiSendData( (addrbsb & 0x0000FF00)>> 8);// Address byte 2
   IINCHIP_SpiSendData( (addrbsb & 0x000000F8))    ;// Data read command and Read data length 1
   data = IINCHIP_SpiSendData(0x00);             // Data read (read 1byte data)
   IINCHIP_CSon();                               // CS=1,  SPI end
   IINCHIP_ISR_ENABLE();                         // Interrupt Service Routine Enable
   return data;    
}
Beispiel #6
0
/**
@brief  This function reads the value from W5100 registers.
*/
uint8 wiz_read_byte(uint16 addr)
{
  uint8 data;
  
    IINCHIP_ISR_DISABLE();
    IINCHIP_SpiInit();  
    IINCHIP_CSoff();                             // CS=0, SPI start
    IINCHIP_SpiSendData(0x0F);
    IINCHIP_SpiSendData(addr>>8);
    IINCHIP_SpiSendData(addr);
    IINCHIP_SpiSendData(0);
    data = IINCHIP_SpiRecvData();
    IINCHIP_CSon();                            // SPI end
    IINCHIP_ISR_ENABLE();
    return data;
}
Beispiel #7
0
uint8 IINCHIP_WRITE(uint16 addr,uint8 data)
{
    IINCHIP_ISR_DISABLE();                      // Interrupt Service Routine Disable

	//SPI MODE I/F
	IINCHIP_CSoff();                            // CS=0, SPI start

	IINCHIP_SpiSendData((addr & 0x0700) >> 8);  // Address byte 1
	IINCHIP_SpiSendData(addr & 0x00FF);         // Address byte 2
	IINCHIP_SpiSendData(((addr&0xF800) >> 8)|FDM1|RWB_WRITE);        // Data write command and Write data length 1
	IINCHIP_SpiSendData(data);                  // Data write (write 1byte data)
	
	IINCHIP_CSon();                             // CS=1,  SPI end

    IINCHIP_ISR_ENABLE();                       // Interrupt Service Routine Enable
	return 1;
}
Beispiel #8
0
/**
@brief	This function reads the value from W5200 registers.
*/
uint8 IINCHIP_READ(uint16 addr)
{
	uint8 data;
        
	IINCHIP_ISR_DISABLE();                       // Interrupt Service Routine Disable
	
	IINCHIP_CSoff();                             // CS=0, SPI start
	
    IINCHIP_SpiSendData((addr & 0x0700) >> 8);   // Address byte 1
	IINCHIP_SpiSendData(addr & 0x00FF);          // Address byte 2
	IINCHIP_SpiSendData(((addr & 0xF800) >> 8)|FDM1|RWB_READ);                    // Data read command and Read data length 1
	data = IINCHIP_SpiSendData(0x00);                   // Read data 
	
    IINCHIP_CSon();                              // CS=1,  SPI end
	
    IINCHIP_ISR_ENABLE();                        // Interrupt Service Routine Enable
	return data;
}
Beispiel #9
0
uint16 wiz_write_buf(uint32 addrbsb,uint8* buf,uint16 len)
{
   uint16 idx = 0;
   if(len == 0) printf("Unexpected2 length 0\r\n");

   IINCHIP_ISR_DISABLE();
   IINCHIP_CSoff();                              // CS=0, SPI start
   IINCHIP_SpiSendData( (addrbsb & 0x00FF0000)>>16);// Address byte 1
   IINCHIP_SpiSendData( (addrbsb & 0x0000FF00)>> 8);// Address byte 2
   IINCHIP_SpiSendData( (addrbsb & 0x000000F8) + 4);    // Data write command and Write data length 1
   for(idx = 0; idx < len; idx++)                // Write data in loop
   {
     IINCHIP_SpiSendData(buf[idx]);
   }
   IINCHIP_CSon();                               // CS=1, SPI end
   IINCHIP_ISR_ENABLE();                         // Interrupt Service Routine Enable    

   return len;  
}
Beispiel #10
0
/**
@brief	This function reads into W5200 memory(Buffer)
*/ 
uint16 wiz_read_buf(uint16 addr, uint8* buf,uint16 len)
{
	uint16 idx = 0;
        
	IINCHIP_ISR_DISABLE();                                  // Interrupt Service Routine Disable
        
	IINCHIP_CSoff();                                        // CS=0, SPI start 
        
	IINCHIP_SpiSendData((addr & 0x0700) >> 8);        // Address byte 1
	IINCHIP_SpiSendData( addr & 0x00FF);               // Address byte 2
	IINCHIP_SpiSendData(((addr & 0xF800)>>8)|RWB_READ|VDM);    // Data read command

	for(idx = 0; idx < len; idx++)                          // Read data in loop
	{
	 	buf[idx] = IINCHIP_SpiSendData(0x00);
	}
        
	IINCHIP_CSon();                                         // CS=0, SPI end 	   	
        
	IINCHIP_ISR_ENABLE();                                   // Interrupt Service Routine Enable
	return len;
}
Beispiel #11
0
/**
@brief	This function writes into W5200 memory(Buffer)
*/ 
uint16 wiz_write_buf(uint16 addr,uint8* buf,uint16 len)
{
	uint16 idx = 0;
	
	IINCHIP_ISR_DISABLE();
     
	//SPI MODE I/F
	IINCHIP_CSoff();                                        // CS=0, SPI start 
	
    IINCHIP_SpiSendData((addr & 0x0700) >> 8);        // Address byte 1
	IINCHIP_SpiSendData((addr) & 0x00FF);               // Address byte 2
	IINCHIP_SpiSendData(((addr & 0xF800) >> 8)|RWB_WRITE|VDM);    // Data write command and Write data length 1
	for(idx = 0; idx < len; idx++)                          // Write data in loop
	{	
		IINCHIP_SpiSendData(buf[idx]);
	}
	
    IINCHIP_CSon();                                         // CS=1, SPI end 
        
    IINCHIP_ISR_ENABLE();                                   // Interrupt Service Routine Enable        
	return len;
}
Beispiel #12
0
/*
@brief  This function reads into W5200 memory(Buffer)
*/ 
uint16 IINCHIP_READ_BLOCK(uint16 addr, uint8* buf,uint16 len)
{
  uint16 idx = 0;
        
  IINCHIP_ISR_DISABLE();                                  // Interrupt Service Routine Disable
        
  IINCHIP_CSoff();                                        // CS=0, SPI start 
        
  IINCHIP_SpiSendData(((addr+idx) & 0xFF00) >> 8);        // Address byte 1
  IINCHIP_SpiSendData((addr+idx) & 0x00FF);               // Address byte 2
  IINCHIP_SpiSendData((0x00 | ((len & 0x7F00) >> 8)));    // Data read command
  IINCHIP_SpiSendData((len & 0x00FF));            

  for(idx = 0; idx < len; idx++)                          // Read data in loop
  {
    buf[idx] = IINCHIP_SpiSendData(0x00);
    
  }
        
  IINCHIP_CSon();                                         // CS=0, SPI end      
        
  IINCHIP_ISR_ENABLE();                                   // Interrupt Service Routine Enable
  return len;
}