summaryrefslogtreecommitdiff
path: root/libhw/rp2040_include
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-30 01:44:34 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-10-30 01:46:19 -0600
commit191c5ae0cde0b753eaa6d4e9074ddab465933700 (patch)
treee59e0a3a08b7e2aa936d031142354780502bd062 /libhw/rp2040_include
parent26361be59c08917c47718bcd4114b8028aaf7810 (diff)
Finish the W5500 driver?
Diffstat (limited to 'libhw/rp2040_include')
-rw-r--r--libhw/rp2040_include/libhw/w5500.h34
1 files changed, 18 insertions, 16 deletions
diff --git a/libhw/rp2040_include/libhw/w5500.h b/libhw/rp2040_include/libhw/w5500.h
index 037d4f1..16f88cc 100644
--- a/libhw/rp2040_include/libhw/w5500.h
+++ b/libhw/rp2040_include/libhw/w5500.h
@@ -7,6 +7,8 @@
#ifndef _LIBHW_W5500_H_
#define _LIBHW_W5500_H_
+#include <pico/binary_info.h> /* for bi_* */
+
#include <libcr_ipc/sema.h>
#include <libcr_ipc/mutex.h>
#include <libmisc/private.h>
@@ -14,27 +16,27 @@
#include <libhw/generic/net.h>
#include <libhw/generic/spi.h>
-struct _w5500_tcp_conn {
- /* const-after-init */
- implements_net_stream_conn;
- /* mutable */
- BEGIN_PRIVATE(LIBHW_W5500_H)
- bool read_open;
- bool write_open;
- END_PRIVATE(LIBHW_W5500_H)
-};
-
-struct _w5500_tcp_listener {
+struct _w5500_socket {
/* const-after-init */
- implements_net_stream_listener;
+ implements_net_stream_listener implements_net_stream_listener;
+ implements_net_stream_conn implements_net_stream_conn;
+ implements_net_packet_conn implements_net_packet_conn;
BEGIN_PRIVATE(LIBHW_W5500_H)
uint8_t socknum;
- struct _w5500_tcp_conn active_conn;
/* mutable */
- uint16_t port;
+ enum {
+ W5500_MODE_NONE = 0,
+ W5500_MODE_TCP,
+ W5500_MODE_UDP,
+ } mode;
+ uint16_t port; /* MODE_{TCP,UDP} */
+ uint64_t read_deadline_ns; /* MODE_{TCP,UDP} */
+ cr_sema_t listen_sema; /* MODE_TCP */
+ cr_sema_t read_sema; /* MODE_{TCP,UDP} */
+ bool read_open, write_open; /* MODE_TCP */
+
cr_mutex_t cmd_mu;
- cr_sema_t listen_sema, read_sema;
END_PRIVATE(LIBHW_W5500_H)
};
@@ -48,7 +50,7 @@ struct w5500 {
/* mutable */
uint16_t next_local_port;
- struct _w5500_tcp_listener listeners[8];
+ struct _w5500_socket sockets[8];
cr_sema_t intr;
END_PRIVATE(LIBHW_W5500_H)
};