diff options
Diffstat (limited to 'cmd/sbc_harness/hw/w5500.h')
-rw-r--r-- | cmd/sbc_harness/hw/w5500.h | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/cmd/sbc_harness/hw/w5500.h b/cmd/sbc_harness/hw/w5500.h index 0f37797..90d4130 100644 --- a/cmd/sbc_harness/hw/w5500.h +++ b/cmd/sbc_harness/hw/w5500.h @@ -1,16 +1,38 @@ #ifndef _HW_W5500_H_ #define _HW_W5500_H_ +#include <libnet/libnet.h> + #include "hw/spi.h" +struct _w5500_listener; + +struct _w5500_conn { + struct libnet_conn_vtable *vtable; + + struct _w5500_listener *parent_listener; +}; + +struct _w5500_listener { + struct libnet_listener_vtable *vtable; + + struct w5500 *chip; + uint8_t socknum; + struct _w5500_conn active_conn; +}; + struct w5500 { - struct spi *spidev; + struct spi *spidev; + uint pin_reset; + + struct _w5500_listener _listeners[8]; + uint16_t _next_local_port; }; /** - * Initialize a WIZnet W5500 Ethernet and TCP/IP-offload chip. + * Initialize a WIZnet W5500 Ethernet-and-TCP/IP-offload chip. * - * The W5500 has 2 channels of communication with the MCU: + * The W5500 has 3 channels of communication with the MCU: * * - An SPI-based RPC protocol: * + mode: mode 0 or mode 3 @@ -19,11 +41,33 @@ struct w5500 { * - An interrupt pin that it pulls low when an event happens (to let * the MCU know that it should do an SPI RPC "get" to see what * happened.) + * - A reset pin that the MCU can pull low to reset the W5500. */ -#define w5500_init(self, name, spi, pin_intr) do { \ - bi_decl(bi_1_pin_with_name(pin_intr, name" interrupt")); \ - _w5500_init(self, spi, pin_intr); \ +#define w5500_init(self, name, spi, pin_intr, pin_reset, eth_addr) do { \ + bi_decl(bi_2_pins_with_names(pin_intr, name" interrupt"), \ + pin_reset, name" reset"); \ + _w5500_init(self, spi, pin_intr, pin_reset, eth_addr); \ } while (0) -void _w5500_init(struct w5500 *self, struct spi* spi, uint pin_intr); +void _w5500_init(struct w5500 *self, + struct spi* spi, uint pin_intr, + struct eth_addr addr); + +/** + * TODO. + */ +void w5500_reset(struct w5500 *self); + +struct w5500_netcfg { + struct ip4_addr gateway_addr; + struct ip4_addr subnet_mask; + struct ip4_addr addr; +}; + +/** + * TODO. + */ +void w5500_netcfg(struct w5500 *self, struct w5500_netcfg cfg); + +struct libnet_listener *w5500_listen(struct w5500 *self, uint8_t socknum, uint16_t port); #endif /* _HW_W5500_H_ */ |