From cb2236cf4664463e4249ee5fa9f2552a474d294e Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 22 Nov 2021 23:22:11 +0100 Subject: [PATCH] =?UTF-8?q?Add=20an=20example=20echo=20bot=20using=20the?= =?UTF-8?q?=20USB=C2=A0Gecko?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This program repeats every byte it is fed. --- src/bin/echo-bot.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/bin/echo-bot.rs diff --git a/src/bin/echo-bot.rs b/src/bin/echo-bot.rs new file mode 100644 index 0000000..4daa426 --- /dev/null +++ b/src/bin/echo-bot.rs @@ -0,0 +1,22 @@ +//! This is an example of how to communicate with an USBĀ Gecko using Luma. + +#![no_std] + +extern crate luma_core; +extern crate luma_runtime; + +use luma_core::exi::usb_gecko::UsbGecko; +use luma_core::exi::Exi; + +fn main() { + let exi = Exi::init(); + let gecko = UsbGecko::new(&exi).unwrap(); + loop { + // TODO: use interrupts here, instead of a busy loop. + let buf = match gecko.receive() { + Ok(buf) => buf, + Err(_) => continue, + }; + gecko.send(&buf).unwrap(); + } +}