Skip to content

Commit f8ac1dd

Browse files
committed
Add an example echo bot using the USB Gecko
This program repeats every byte it is fed.
1 parent 11b8584 commit f8ac1dd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/bin/echo-bot.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! This is an example of how to communicate with an USB Gecko using Luma.
2+
3+
#![no_std]
4+
5+
extern crate luma_core;
6+
extern crate luma_runtime;
7+
8+
use luma_core::exi::Exi;
9+
use luma_core::exi::usb_gecko::UsbGecko;
10+
11+
fn main() {
12+
let exi = Exi::init();
13+
let gecko = UsbGecko::new(&exi).unwrap();
14+
loop {
15+
// TODO: use interrupts here, instead of a busy loop.
16+
let buf = match gecko.receive() {
17+
Ok(buf) => buf,
18+
Err(_) => continue,
19+
};
20+
gecko.send(&buf).unwrap();
21+
}
22+
}

0 commit comments

Comments
 (0)