diff options
Diffstat (limited to 'cmd/sbc_harness')
-rw-r--r-- | cmd/sbc_harness/main.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index b17725d..ce80711 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -10,10 +10,11 @@ #include <hardware/flash.h> /* pico-sdk:hardware_flash: for flash_get_unique_id() */ #include <libcr/coroutine.h> +#include <libhw/generic/alarmclock.h> /* so we can set `bootclock` */ #include <libhw/rp2040_hwspi.h> +#include <libhw/rp2040_hwtimer.h> #include <libhw/w5500.h> #include <libmisc/hash.h> -#include <libmisc/vcall.h> #include <libusb/usb_common.h> #include <libdhcp/client.h> #include <lib9p/srv.h> @@ -41,15 +42,6 @@ static COROUTINE hello_world_cr(void *_chan) { cr_end(); } -static COROUTINE dhcp_cr(void *_chip) { - struct w5500 *chip = _chip; - cr_begin(); - - dhcp_client_main(chip, "harness"); - - cr_end(); -} - struct { struct rp2040_hwspi dev_spi; struct w5500 dev_w5500; @@ -58,11 +50,19 @@ struct { struct lib9p_srv srv; } globals; +static COROUTINE dhcp_cr(void *) { + cr_begin(); + + dhcp_client_main(lo_box_w5500_if_as_net_iface(&globals.dev_w5500), "harness"); + + cr_end(); +} + static COROUTINE read9p_cr(void *) { cr_begin(); lib9p_srv_read_cr(&globals.srv, - VCALL(&globals.dev_w5500, tcp_listen, CONFIG_9P_PORT)); + LO_CALL(lo_box_w5500_if_as_net_iface(&globals.dev_w5500), tcp_listen, CONFIG_9P_PORT)); cr_end(); } @@ -94,7 +94,8 @@ COROUTINE init_cr(void *) { 19, /* PIN_MOSI */ 18, /* PIN_CLK */ 17); /* PIN_CS */ - w5500_init(&globals.dev_w5500, "W5500", &globals.dev_spi, + w5500_init(&globals.dev_w5500, "W5500", + lo_box_rp2040_hwspi_as_spi(&globals.dev_spi), 21, /* PIN_INTR */ 20, /* PIN_RESET */ ((struct net_eth_addr){{ @@ -117,7 +118,7 @@ COROUTINE init_cr(void *) { coroutine_add("usb_common", usb_common_cr, NULL); coroutine_add("usb_keyboard", usb_keyboard_cr, &globals.keyboard_chan); coroutine_add("hello_world", hello_world_cr, &globals.keyboard_chan); - coroutine_add_with_stack_size(4*1024, "dhcp", dhcp_cr, &globals.dev_w5500); + coroutine_add_with_stack_size(4*1024, "dhcp", dhcp_cr, NULL); for (int i = 0; i < _CONFIG_9P_NUM_SOCKS; i++) { char name[] = {'r', 'e', 'a', 'd', '-', hexdig[i], '\0'}; coroutine_add(name, read9p_cr, NULL); @@ -131,6 +132,7 @@ COROUTINE init_cr(void *) { } int main() { + bootclock = rp2040_hwtimer(0); stdio_uart_init(); /* char *hdr = "=" * (80-strlen("info : MAIN: ")); */ infof("==================================================================="); |