STM32 - WIZnet W5500: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 37: | Line 37: | ||
void Callback_IP_Assigned(void); | void Callback_IP_Assigned(void); | ||
void Callback_IP_Conflict(void); | void Callback_IP_Conflict(void); | ||
==Calling w5500_init() from command_line== | |||
>init | |||
w5500_init() | |||
w5500_hardware_reset() | |||
Registering W5500 callbacks... | |||
Calling wizchip_init()... | |||
wizchip_sw_reset() | |||
wizchip_init() Success! | |||
PHY Link Up | |||
Calling DHCP_init()... | |||
w5500_init(), MAC:EA 11 22 33 44 EA | |||
Registering DHCP callbacks... | |||
Calling DHCP_run()... | |||
IP assigned! Leased time: 86400 sec | |||
IP: 192.168.1.126 | |||
GW: 192.168.1.1 | |||
Net: 255.255.255.0 | |||
DNS: 192.168.1.1 | |||
Calling wizchip_setnetinfo()... | |||
Calling DNS_init()... |
Revision as of 16:42, 21 January 2023
The WIZnet W5500 Ethernet chip provides an easy Ethernet network solution for many microprocessors/microcontrollers. Using a SPI interface and sample library code, most any processor can use this device to get connected to a network.
Hardware Interface
In my case, I purchased a small development module from Amazon.com. This same module is readily available on Ebay.com and Aliexpress.com Examples: https://www.amazon.com/AITRIP-Ethernet-Hardware-Microcontroller-Interface/dp/B09FG5VZFS/ref=sr_1_10 https://www.aliexpress.us/item/3256801465688850.html A 10 conductor, 2x5 pin header, provides the electrical connection between the host and this module I wired mine using a female-female ribbon cable as follows: Wire Color Signal W5500 Module Pin NUCLEO-F103RB Pin Comment Brown Not Connected J1-1 NC Red SPI-SCLK J1-2 SCLK SPI2_SCK, PB13, CN10-30 Orange INTn J1-3 INT PB11, CN10-18 Active low Yellow SPI-CSn J1-4 SCS SPI2_NCS, PB12, CN10-16 Active Low Chip Select Green RSTn J1-5 nRST PB10, CN10-25 Active Low, 500us min Blue MOSI J1-6 MOSI SPI2_MOSI, PB15, CN10-26 Violet GND J1-7 GND GND, CN10-20 Grey MISO J1-8 MISO SPI2_MISO, PB14, CN10-28 White 5.0V (NC) J1-9 NC Black 3.3V J1-10 3.3V +3V3, CN7-16 Information in the comment field describes what pin/function I connected to on my NUCLEO-F103RB board.
Target Software Interface
The WIZnet software library, "ioLibrary_Driver-master", https://github.com/Wiznet/ioLibrary_Driver interfaces to the target via function pointers. Need to implement the following functions (function name not important): void W5500_Select(void); // Drive the SPI-CSn signal low, selecting the device void W5500_Deselect(void); // Drive the SPI-CSn signal high, deselecting the device void W5500_WriteByte(void); // Write a single byte to the device uint8_t W5500_ReadByte(void); // Read a single byte from the device void W5500_WriteBuff(uint8_t* buff, uint16_t len); // Write one or more bytes from a buffer void W5500_ReadBuff(uint8_t* buff, uint16_t len); // Read one or more bytes into a buffer For DHCP, a couple call-back functions need implementations: void Callback_IP_Assigned(void); void Callback_IP_Conflict(void);
Calling w5500_init() from command_line
>init w5500_init() w5500_hardware_reset() Registering W5500 callbacks... Calling wizchip_init()... wizchip_sw_reset() wizchip_init() Success! PHY Link Up Calling DHCP_init()... w5500_init(), MAC:EA 11 22 33 44 EA Registering DHCP callbacks... Calling DHCP_run()... IP assigned! Leased time: 86400 sec IP: 192.168.1.126 GW: 192.168.1.1 Net: 255.255.255.0 DNS: 192.168.1.1 Calling wizchip_setnetinfo()... Calling DNS_init()...