summaryrefslogtreecommitdiff
path: root/cmd/sbc_harness
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-04 00:18:23 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-04 00:18:23 -0700
commit47cee5df1e5e63a8d0a5f1b634ac6d4e1ff00af7 (patch)
treed72daabeedecbc397cdce739639f8cf2cb947685 /cmd/sbc_harness
parent355d7a495b0ca1a622d600427a8c737f3207a803 (diff)
parent3f49a57b99e7fe5aafa73e70ed146d98b1ae174c (diff)
Merge branch 'lukeshu/dma'
Diffstat (limited to 'cmd/sbc_harness')
-rw-r--r--cmd/sbc_harness/CMakeLists.txt10
-rw-r--r--cmd/sbc_harness/config/config.h6
-rw-r--r--cmd/sbc_harness/main.c13
3 files changed, 23 insertions, 6 deletions
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/config/config.h b/cmd/sbc_harness/config/config.h
index f9c7df2..e923ac8 100644
--- a/cmd/sbc_harness/config/config.h
+++ b/cmd/sbc_harness/config/config.h
@@ -9,6 +9,10 @@
#include <stddef.h> /* for size_t */
+/* RP2040 *********************************************************************/
+
+#define CONFIG_RP2040_SPI_DEBUG 1 /* bool */
+
/* W5500 **********************************************************************/
/**
@@ -22,8 +26,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 *************************************************************************/
diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c
index 6f1d0ca..c932ec0 100644
--- a/cmd/sbc_harness/main.c
+++ b/cmd/sbc_harness/main.c
@@ -168,11 +168,14 @@ 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 */
+ 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 */
+ 19, /* PIN_MOSI */
+ 18, /* PIN_CLK */
+ 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 */