The ENC424J600 Ethernet controller module supports operation in one of the following interfaces: Serial Peripheral Interace (SPI), or Parallel Slave Port (PSP). This Rust library currently only supports the use of SPI for STM32F4xx microcontrollers.
On ENC424J600, the **INTn/SPISEL** pin is multiplexed with an **interrupt function** (INTn) and an **interface selection function** (SPISEL). During power-up, to select SPI as the interface, INTn/SPISEL needs to latch a logic high for 1-10 us, driven outside of ENC424J600. After ENC424J600 has been initialsed, the same pin can be used to indicate occurrence of interrupt with a logic low, or idling with a logic high, driven by ENC424J600. Therefore, on the microcontroller side, the mode of driving the pin should be chosen by design: it should be **tri-stated** if interrupt is enabled, or **push-pull** otherwise.
### Instructions for STM32F407 Examples
These examples assume that the **SPI1** port is connected to the Ethernet module, and the **GPIO PA1** pin is connected to its SPISEL pin. Since no interrupts are involved, GPIO PA1 is configured as a **push-pull** output to only initialise the controller. The program output is logged via ITM stimulus port 0.
This program demonstrates the Ethernet TX capability on an STM32F407 board. Once loaded and initialised, a specific ping packet is sent (broadcasted) every 100ms. Such a packet has the following properties:
1. Connect your STM32F407 device to the computer. Without changing any code, you may use an STLink V2 debugger. Then, on a console window, run OpenOCD and debug the example program:
This program demonstrates the TCP connectivity using **smoltcp** on an STM32F407 board. Once loaded and initialised, two TCP sockets will be opened on a specific IPv4 address. These sockets are:
* Note that once a greeting is sent, the socket is closed immediately. Further packets received by the controller are dropped until the initiator disconnects from the port.
1. Connect your STM32F407 device to the computer. Without changing any code, you may use an STLink V2 debugger. Then, on a console window, run OpenOCD and debug the example program. Choose your own IPv4 address and prefix length:
Multiple instances of Netcat can run to use all the ports simultaneously. Use Ctrl+C to disconnect from the port manually (especially for the greeting port).
After 10 seconds of the user not sending any more packets on port 1234, the following is appended to the ITM output; meanwhile, the socket is closed by `nc` for the user:
For port 4321, without closing the port by exiting `nc`, the user keeps sending any packets with the utility. Since the Ethernet controller has already closed the socket, these new packets are dropped and the following error messages are appended to the ITM output: