diff options
Diffstat (limited to 'cmd/sbc_harness')
-rw-r--r-- | cmd/sbc_harness/main.c | 8 | ||||
-rw-r--r-- | cmd/sbc_harness/usb_keyboard.c | 8 | ||||
-rw-r--r-- | cmd/sbc_harness/usb_keyboard.h | 7 |
3 files changed, 15 insertions, 8 deletions
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 <string.h> /* for strlen() */ +#include <stdio.h> /* for printf() */ #include "pico/stdlib.h" #include <libcr/coroutine.h> @@ -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 <libcr_ipc/rpc.h> +#include <stdint.h> /* for uint32_t */ -typedef cr_rpc_t(uint32_t, int) usb_keyboard_rpc_t; +#include <libcr/coroutine.h> /* for COROUTINE */ +#include <libcr_ipc/rpc.h> /* for CR_RPC_DECLARE */ + +CR_RPC_DECLARE(usb_keyboard_rpc, uint32_t, int) void usb_keyboard_init(void); COROUTINE usb_keyboard_cr(void *arg); |