From 4da8e81989f6ed86628d6497397b22e0cd8daf53 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Mon, 30 Sep 2024 21:29:08 -0600 Subject: libcr_ipc: Redo --- cmd/sbc_harness/main.c | 8 ++++++-- cmd/sbc_harness/usb_keyboard.c | 8 ++++---- cmd/sbc_harness/usb_keyboard.h | 7 +++++-- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/cmd/sbc_harness/main.c b/cmd/sbc_harness/main.c index 31ce30b..e2b3b15 100644 --- a/cmd/sbc_harness/main.c +++ b/cmd/sbc_harness/main.c @@ -5,6 +5,7 @@ */ #include /* for strlen() */ +#include /* for printf() */ #include "pico/stdlib.h" #include @@ -18,8 +19,11 @@ COROUTINE hello_world_cr(void *_chan) { cr_begin(); for (size_t i = 0;; i = (i+1) % strlen(msg)) { - int result; - cr_rpc_req(chan, &result, (uint32_t)msg[i]); + int result = usb_keyboard_rpc_send_req(chan, (uint32_t)msg[i]); + if (result < 1) { + printf("error!\n"); + break; + } } cr_end(); diff --git a/cmd/sbc_harness/usb_keyboard.c b/cmd/sbc_harness/usb_keyboard.c index 5482fdc..4e20330 100644 --- a/cmd/sbc_harness/usb_keyboard.c +++ b/cmd/sbc_harness/usb_keyboard.c @@ -56,9 +56,9 @@ COROUTINE usb_keyboard_cr(void *_chan) { while (!tud_hid_n_ready(kbd_ifc)) cr_yield(); - if (cr_rpc_have_req(chan)) { - uint32_t rune; - cr_rpc_recv_req(chan, &rune); + if (usb_keyboard_rpc_can_recv_req(chan)) { + usb_keyboard_rpc_req_t req = usb_keyboard_rpc_recv_req(chan); + uint32_t rune = req.req; modifier = ascii2keycode[rune][0] ? KEYBOARD_MODIFIER_LEFTSHIFT : 0; keycodes[0] = ascii2keycode[rune][1]; @@ -71,7 +71,7 @@ COROUTINE usb_keyboard_cr(void *_chan) { keycodes[0] = 0; tud_hid_n_keyboard_report(kbd_ifc, report_id, modifier, keycodes); - cr_rpc_send_resp(chan, 1); + usb_keyboard_rpc_send_resp(req, 1); } else { modifier = 0; keycodes[0] = 0; diff --git a/cmd/sbc_harness/usb_keyboard.h b/cmd/sbc_harness/usb_keyboard.h index 8eba062..d946ff6 100644 --- a/cmd/sbc_harness/usb_keyboard.h +++ b/cmd/sbc_harness/usb_keyboard.h @@ -7,9 +7,12 @@ #ifndef _USB_KEYBOARD_H_ #define _USB_KEYBOARD_H_ -#include +#include /* for uint32_t */ -typedef cr_rpc_t(uint32_t, int) usb_keyboard_rpc_t; +#include /* for COROUTINE */ +#include /* for CR_RPC_DECLARE */ + +CR_RPC_DECLARE(usb_keyboard_rpc, uint32_t, int) void usb_keyboard_init(void); COROUTINE usb_keyboard_cr(void *arg); -- cgit v1.2.3-2-g168b