我平时用的这份.c,注释里写了Write a dummy byte
/* Read W5500 Socket register 1 Byte */
unsigned char Read_SOCK_1_Byte(SOCKET s, unsigned short reg)
{
unsigned char i;
/* Set W5500 SCS Low */
W5500_SCS_LOW;
/* Write Address */
SPI_I2S_SendData(SPI2,reg/256);
while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
SPI_I2S_SendData(SPI2,reg);
while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
/* Write Control Byte */
SPI_I2S_SendData(SPI2,(FDM1|RWB_READ|(s*0x20+0x08)));
while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
/* Write a dummy byte */
i=SPI_I2S_ReceiveData(SPI2);
SPI_I2S_SendData(SPI2,0x00);
while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
/* Read 1 byte */
i=SPI_I2S_ReceiveData(SPI2);
/* Set W5500 SCS High*/
W5500_SCS_HIGH;
return i;
}
|