diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/sbc_harness/main.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 85dfdfb..bdd23a7 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -44,9 +44,14 @@ COROUTINE dhcp_cr(void *_chip) { cr_end(); } -int main() { - /* initialization *****************************************************/ - stdio_uart_init(); +struct { + struct rp2040_hwspi dev_spi; + struct w5500 dev_w5500; + usb_keyboard_rpc_t keyboard_chan; +} globals; + +COROUTINE init_cr(void *) { + cr_begin(); /* NOR flash chips have a (bog-?)standard "RUID" "Read Unique * ID" instruction; use our flash chip's unique ID as the @@ -62,16 +67,14 @@ int main() { (uint8_t)((flash_id32 >> 0) & 0xFF), }; - struct rp2040_hwspi dev_spi; - struct w5500 dev_w5500; - rp2040_hwspi_init(&dev_spi, "W5500", RP2040_HWSPI_0, + rp2040_hwspi_init(&globals.dev_spi, "W5500", RP2040_HWSPI_0, SPI_MODE_0, /* the W5500 supports mode 0 or mode 3 */ 80*1000*1000, /* run at the W5500's max rate of 80MHz */ 16, /* PIN_MISO */ 19, /* PIN_MOSI */ 18, /* PIN_CLK */ 17); /* PIN_CS */ - w5500_init(&dev_w5500, "W5500", &dev_spi, + w5500_init(&globals.dev_w5500, "W5500", &globals.dev_spi, 21, /* PIN_INTR */ 20, /* PIN_RESET */ ((struct net_eth_addr){{ @@ -85,13 +88,19 @@ int main() { usb_keyboard_init(); usb_common_lateinit(); + globals.keyboard_chan = (usb_keyboard_rpc_t){0}; + /* set up coroutines **************************************************/ coroutine_add("usb_common", usb_common_cr, NULL); - usb_keyboard_rpc_t keyboard_chan = {0}; - coroutine_add("usb_keyboard", usb_keyboard_cr, &keyboard_chan); + coroutine_add("usb_keyboard", usb_keyboard_cr, &globals.keyboard_chan); //coroutine_add("hello_world", hello_world_cr, &keyboard_chan); - coroutine_add_with_stack_size(4*1024, "dhcp", dhcp_cr, &dev_w5500); + coroutine_add_with_stack_size(4*1024, "dhcp", dhcp_cr, &globals.dev_w5500); - /* event loop *********************************************************/ + cr_exit(); +} + +int main() { + stdio_uart_init(); + coroutine_add("init", init_cr, NULL); coroutine_main(); } |