
© Copyright 2011 WIZnet Co., Inc. All rights reserved. Ver. 1.1
12
W7200-EVB User
’s
Guide
7
W7200 SPI
Below diagram show internal SPI connection between STM32F103CB and W5200.
Figure 5 W7200 SPI Interface
A pseudo code for read/write with SPI is shown below. Check the W5200 documentation for
SPI burst mode, and how to use it.
Code 1 Pseudo code for Read with SPI interface
#define
data_read_command 0x00
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 */
{
ISR_DISABLE();
// Interrupt Service Routine disable
CSoff();
// CS=0, SPI start
//SpiSendData
SpiSendData(((addr+idx) & 0xFF00) >> 8);
//Address byte 1
SpiSendData((addr+idx) & 0x00FF);
//Address byte 2
// data write c data length upper 7bits
SpiSendData((data_read_command | ((data_len & 0x7F00) >> 8)));
// data length bottom 8bits
SpiSendData((data_len & 0x00FF));