summaryrefslogtreecommitdiff
path: root/cmd/sbc_harness/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/sbc_harness/main.c')
-rw-r--r--cmd/sbc_harness/main.c87
1 files changed, 0 insertions, 87 deletions
diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c
deleted file mode 100644
index b9c5330..0000000
--- a/cmd/sbc_harness/main.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/* sbc_harness/main.c - Main entry point and event loop for sbc-harness
- *
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-#include <string.h> /* libc: for strlen() */
-#include <stdio.h> /* libc: for printf() */
-
-#include <pico/stdlib.h> /* pico-sdk:pico_stdlib: for stdio_uart_init() */
-#include <hardware/flash.h> /* pico-sdk:hardware_flash: for flash_get_unique_id() */
-
-#include <libcr/coroutine.h>
-#include <libhw/rp2040_hwspi.h>
-#include <libhw/w5500.h>
-#include <libmisc/hash.h>
-#include <libusb/usb_common.h>
-
-#include "usb_keyboard.h"
-
-COROUTINE hello_world_cr(void *_chan) {
- const char *msg = "Hello world!\n";
- usb_keyboard_rpc_t *chan = _chan;
- cr_begin();
-
- for (size_t i = 0;; i = (i+1) % strlen(msg)) {
- int result = usb_keyboard_rpc_send_req(chan, (uint32_t)msg[i]);
- if (result < 1) {
- printf("error!\n");
- break;
- }
- }
-
- cr_end();
-}
-
-int main() {
- /* initialization *****************************************************/
- stdio_uart_init();
-
- /* NOR flash chips have a (bog-?)standard "RUID" "Read Unique
- * ID" instruction; use our flash chip's unique ID as the
- * basis for our serial numbers. */
- uint64_t flash_id64;
- static_assert(sizeof(flash_id64) == FLASH_UNIQUE_ID_SIZE_BYTES);
- flash_get_unique_id((uint8_t *)&flash_id64);
- uint32_t flash_id32 = hash(&flash_id64, sizeof(flash_id64));
- static_assert(sizeof(flash_id32) == sizeof(hash(NULL, 0)));
- uint8_t flash_id24[3] = {
- (uint8_t)((flash_id32 >> 16) & 0xFF),
- (uint8_t)((flash_id32 >> 8) & 0xFF),
- (uint8_t)((flash_id32 >> 0) & 0xFF),
- };
-
- struct rp2040_hwspi dev_spi;
- struct w5500 dev_w5500;
- rp2040_hwspi_init(&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,
- 21, /* PIN_INTR */
- 20, /* PIN_RESET */
- ((struct net_eth_addr){{
- /* vendor ID: "Wiznet" */
- 0x00, 0x08, 0xDC,
- /* serial number */
- flash_id24[0], flash_id24[1], flash_id24[2],
- }}));
-
- usb_common_earlyinit();
- usb_keyboard_init();
- usb_common_lateinit();
-
- /* set up coroutines **************************************************/
- coroutine_add(usb_common_cr, NULL);
- usb_keyboard_rpc_t keyboard_chan = {0};
- coroutine_add(usb_keyboard_cr, &keyboard_chan);
- //coroutine_add(hello_world_cr, &keyboard_chan);
- //coroutine_add(dhcp_client_cr, NULL);
-
- /* event loop *********************************************************/
- coroutine_main();
-}