From c63584e6bcb934d84ef277cdc4619763a41f1bbe Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 2 Mar 2025 13:43:36 -0700 Subject: libhw: w5500: Add a VALIDATE_SPI toggle --- cmd/sbc_harness/config/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/sbc_harness') diff --git a/cmd/sbc_harness/config/config.h b/cmd/sbc_harness/config/config.h index f9c7df2..0fa95ae 100644 --- a/cmd/sbc_harness/config/config.h +++ b/cmd/sbc_harness/config/config.h @@ -22,8 +22,8 @@ #define CONFIG_W5500_LOCAL_PORT_MIN 32768 #define CONFIG_W5500_LOCAL_PORT_MAX 60999 +#define CONFIG_W5500_VALIDATE_SPI 1 /* bool */ #define CONFIG_W5500_DEBUG 1 /* bool */ - #define CONFIG_W5500_LL_DEBUG 0 /* bool */ /* 9P *************************************************************************/ -- cgit v1.2.3-2-g168b From 6354a440b24d9a0b157c8c5571403f09dd04c245 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 2 Mar 2025 21:16:35 -0700 Subject: libhw: Update comments and asserts about clock rate --- cmd/sbc_harness/config/config.h | 4 ++++ cmd/sbc_harness/main.c | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'cmd/sbc_harness') diff --git a/cmd/sbc_harness/config/config.h b/cmd/sbc_harness/config/config.h index 0fa95ae..e923ac8 100644 --- a/cmd/sbc_harness/config/config.h +++ b/cmd/sbc_harness/config/config.h @@ -9,6 +9,10 @@ #include /* for size_t */ +/* RP2040 *********************************************************************/ + +#define CONFIG_RP2040_SPI_DEBUG 1 /* bool */ + /* W5500 **********************************************************************/ /** diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 6f1d0ca..6fa76bd 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -168,11 +168,11 @@ COROUTINE init_cr(void *) { rp2040_hwspi_init(&globals.dev_spi, "W5500", RP2040_HWSPI_0, SPI_MODE_0, /* the W5500 supports mode 0 or mode 3 */ - 60*1000*1000, /* as close to the W5500's max rate of 80MHz as we can without hwspi borking */ - 16, /* PIN_MISO */ - 19, /* PIN_MOSI */ - 18, /* PIN_CLK */ - 17); /* PIN_CS */ + 31250000, /* min(w5500, hwspi); w5500=80MHz; hwspi=31.25MHz, see rp2040_hwspi.h for a comment about why this is so low */ + 16, /* PIN_MISO */ + 19, /* PIN_MOSI */ + 18, /* PIN_CLK */ + 17);/* PIN_CS */ w5500_init(&globals.dev_w5500, "W5500", lo_box_rp2040_hwspi_as_spi(&globals.dev_spi), 21, /* PIN_INTR */ -- cgit v1.2.3-2-g168b From fb73355711c99003c559df48164a1ce6db93cff9 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Tue, 4 Mar 2025 00:05:35 -0700 Subject: libhw: rp2040_hwspi: Add more config knobs --- cmd/sbc_harness/main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cmd/sbc_harness') diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 6fa76bd..a3351fc 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -169,6 +169,8 @@ COROUTINE init_cr(void *) { rp2040_hwspi_init(&globals.dev_spi, "W5500", RP2040_HWSPI_0, SPI_MODE_0, /* the W5500 supports mode 0 or mode 3 */ 31250000, /* min(w5500, hwspi); w5500=80MHz; hwspi=31.25MHz, see rp2040_hwspi.h for a comment about why this is so low */ + 30, /* W5500 datasheet says min(T_CS = SCSn High Time) = 30ns */ + 0, /* bogus write write data when doing a read */ 16, /* PIN_MISO */ 19, /* PIN_MOSI */ 18, /* PIN_CLK */ -- cgit v1.2.3-2-g168b From c336bf7f2205131c86e6d2991770a2c150d85ca9 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Mon, 24 Feb 2025 22:54:30 -0700 Subject: libhw: rp2040_hwspi: Use DMA --- cmd/sbc_harness/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'cmd/sbc_harness') diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index a3351fc..8e2c5ee 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -174,7 +174,8 @@ COROUTINE init_cr(void *) { 16, /* PIN_MISO */ 19, /* PIN_MOSI */ 18, /* PIN_CLK */ - 17);/* PIN_CS */ + 17, /* PIN_CS */ + 0, 1, 2, 3); /* DMA channels */ w5500_init(&globals.dev_w5500, "W5500", lo_box_rp2040_hwspi_as_spi(&globals.dev_spi), 21, /* PIN_INTR */ -- cgit v1.2.3-2-g168b From 7a1f764cda070de396fcb186e1f7457ff2704ba4 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sun, 2 Mar 2025 23:22:40 -0700 Subject: Bump the CPU clock speed, wring a few more MHz out of the hwspi --- cmd/sbc_harness/CMakeLists.txt | 10 ++++++++++ cmd/sbc_harness/main.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'cmd/sbc_harness') diff --git a/cmd/sbc_harness/CMakeLists.txt b/cmd/sbc_harness/CMakeLists.txt index 081a5fc..d7923c2 100644 --- a/cmd/sbc_harness/CMakeLists.txt +++ b/cmd/sbc_harness/CMakeLists.txt @@ -31,6 +31,16 @@ target_link_libraries(sbc_harness_objs pico_minimize_runtime(sbc_harness_objs INCLUDE PRINTF PRINTF_MINIMAL PRINTF_LONG_LONG PRINTF_PTRDIFF_T ) +target_compile_definitions(sbc_harness_objs PRIVATE + #PICO_USE_FASTEST_SUPPORTED_CLOCK=1 + + # Calculated by `./3rd-party/pico-sdk/src/rp2_common/hardware_clocks/scripts/vcocalc.py --cmake-only 170` + PLL_SYS_REFDIV=2 + PLL_SYS_VCO_FREQ_HZ=1530000000 + PLL_SYS_POSTDIV1=3 + PLL_SYS_POSTDIV2=3 + SYS_CLK_HZ=170000000 +) suppress_tinyusb_warnings() diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 8e2c5ee..c932ec0 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -168,7 +168,7 @@ COROUTINE init_cr(void *) { rp2040_hwspi_init(&globals.dev_spi, "W5500", RP2040_HWSPI_0, SPI_MODE_0, /* the W5500 supports mode 0 or mode 3 */ - 31250000, /* min(w5500, hwspi); w5500=80MHz; hwspi=31.25MHz, see rp2040_hwspi.h for a comment about why this is so low */ + 42500000, /* min(w5500, hwspi); w5500=80MHz; hwspi=42.5MHz, see rp2040_hwspi.h for a comment about why this is so low */ 30, /* W5500 datasheet says min(T_CS = SCSn High Time) = 30ns */ 0, /* bogus write write data when doing a read */ 16, /* PIN_MISO */ -- cgit v1.2.3-2-g168b