Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wire up embassy-net #12

Merged
merged 9 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 181 additions & 19 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ cortex-m-semihosting = { version = "0.5" }
critical-section = { version = "1.1.2" }

embassy-executor = { version = "0.3.2", default-features = false }
embassy-net = { version = "0.2.1", default-features = false }
embassy-nrf = { version = "0.1.0", default-features = false }
embassy-rp = { version = "0.1.0", default-features = false }
embassy-sync = { version = "0.3.0", default-features = false }
embassy-time = { version = "0.1.5", default-features = false }
embassy-usb = { version = "0.1.0", default-features = false }

linkme = { version = "0.3.17", features = ["used_linker"] }

Expand All @@ -46,6 +48,7 @@ riot-wrappers = { version = "^0.8", default-features = false, features = [
"with_riot_rs",
] }

static_cell = { version = "2.0.0", features = [ "nightly" ] }
ld-memory = { version = "0.2.9" }

[profile.dev]
Expand Down Expand Up @@ -78,7 +81,9 @@ nrf52840-pac = { git = "https://github.com/kaspar030/nrf-pacs", branch = "riot-r
nrf52832-pac = { git = "https://github.com/kaspar030/nrf-pacs", branch = "riot-rs" }
embassy-macros = { git = "https://github.com/embassy-rs/embassy"}
embassy-executor = { git = "https://github.com/embassy-rs/embassy"}
embassy-net = { git = "https://github.com/embassy-rs/embassy"}
embassy-nrf = { git = "https://github.com/embassy-rs/embassy"}
embassy-rp = { git = "https://github.com/embassy-rs/embassy"}
embassy-time = { git = "https://github.com/embassy-rs/embassy"}
embassy-sync = { git = "https://github.com/embassy-rs/embassy"}
embassy-usb = { git = "https://github.com/embassy-rs/embassy"}
13 changes: 13 additions & 0 deletions examples/embassy-net/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "embassy-net"
version = "0.1.0"
authors.workspace = true
edition.workspace = true
publish = false

[dependencies]
riot-rs = { path = "../../src/riot-rs", features = [ "time", "usb_ethernet"] }
riot-rs-boards = { path = "../../src/riot-rs-boards" }
embassy-executor = { workspace = true, default-features = false }
embassy-time = { workspace = true, default-features = false }
embassy-sync = { workspace = true, default-features = false }
15 changes: 15 additions & 0 deletions examples/embassy-net/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# embassy-net

## About

This application is testing basic
[embassy](https://github.com/embassy-rs/embassy) _networking_ usage with RIOT-rs.

## How to run

In this folder, run

laze build -b nrf52840dk run

With the device USB cable connected, a USB ethernet device should pop up.
RIOT-rs will reply to ping requests on 10.0.42.61.
4 changes: 4 additions & 0 deletions examples/embassy-net/laze.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apps:
- name: embassy-net
selects:
- ?release
48 changes: 48 additions & 0 deletions examples/embassy-net/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#![no_main]
#![no_std]
#![feature(type_alias_impl_trait)]

use riot_rs as _;

use riot_rs::rt::debug::println;

use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
use riot_rs::embassy::{blocker, EXECUTOR};

static SIGNAL: Signal<CriticalSectionRawMutex, u32> = Signal::new();

#[embassy_executor::task]
async fn async_task() {
use embassy_time::{Duration, Timer, TICK_HZ};
let mut counter = 0u32;
loop {
if counter % 2 == 0 {
println!("async_task() signalling");
SIGNAL.signal(counter);
} else {
println!("async_task()");
}
Timer::after(Duration::from_ticks(TICK_HZ / 10)).await;
counter += 1;
}
}

#[no_mangle]
fn riot_main() {
println!(
"Hello from riot_main()! Running on a {} board.",
riot_rs::buildinfo::BOARD
);

let spawner = EXECUTOR.spawner();
spawner.spawn(async_task()).unwrap();

loop {
let val = blocker::block_on(SIGNAL.wait());
println!(
"now={}ms threadtest() val={}",
Instant::now().as_millis(),
val
);
}
}
1 change: 1 addition & 0 deletions examples/laze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ subdirs:
- bottles
- core-sizes
- embassy
- embassy-net
# - embassy-gpio
- hello-world
- minimal
Expand Down
11 changes: 10 additions & 1 deletion src/riot-rs-embassy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,22 @@ edition = "2021"
[dependencies]
# always
linkme.workspace = true
static_cell.workspace = true
critical-section.workspace = true
embassy-sync = { workspace = true }
riot-rs-core = { path = "../riot-rs-core" }
riot-rs-rt = { path = "../riot-rs-rt" }
critical-section.workspace = true

# time
embassy-time = { workspace = true, optional = true, features = [
"nightly",
"unstable-traits",
] }

embassy-usb = { workspace = true, optional = true }
embassy-net = { workspace = true, optional = true, features = [ "dhcpv4", "medium-ethernet" ] }
heapless = "0.8.0"

[target.'cfg(context = "cortex-m")'.dependencies]
embassy-executor = { workspace = true, features = [
"arch-cortex-m",
Expand All @@ -26,6 +31,7 @@ embassy-executor = { workspace = true, features = [

[target.'cfg(context = "nrf52")'.dependencies]
embassy-nrf = { workspace = true, features = [
"nightly",
"time-driver-rtc1",
"time",
"unstable-pac",
Expand Down Expand Up @@ -53,3 +59,6 @@ embassy-rp = { workspace = true, features = [

[features]
time = ["dep:embassy-time", "embassy-executor/integrated-timers"]
usb = [ "dep:embassy-usb" ]
net = [ "dep:embassy-net" ]
usb_ethernet = [ "usb", "net" ]
Loading
Loading