我做了几组实验,像我这样直接经过网线接到电脑上的,IP设置的是以太网地址,只是这样就没有默认网关,所以我按照自己理解,设置为如下
wiz_NetInfo gWIZNETINFO = { .mac = {0x0c, 0x29, 0xab,0x7c, 0x00, 0x01},
.ip = {169, 254, 209, 123}, //是模块本身ip
.sn = {255,255,255,0},
.gw = {169, 254, 209, 1},
.dns = {0,0,0,0},
.dhcp = NETINFO_STATIC }; //静态 NETINFO_DHCP NETINFO_STATIC
这样应该对吧???
我是参照《飞鸿踏雪》引用wiznet库函数,从stm32 改为M4程序,如下
spi配置:
CLK_SetModuleClock(SPI0_MODULE, CLK_CLKSEL2_SPI0SEL_PCLK0, MODULE_NoMsk);
CLK_EnableModuleClock(SPI0_MODULE);
SYS->GPB_MFPL &= ~(SYS_GPB_MFPL_PB2MFP_Msk | SYS_GPB_MFPL_PB3MFP_Msk | SYS_GPB_MFPL_PB4MFP_Msk | SYS_GPB_MFPL_PB5MFP_Msk);
SYS->GPB_MFPL |= (SYS_GPB_MFPL_PB2MFP_SPI0_CLK | SYS_GPB_MFPL_PB3MFP_SPI0_MISO0 | SYS_GPB_MFPL_PB4MFP_SPI0_SS | SYS_GPB_MFPL_PB5MFP_SPI0_MOSI0);
SYS_ResetModule(SPI0_RST);
SPI_Open(SPI0, SPI_MASTER, SPI_MODE_0, 8, 25000000);
SPI_DisableAutoSS(SPI0);
//SPI_SetFIFO(SPI0, 3, 3);
spi读写函数:
void SPI_WriteByte(uint8_t TxData)
{
SPI_SET_SS_LOW(SPI0);
while(SPI_GET_TX_FIFO_EMPTY_FLAG(SPI0)==0);
SPI_WRITE_TX(SPI0,TxData);
while(SPI_IS_BUSY(SPI0));
SPI_READ_RX(SPI0);
SPI_SET_SS_HIGH(SPI0);
}
uint8_t SPI_ReadByte(void)
{
uint8_t ret;
SPI_SET_SS_LOW(SPI0);
//while(SPI_GET_TX_FIFO_EMPTY_FLAG(SPI0)==0);
SPI_WRITE_TX(SPI0,0xff);
//while((SPI1->SR&SPI_I2S_FLAG_RXNE)==0); //等待接收完一个byte《m4没有rx不为空这个标志/函数/宏》
ret= (uint8_t)SPI_READ_RX(SPI0);
SPI_SET_SS_HIGH(SPI0);
return ret;
}
结果是:
MAC: 01:00:00:00:01:01
SIP: 1.1.0.0
GAR: 1.1.0.0
SUB: 1.1.0.0
DNS: 0.0.0.0
|