所以我们在开启第一件事就是配置寄存器,而我们处理发送的顺序为PHY_MODE,MAC address,IP address,gateway_address(网关地址),Set the subnet mask,Set socket 0's mode,Set the size of socket 0's TX buffer,Set the source port for socket 0,Send the command to open the socket, Set the destination IP address for socket 0,Send the command to read the socket state。
首先我们设置出几个状态,按其功能进行命名
1.状态初始在STATE_INITIALIZING状态,该状态内将spi_clk拉低,下一状态转入STATE_SENDING_COMMAND,同时将initialization_progress加一,case他来选择initialization_progress(mosi的数组集合)的赋值,首先是PHY_MODE,spi_chip_select_n赋值给零,spi_clock_count赋值给零,忙信号给1;此状态结束
2.状态转入STATE_SENDING_COMMAND,spi_clk信号取反,即拉高,状态没有变化。
3.状态依然是STATE_SENDING_COMMAND,spi_clk信号取反,即拉低,此时满足下边的条件,执行将spi_clk_count加1,
反复执行这两个状态,到spi_clk_count 加到32时,各项状态仍和3是一样,经过了32x2个系统时钟
4.状态依然在STATE_AEND_COMMAND,只是将spi_chip_select_n拉高为1;此时is_initialized信号为初始值0,,此时将状态转换为STATE_INITIALIZING
状态再次到达1,此种状态一直重复直到将29个数据全部发送完毕。依次发送的是PHY_MODE,MAC address,IP address,gateway_address(网关地址),Set the subnet mask,Set socket 0's mode,Set the size of socket 0's TX buffer,Set the source port for socket 0,Send the command to open the socket, Set the destination IP address for socket 0,Send the command to read the socket state。