© Copyright 2011 WIZnet Co., Inc. All rights reserved. Ver. 1.1
13
W7200-EVB User
’s
Guide
SpiSendData(0);
//dummy data
data_buf[idx] = SpiRecvData(idx);
//READ data
CSon();
// CS=1, SPI end
ISR_ENABLE();
// Interrupt Service Routine disable
}
Code 2 Pseudo code for write with SPI interface
#define
data_write_command 0x80
uint16 addr;
//address : 16bits
int16 data_len;
//data_length :15bits
uint8 data_buf[];
// array for data
SpiSendData();
//send data from MCU to W5200
SpiRecvData();
//Receive data from W5200 to MCU
/* Pseudo Code for Read data of 8bit per packet */
{
SpiSendData();
//send data from MCU to W5200
ISR_DISABLE();
// Interrupt Service Routine disable
CSoff();
// CS=0, SPI start
SpiSendData(((addr+idx) & 0xFF00) >> 8);
//Address byte 1
SpiSendData((addr+idx) & 0x00FF);
//Address byte 2
// data write c data length upper 7bits
SpiSendData((data_write_command | ((data_len & 0x7F00) >> 8)));
// data length bottom 8bits
SpiSendData((data_len & 0x00FF));
SpiSendData(data_buf[idx]);
CSon();
// CS=1, SPI end
IINCHIP_ISR_ENABLE();
// Interrupt Service Routine disable
}