summaryrefslogtreecommitdiff
path: root/cmd/harness/main.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-26 19:36:54 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2024-09-26 19:36:54 -0600
commit71e1a86a033c380f85dd300d788af63bfef25bab (patch)
tree07aa53d5a933ba51535a78972edbfe0cd95a31c5 /cmd/harness/main.c
parentf5da707e77ee954b12f3c961012e4f40fa4e1bd3 (diff)
wip reorg
Diffstat (limited to 'cmd/harness/main.c')
-rw-r--r--cmd/harness/main.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/cmd/harness/main.c b/cmd/harness/main.c
new file mode 100644
index 0000000..1fd9f8c
--- /dev/null
+++ b/cmd/harness/main.c
@@ -0,0 +1,48 @@
+/* main.c - Main entry point and event loop for sbc-harness
+ *
+ * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * SPDX-Licence-Identifier: AGPL-3.0-or-later
+ */
+
+/* newlib */
+#include <string.h> /* for strlen() */
+
+/* pico-sdk */
+#include "pico/stdlib.h"
+
+/* local */
+#include "coroutine.h"
+#include "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)) {
+ cr_rpc_req(chan, NULL, msg[i]);
+ }
+
+ cr_end();
+}
+
+int main() {
+ /* initialization */
+ stdio_uart_init();
+ //gpio_init(PICO_DEFAULT_LED_PIN);
+ //gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
+
+ 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);
+
+ /* Event loop. */
+ coroutine_main();
+}